Ejemplo n.º 1
0
bool KOEventView::processKeyEvent( QKeyEvent *ke )
{
  // If Return is pressed bring up an editor for the current selected time span.
  if ( ke->key() == Qt::Key_Return ) {
    if ( ke->type() == QEvent::KeyPress ) {
      mReturnPressed = true;
    } else if ( ke->type() == QEvent::KeyRelease ) {
      if ( mReturnPressed ) {
        emit newEventSignal();
        mReturnPressed = false;
        return true;
      } else {
        mReturnPressed = false;
      }
    }
  }

  // Ignore all input that does not produce any output
  if ( ke->text().isEmpty() || ( ke->modifiers() & Qt::ControlModifier ) ) {
    return false;
  }

  if ( ke->type() == QEvent::KeyPress ) {
    switch ( ke->key() ) {
    case Qt::Key_Escape:
    case Qt::Key_Return:
    case Qt::Key_Enter:
    case Qt::Key_Tab:
    case Qt::Key_Backtab:
    case Qt::Key_Left:
    case Qt::Key_Right:
    case Qt::Key_Up:
    case Qt::Key_Down:
    case Qt::Key_Backspace:
    case Qt::Key_Delete:
    case Qt::Key_PageUp:
    case Qt::Key_PageDown:
    case Qt::Key_Home:
    case Qt::Key_End:
    case Qt::Key_Control:
    case Qt::Key_Meta:
    case Qt::Key_Alt:
      break;
    default:
      mTypeAheadEvents.append(
        new QKeyEvent( ke->type(),
                       ke->key(),
                       ke->modifiers(),
                       ke->text(),
                       ke->isAutoRepeat(),
                       static_cast<ushort>( ke->count() ) ) );
      if ( !mTypeAhead ) {
        mTypeAhead = true;
        emit newEventSignal();
      }
      return true;
    }
  }
  return false;
}
Ejemplo n.º 2
0
void KOViewManager::connectView(KOrg::BaseView *view)
{
    if(!view) return;

    // selecting an incidence
    connect(view, SIGNAL(incidenceSelected(Incidence *)),
            mMainView, SLOT(processMainViewSelection(Incidence *)));

    // showing/editing/deleting an incidence. The calendar view takes care of the action.
    connect(view, SIGNAL(showIncidenceSignal(Incidence *)),
            mMainView, SLOT(showIncidence(Incidence *)));
    connect(view, SIGNAL(editIncidenceSignal(Incidence *)),
            mMainView, SLOT(editIncidence(Incidence *)));
    connect(view, SIGNAL(deleteIncidenceSignal(Incidence *)),
            mMainView, SLOT(deleteIncidence(Incidence *)));
    connect(view, SIGNAL(copyIncidenceSignal(Incidence *)),
            mMainView, SLOT(copyIncidence(Incidence *)));
    connect(view, SIGNAL(cutIncidenceSignal(Incidence *)),
            mMainView, SLOT(cutIncidence(Incidence *)));
    connect(view, SIGNAL(pasteIncidenceSignal()),
            mMainView, SLOT(pasteIncidence()));
    connect(view, SIGNAL(toggleAlarmSignal(Incidence *)),
            mMainView, SLOT(toggleAlarm(Incidence *)));
    connect(view, SIGNAL(dissociateOccurrenceSignal(Incidence *, const QDate &)),
            mMainView, SLOT(dissociateOccurrence(Incidence *, const QDate &)));
    connect(view, SIGNAL(dissociateFutureOccurrenceSignal(Incidence *, const QDate &)),
            mMainView, SLOT(dissociateFutureOccurrence(Incidence *, const QDate &)));

    // signals to create new incidences
    connect(view, SIGNAL(newEventSignal()),
            mMainView, SLOT(newEvent()));
    connect(view, SIGNAL(newEventSignal(const QDateTime &)),
            mMainView, SLOT(newEvent(const QDateTime &)));
    connect(view, SIGNAL(newEventSignal(const QDateTime &, const QDateTime &)),
            mMainView, SLOT(newEvent(const QDateTime &, const QDateTime &)));
    connect(view, SIGNAL(newEventSignal(const QDate &)),
            mMainView, SLOT(newEvent(const QDate &)));
    connect(view, SIGNAL(newTodoSignal(const QDate &)),
            mMainView, SLOT(newTodo(const QDate &)));
    connect(view, SIGNAL(newSubTodoSignal(Todo *)),
            mMainView, SLOT(newSubTodo(Todo *)));
    connect(view, SIGNAL(newJournalSignal(const QDate &)),
            mMainView, SLOT(newJournal(const QDate &)));

    // reload settings
    connect(mMainView, SIGNAL(configChanged()), view, SLOT(updateConfig()));

    // Notifications about added, changed and deleted incidences
    connect(mMainView, SIGNAL(dayPassed(const QDate &)),
            view, SLOT(dayPassed(const QDate &)));
    connect(view, SIGNAL(startMultiModify(const QString &)),
            mMainView, SLOT(startMultiModify(const QString &)));
    connect(view, SIGNAL(endMultiModify()),
            mMainView, SLOT(endMultiModify()));

    connect(mMainView, SIGNAL(newIncidenceChanger(IncidenceChangerBase *)),
            view, SLOT(setIncidenceChanger(IncidenceChangerBase *)));
    view->setIncidenceChanger(mMainView->incidenceChanger());
}