예제 #1
0
	QWidget* TodoListDelegate::createEditor (QWidget *parent,
			const QStyleOptionViewItem& option, const QModelIndex& index) const
	{
		switch (index.column ())
		{
		case StorageModel::Columns::Tags:
		{
			auto edit = new Util::TagsLineEdit (parent);
			new Util::TagsCompleter (edit);
			edit->AddSelector ();
			edit->setText (index.data (Qt::EditRole).toString ());
			edit->setFrame (false);
			return edit;
		}
		case StorageModel::Columns::DueDate:
		case StorageModel::Columns::Created:
		{
			auto edit = new QDateTimeEdit (parent);
			edit->setFrame (false);
			edit->setCalendarPopup (true);
			edit->setDateTime (index.data (Qt::EditRole).toDateTime ());
			return edit;
		}
		default:
			return QStyledItemDelegate::createEditor (parent, option, index);
		}
	}
예제 #2
0
	void CodeDateTimeEdit::codeChanged(bool code)
	{
		if(!code)
		{
			setCalendarPopup(true);
			setButtonSymbols(QAbstractSpinBox::UpDownArrows);
			setDateTime(QDateTime::currentDateTime());
			setDisplayFormat("dd/MM/yyyy hh:mm:ss");
			codeLineEdit()->textChanged(codeLineEdit()->text());
		}
		else
		{
			setDisplayFormat(QString());
			setCalendarPopup(false);
			setButtonSymbols(QAbstractSpinBox::NoButtons);
		}
	}
예제 #3
0
QWidget *DateEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &/*option*/, const QModelIndex &/*index*/) const
{
    auto editor = new QDateEdit(parent);

    editor->setDisplayFormat("dd/MMMM/yy");
    editor->setCalendarPopup(true);
    editor->setDate(QDate::currentDate());

    return editor;
}
예제 #4
0
	CodeDateTimeEdit::CodeDateTimeEdit(QWidget *parent)
	: QDateTimeEdit(parent)
	{
		CodeLineEdit *codeLineEdit = new CodeLineEdit(parent);
		codeLineEdit->setEmbedded(true);
		setLineEdit(codeLineEdit);

		setCalendarPopup(true);

		connect(codeLineEdit, SIGNAL(codeChanged(bool)), this, SLOT(codeChanged(bool)));

		addActions(codeLineEdit->actions());
	}
예제 #5
0
KPropertyDateTimeEditor::KPropertyDateTimeEditor(const KProperty* prop, QWidget* parent)
    : QDateTimeEdit(parent)
{
    setFrame(false);
    setCalendarPopup(true);

    const QDateTime minDateTime = prop->option("min").toDateTime();
    if (minDateTime.isValid()) {
        setMinimumDateTime(minDateTime);
    }
    const QDateTime maxDateTime = prop->option("max").toDateTime();
    if (maxDateTime.isValid()) {
        setMaximumDateTime(maxDateTime);
    }

    connect(this, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(onDateTimeChanged()));
}
예제 #6
0
QgsDateTimeEdit::QgsDateTimeEdit( QWidget *parent )
  : QDateTimeEdit( parent )
{
  QIcon clearIcon = QgsApplication::getThemeIcon( "/mIconClearText.svg" );
  mClearAction = new QAction( clearIcon, tr( "clear" ), this );
  mClearAction->setCheckable( false );
  lineEdit()->addAction( mClearAction, QLineEdit::TrailingPosition );
  mClearAction->setVisible( mAllowNull );
  connect( mClearAction, &QAction::triggered, this, &QgsDateTimeEdit::clear );

  connect( this, &QDateTimeEdit::dateTimeChanged, this, &QgsDateTimeEdit::changed );

  // enable calendar widget by default so it's already created
  setCalendarPopup( true );

  setMinimumEditDateTime();

  // init with current time so mIsNull is properly initialized
  QDateTimeEdit::setDateTime( QDateTime::currentDateTime() );
}
예제 #7
0
int QDateTimeEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractSpinBox::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 7)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 7;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QDateTime*>(_v) = dateTime(); break;
        case 1: *reinterpret_cast< QDate*>(_v) = date(); break;
        case 2: *reinterpret_cast< QTime*>(_v) = time(); break;
        case 3: *reinterpret_cast< QDateTime*>(_v) = maximumDateTime(); break;
        case 4: *reinterpret_cast< QDateTime*>(_v) = minimumDateTime(); break;
        case 5: *reinterpret_cast< QDate*>(_v) = maximumDate(); break;
        case 6: *reinterpret_cast< QDate*>(_v) = minimumDate(); break;
        case 7: *reinterpret_cast< QTime*>(_v) = maximumTime(); break;
        case 8: *reinterpret_cast< QTime*>(_v) = minimumTime(); break;
        case 9: *reinterpret_cast< Section*>(_v) = currentSection(); break;
        case 10: *reinterpret_cast<int*>(_v) = QFlag(displayedSections()); break;
        case 11: *reinterpret_cast< QString*>(_v) = displayFormat(); break;
        case 12: *reinterpret_cast< bool*>(_v) = calendarPopup(); break;
        case 13: *reinterpret_cast< int*>(_v) = currentSectionIndex(); break;
        case 14: *reinterpret_cast< int*>(_v) = sectionCount(); break;
        case 15: *reinterpret_cast< Qt::TimeSpec*>(_v) = timeSpec(); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDateTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 1: setDate(*reinterpret_cast< QDate*>(_v)); break;
        case 2: setTime(*reinterpret_cast< QTime*>(_v)); break;
        case 3: setMaximumDateTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 4: setMinimumDateTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 5: setMaximumDate(*reinterpret_cast< QDate*>(_v)); break;
        case 6: setMinimumDate(*reinterpret_cast< QDate*>(_v)); break;
        case 7: setMaximumTime(*reinterpret_cast< QTime*>(_v)); break;
        case 8: setMinimumTime(*reinterpret_cast< QTime*>(_v)); break;
        case 9: setCurrentSection(*reinterpret_cast< Section*>(_v)); break;
        case 11: setDisplayFormat(*reinterpret_cast< QString*>(_v)); break;
        case 12: setCalendarPopup(*reinterpret_cast< bool*>(_v)); break;
        case 13: setCurrentSectionIndex(*reinterpret_cast< int*>(_v)); break;
        case 15: setTimeSpec(*reinterpret_cast< Qt::TimeSpec*>(_v)); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 3: clearMaximumDateTime(); break;
        case 4: clearMinimumDateTime(); break;
        case 5: clearMaximumDate(); break;
        case 6: clearMinimumDate(); break;
        case 7: clearMaximumTime(); break;
        case 8: clearMinimumTime(); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 16;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}