CalendarBox::Inner::Inner(QWidget *parent, Context *context)
: TWidget(parent)
, _context(context) {
	setMouseTracking(true);
	subscribe(context->month(), [this](QDate month) {
		monthChanged(month);
	});
}
Ejemplo n.º 2
0
void QQuickMonthModel::setMonth(int month)
{
    Q_D(QQuickMonthModel);
    if (d->month != month) {
        if (d->populate(month, d->year, d->locale))
            emit dataChanged(index(0, 0), index(daysOnACalendarMonth - 1, 0));
        d->month = month;
        emit monthChanged();
    }
}
Ejemplo n.º 3
0
void CalendarWidget::nextMonth()
{
    active_j_m += 1;
    if (active_j_m == 13)
    {
        active_j_m = 1;
        active_j_y += 1;
    }

    calculateDrawMonthUpdate();
    emit monthChanged(active_j_y, active_j_m);
}
Ejemplo n.º 4
0
void CalendarWidget::prevMonth()
{
    active_j_m -= 1;
    if (active_j_m == 0)
    {
        active_j_m = 12;
        active_j_y -= 1;
    }

    calculateDrawMonthUpdate();
    emit monthChanged(active_j_y, active_j_m);
}
Ejemplo n.º 5
0
void CalendarWidget::today()
{
    bool emitMonthChanged = (active_j_y != realCurrent_j_y || active_j_m != realCurrent_j_m);

    active_j_y = realCurrent_j_y;
    active_j_m = realCurrent_j_m;


    calculateDrawMonthUpdate();
    if (emitMonthChanged)
        emit monthChanged(active_j_y, active_j_m);
}
Ejemplo n.º 6
0
void
Day::setMonth(int month) {
    if (month != _date.month()) {
        beginResetModel();

        _date.setDate(_date.year(), month, _date.day());
        emit monthChanged(month);
        emit dateChanged(_date);
        emit expenseSumChanged(_book->expenseForDay(_date.day(), _date.month(), _date.year()));
        emit incomeSumChanged(_book->incomeForDay(_date.day(), _date.month(), _date.year()));

        endResetModel();
    }
}
void CalendarBox::prepare() {
	_previous->setClickedCallback([this] {
		if (isPreviousEnabled()) {
			_context->skipMonth(-1);
		}
	});
	_next->setClickedCallback([this] {
		if (isNextEnabled()) {
			_context->skipMonth(1);
		}
	});

//	_inner = setInnerWidget(object_ptr<Inner>(this, _context.get()), st::calendarScroll, st::calendarTitleHeight);
	_inner->setDateChosenCallback(std::move(_callback));

	addButton(langFactory(lng_close), [this] { closeBox(); });

	subscribe(_context->month(), [this](QDate month) { monthChanged(month); });

	_context->start();
}
Ejemplo n.º 8
0
void
Day::setDate(QDate date) {
    if (date != _date) {
        beginResetModel();
        auto oldDate = _date;
        _date = date;
        emit dateChanged(date);

        if (_date.day() != oldDate.day()) {
            emit dayChanged(_date.day());
        }

        if (_date.month() != oldDate.month()) {
            emit monthChanged(_date.month());
        }

        if (_date.year() != oldDate.year()) {
            emit yearChanged(_date.year());
        }
        emit expenseSumChanged(_book->expenseForDay(_date.day(), _date.month(), _date.year()));
        emit incomeSumChanged(_book->incomeForDay(_date.day(), _date.month(), _date.year()));
        endResetModel();
    }
}
Ejemplo n.º 9
0
PickerPopup::PickerPopup(DatePicker *picker)
        : QFrame(NULL, "calendar", WType_Popup | WStyle_Customize | WStyle_Tool | WDestructiveClose)
{
    m_picker = picker;

    setFrameShape(PopupPanel);
    setFrameShadow(Sunken);
    setLineWidth(1);

    QDate d = QDate::currentDate();
    QLabel *lbl = new QLabel(this);
    lbl->setBackgroundMode(PaletteBase);
    QVBoxLayout *l = new QVBoxLayout(this);
    QHBoxLayout *hLay = new QHBoxLayout(l);
    hLay->setMargin(0);
    hLay->setSpacing(4);

    m_monthBox = new MonthSpinBox(this);
    hLay->addWidget(m_monthBox);
    m_yearBox = new QSpinBox(this);
    m_yearBox->setMaxValue(d.year());
    m_yearBox->setMinValue(d.year() - 200);
    m_monthBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
    hLay->addWidget(m_yearBox);
    connect(m_monthBox, SIGNAL(valueChanged(int)), this, SLOT(monthChanged(int)));
    connect(m_yearBox, SIGNAL(valueChanged(int)), this, SLOT(yearChanged(int)));
    l->addWidget(lbl);
    l->setMargin(6);
    l->setSpacing(4);

    QPalette pal(palette());
    pal.setColor(QColorGroup::Text, QColor(127, 0, 0));
    pal.setColor(QColorGroup::Foreground, QColor(255, 0, 0));
    QFont f(font());
    f.setBold(true);

    m_labels = new QLabel*[7 * 6];
    QGridLayout *lay = new QGridLayout(lbl, 7, 7);
    lay->setMargin(6);
    lay->setSpacing(4);
    unsigned n = 0;
    for (unsigned j = 0; j < 6; j++){
        for (unsigned i = 0; i < 7; i++){
            QLabel *l = new PickerLabel(lbl);
            l->setFont(f);
            l->setAlignment(AlignRight);
            l->setText("99");
            l->setMinimumSize(l->sizeHint());
            l->setText(QString::number(n));
            l->setBackgroundMode(PaletteBase);
            lay->addWidget(l, i, j + 1);
            m_labels[n++] = l;
            if (i >= 5)
                l->setPalette(pal);
            connect(l, SIGNAL(clicked(PickerLabel*)), this, SLOT(dayClick(PickerLabel*)));
        }
    }
    for (unsigned i = 0; i < 7; i++){
        QLabel *l = new QLabel(lbl);
        l->setFont(f);
        l->setText(i18n(day_name[i]));
        l->setBackgroundMode(PaletteBase);
        lay->addWidget(l, i, 0);
        if (i >= 5)
            l->setPalette(pal);
    }
    int day, month, year;
    m_picker->getDate(day, month, year);
    if ((month == 0) || (year == 0)){
        month = d.month();
        year  = d.year();
    }
    m_monthBox->setValue(month - 1);
    m_yearBox->setValue(year);
    monthChanged(month - 1);
    yearChanged(year);
}
	Title(QWidget *parent, Context *context)
	: TWidget(parent)
	, _context(context) {
		subscribe(_context->month(), [this](QDate date) { monthChanged(date); });
	}