Exemplo n.º 1
0
bool KonsoleKalendar::showInstance()
{
    bool status = true;
    QFile f;
    QString title;
    Event::Ptr event;
    const KDateTime::Spec timeSpec = m_variables->getCalendar()->timeSpec();
    Akonadi::CalendarBase::Ptr calendar = m_variables->getCalendar();

    if (m_variables->isDryRun()) {
        cout << i18n("View Events <Dry Run>:").toLocal8Bit().data()
             << endl;
        printSpecs();
    } else {
        qCDebug(KONSOLEKALENDAR_LOG) << "konsolekalendar.cpp::showInstance() |"
                                     << "open export file";

        if (m_variables->isExportFile()) {
            f.setFileName(m_variables->getExportFile());
            if (!f.open(QIODevice::WriteOnly)) {
                status = false;
                qCDebug(KONSOLEKALENDAR_LOG) << "konsolekalendar.cpp::showInstance() |"
                                             << "unable to open export file"
                                             << m_variables->getExportFile();
            }
        } else {
            f.open(stdout, QIODevice::WriteOnly);
        }

        if (status) {
            qCDebug(KONSOLEKALENDAR_LOG) << "konsolekalendar.cpp::showInstance() |"
                                         << "opened successful";

            if (m_variables->isVerbose()) {
                cout << i18n("View Event <Verbose>:").toLocal8Bit().data()
                     << endl;
                printSpecs();
            }

            QTextStream ts(&f);

            if (m_variables->getExportType() != ExportTypeHTML &&
                    m_variables->getExportType() != ExportTypeMonthHTML) {

                if (m_variables->getAll()) {
                    qCDebug(KONSOLEKALENDAR_LOG) << "konsolekalendar.cpp::showInstance() |"
                                                 << "view all events sorted list";

                    Event::List sortedList = calendar->events(EventSortStartDate);
                    qCDebug(KONSOLEKALENDAR_LOG) << "Found" << sortedList.count() << "events";
                    if (!sortedList.isEmpty()) {
                        // The code that was here before the akonadi port was really slow with 200 events
                        // this is much faster:
                        foreach (const KCalCore::Event::Ptr &event, sortedList) {
                            status &= printEvent(&ts, event, event->dtStart().date());
                        }
                    }
                } else if (m_variables->isUID()) {
Exemplo n.º 2
0
Event::Ptr DndFactory::createDropEvent( const QMimeData *mimeData )
{
  //kDebug();
  Event::Ptr event;
  MemoryCalendar::Ptr calendar( createDropCalendar( mimeData ) );

  if ( calendar ) {
    Event::List events = calendar->events();
    if ( !events.isEmpty() ) {
      event = Event::Ptr( new Event( *events.first() ) );
    }
  }
  return event;
}
Exemplo n.º 3
0
Event *DndFactory::createDropEvent( const QMimeData *md )
{
  kDebug();
  Event *ev = 0;
  Calendar *cal = createDropCalendar( md );

  if ( cal ) {
    Event::List events = cal->events();
    if ( !events.isEmpty() ) {
      ev = new Event( *events.first() );
    }
    delete cal;
  }
  return ev;
}