Esempio n. 1
0
void SideBarCalendar::setUpViewMiniCalendar(){

    miniCal = new CustomCalendarWidget;
    QToolButton* next = new QToolButton;
    QToolButton* prev = new QToolButton;
    QPushButton* today = new QPushButton("Aujourd'hui");
    year = new QLabel(QString::number(miniCal->selectedDate().year()));
    month = new QLabel(QDate::longMonthName(miniCal->selectedDate().month()));

    QString styleToolButton = "QToolButton {background-color: rgba(0,0,0,0)}";
    QSize sizeToolButton(24,24);
    next->setIcon(QIcon(":/icons/img/icons/ic_chevron_right_48px.svg"));
    next->setStyleSheet(styleToolButton);
    next->setIconSize(sizeToolButton);
    next->setCursor(Qt::PointingHandCursor);

    prev->setIcon(QIcon(":/icons/img/icons/ic_chevron_left_48px.svg"));
    prev->setStyleSheet(styleToolButton);
    prev->setIconSize(sizeToolButton);
    prev->setCursor(Qt::PointingHandCursor);

    /* Infos jour sélectionné
     * Contient : No du jour et nom du jour de la semaine
     */
    currentDayCal = new DayWidget;
    currentDayCal->setDayName(QDate::longDayName(miniCal->selectedDate().dayOfWeek()));
    currentDayCal->setDayNumber(miniCal->selectedDate().day());

    /* Header
     * Contient: Bouton next, prev, mois et année
     */
    QWidget* header = new QWidget;
    header->setStyleSheet("QLabel{font-size: 16px;}");
    QHBoxLayout* headerLayout = new QHBoxLayout;
    headerLayout->addWidget(prev);
    headerLayout->addStretch(1);
    headerLayout->addWidget(month);
    headerLayout->addWidget(year);
    headerLayout->addStretch(1);
    headerLayout->addWidget(next);
    header->setLayout(headerLayout);

    /*
     * Layout principale
     * Contient: Header et Calendar
     */
    layoutMiniCalendar = new QVBoxLayout;

    layoutMiniCalendar->addWidget(currentDayCal);
    layoutMiniCalendar->addWidget(header);
    layoutMiniCalendar->addWidget(today, 0, Qt::AlignCenter);
    layoutMiniCalendar->addWidget(miniCal, 0, Qt::AlignHCenter);
    layoutMiniCalendar->addStretch(1);
    miniCal->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    miniCal->setFixedHeight(280);
    miniCal->setFixedWidth(280);

    connect(prev, SIGNAL(clicked()), miniCal, SLOT(showPreviousMonth()));
    connect(next, SIGNAL(clicked()), miniCal, SLOT(showNextMonth()));
    connect(miniCal, SIGNAL(currentPageChanged(int,int)), this, SLOT(pageChanged(int,int)));
    connect(miniCal, SIGNAL(selectionChanged()), this, SLOT(onDayClicked()));
    connect(today, SIGNAL(clicked()), this, SLOT(onTodayClicked()));

    viewMiniCalendar->setLayout(layoutMiniCalendar);
}
int QCalendarWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: selectionChanged(); break;
        case 1: clicked((*reinterpret_cast< const QDate(*)>(_a[1]))); break;
        case 2: activated((*reinterpret_cast< const QDate(*)>(_a[1]))); break;
        case 3: currentPageChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: setSelectedDate((*reinterpret_cast< const QDate(*)>(_a[1]))); break;
        case 5: setDateRange((*reinterpret_cast< const QDate(*)>(_a[1])),(*reinterpret_cast< const QDate(*)>(_a[2]))); break;
        case 6: setCurrentPage((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 7: setGridVisible((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: setNavigationBarVisible((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 9: showNextMonth(); break;
        case 10: showPreviousMonth(); break;
        case 11: showNextYear(); break;
        case 12: showPreviousYear(); break;
        case 13: showSelectedDate(); break;
        case 14: showToday(); break;
        case 15: d_func()->_q_slotShowDate((*reinterpret_cast< const QDate(*)>(_a[1]))); break;
        case 16: d_func()->_q_slotChangeDate((*reinterpret_cast< const QDate(*)>(_a[1]))); break;
        case 17: d_func()->_q_slotChangeDate((*reinterpret_cast< const QDate(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 18: d_func()->_q_editingFinished(); break;
        case 19: d_func()->_q_prevMonthClicked(); break;
        case 20: d_func()->_q_nextMonthClicked(); break;
        case 21: d_func()->_q_yearEditingFinished(); break;
        case 22: d_func()->_q_yearClicked(); break;
        case 23: d_func()->_q_monthChanged((*reinterpret_cast< QAction*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 24;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QDate*>(_v) = selectedDate(); break;
        case 1: *reinterpret_cast< QDate*>(_v) = minimumDate(); break;
        case 2: *reinterpret_cast< QDate*>(_v) = maximumDate(); break;
        case 3: *reinterpret_cast< Qt::DayOfWeek*>(_v) = firstDayOfWeek(); break;
        case 4: *reinterpret_cast< bool*>(_v) = isGridVisible(); break;
        case 5: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break;
        case 6: *reinterpret_cast< HorizontalHeaderFormat*>(_v) = horizontalHeaderFormat(); break;
        case 7: *reinterpret_cast< VerticalHeaderFormat*>(_v) = verticalHeaderFormat(); break;
        case 8: *reinterpret_cast< bool*>(_v) = isHeaderVisible(); break;
        case 9: *reinterpret_cast< bool*>(_v) = isNavigationBarVisible(); break;
        case 10: *reinterpret_cast< bool*>(_v) = isDateEditEnabled(); break;
        case 11: *reinterpret_cast< int*>(_v) = dateEditAcceptDelay(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setSelectedDate(*reinterpret_cast< QDate*>(_v)); break;
        case 1: setMinimumDate(*reinterpret_cast< QDate*>(_v)); break;
        case 2: setMaximumDate(*reinterpret_cast< QDate*>(_v)); break;
        case 3: setFirstDayOfWeek(*reinterpret_cast< Qt::DayOfWeek*>(_v)); break;
        case 4: setGridVisible(*reinterpret_cast< bool*>(_v)); break;
        case 5: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        case 6: setHorizontalHeaderFormat(*reinterpret_cast< HorizontalHeaderFormat*>(_v)); break;
        case 7: setVerticalHeaderFormat(*reinterpret_cast< VerticalHeaderFormat*>(_v)); break;
        case 8: setHeaderVisible(*reinterpret_cast< bool*>(_v)); break;
        case 9: setNavigationBarVisible(*reinterpret_cast< bool*>(_v)); break;
        case 10: setDateEditEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 11: setDateEditAcceptDelay(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}