예제 #1
0
static EventList createEventList( const QDate& start, const QDate& end, int minutes, const TaskId& taskId )
{
    Q_ASSERT( start < end );

    EventList events;

    const int days = start.daysTo( end );
#if QT_VERSION >= 0x040700
    events.reserve( days );
#endif
    for ( int i = 0; i < days; ++i ) {
        const QDate date = start.addDays( i );
        //for each work day, create an event starting at 8 am
        if ( isWorkDay( date ) ) {
            const QDateTime startTime = QDateTime( date, QTime( 8, 0  ) );
            const QDateTime endTime = startTime.addSecs( minutes * 60 );
            Event event;
            event.setTaskId( taskId );
            event.setStartDateTime( startTime );
            event.setEndDateTime( endTime );
            event.setComment( QObject::tr( "(created by vacation dialog)" ) );
            events.append( event );
        }
    }
    return events;
}
예제 #2
0
void CalendarDatePrivate::updateDayView(gboolean isForceLoad, GTimeSpan changed) {
    if (NULL == m_swipeBox[VIEWTYPE_DAY]) {
        initDayView();
    }

    ComputeDays();
    gint rowCount = 7;
    gint offsetCols = (m_isShowWeekNum ? 1 : 0);
    gint colCount = 7 + offsetCols;
    int row = 0;
    int col = 0;

    m_viewType = VIEWTYPE_DAY;

    GDateTime* selectedDate = g_date_time_new_local(m_selectedYear, m_selectedMonth, m_selectedDayOfMonth, 1, 1, 1);
    gchar* dateLabelText = g_date_time_format(selectedDate, C_("calendar heading", "%Y, %b"));
    gtk_button_set_label(GTK_BUTTON(m_viewTypeSwitch), dateLabelText);
    g_date_time_unref(selectedDate);
    g_free(dateLabelText);

    for (col = 0; col < colCount; ++col) {
        for (row = 0; row < rowCount; ++row) {
            if (m_isShowWeekNum && (0 == col)) {
                if (0 == row) {
                    // do nothing
                } else {
                    // do nothing
                } // end: if (0 == row)
            } else {
                if (0 == row) {
                } else {
                    if (NULL != m_dayItem[row - 1][col - offsetCols]) {
                        GDateTime* nowDate = g_date_time_new_now_local();
                        m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-day-base");
                        m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-day");
                        if (isWorkDay(col - offsetCols + m_weekStart)) {
                            m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-work-day");
                        } else {
                            m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-nonwork-day");
                        }


                        switch (m_dayMonth[row - 1][col - offsetCols]) {
                        case MONTH_CURRENT: {
                            GDateTime * currentDate = g_date_time_new_local(m_selectedYear, m_selectedMonth, m_day[row - 1][col - offsetCols],
                                                                            0, 0, 0);
                            if (isTheSameDate(nowDate, currentDate)) {
                                m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-today");
                            } else {
                                m_dayItem[row - 1][col - offsetCols]->removeStyleClass("calendar-today");
                            }
                            g_date_time_unref(currentDate);
                        }
                            break;
                        case MONTH_PREV:
                        case MONTH_NEXT:
                             m_dayItem[row - 1][col - offsetCols]->addStyleClass("calendar-other-month-day");
                            break;
                        default:
                            break;
                        }
                        m_dayItem[row - 1][col - offsetCols]->setValue(m_day[row - 1][col - offsetCols]);
                    }
                }
            } // end: if (priv->show_week_num && (0 == col))
        } // end: for row
    } // end: for col

    if (NULL != m_swipeBox[VIEWTYPE_MONTH]) {
        gtk_widget_hide(m_swipeBox[VIEWTYPE_MONTH]);
    }

    if (NULL != m_swipeBox[VIEWTYPE_YEAR]) {
        gtk_widget_hide(m_swipeBox[VIEWTYPE_YEAR]);
    }

    if (NULL != m_swipeBox[VIEWTYPE_DAY]) {
        gtk_widget_show_all(m_swipeBox[VIEWTYPE_DAY]);
    }

    apply_css(GTK_WIDGET(m_actor), m_provider);
}