Пример #1
0
KOrganizerPlugin::KOrganizerPlugin( Kontact::Core *core, const char *, const QStringList& )
  : Kontact::Plugin( core, core, "korganizer" ),
    mIface( 0 )
{

  setInstance( KOrganizerPluginFactory::instance() );
  instance()->iconLoader()->addAppDir("kdepim");

  insertNewAction( new KAction( i18n( "New Event..." ), "newappointment",
                   CTRL+SHIFT+Key_E, this, SLOT( slotNewEvent() ), actionCollection(),
                   "new_event" ) );

  insertSyncAction( new KAction( i18n( "Synchronize Calendar" ), "reload",
                   0, this, SLOT( slotSyncEvents() ), actionCollection(),
                   "korganizer_sync" ) );

  mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
      new Kontact::UniqueAppHandlerFactory<KOrganizerUniqueAppHandler>(), this );
}
Пример #2
0
EventView::EventView( QToolBar* toolBar, QWidget* parent )
    : QWidget( parent )
    , m_model( 0 )
    , m_actionNewEvent( this )
    , m_actionEditEvent( this )
    , m_actionDeleteEvent( this )
    , m_actionCreateTimeSheet( this )
    , m_comboBox( new QComboBox( this ) )
    , m_labelTotal( new QLabel( this ) )
    , m_listView( new QListView( this ) )
{
    QVBoxLayout* layout = new QVBoxLayout( this );
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->addWidget( m_listView );

    m_listView->setAlternatingRowColors( true );
    m_listView->setContextMenuPolicy( Qt::CustomContextMenu );
    connect( m_listView,
             SIGNAL( customContextMenuRequested( const QPoint& ) ),
             SLOT( slotContextMenuRequested( const QPoint& ) ) );
    connect( m_listView,
             SIGNAL( doubleClicked( const QModelIndex& ) ),
             SLOT( slotEventDoubleClicked( const QModelIndex& ) ) );
    connect( &m_actionNewEvent, SIGNAL( triggered() ),
             SLOT( slotNewEvent() ) );
    connect( &m_actionEditEvent, SIGNAL( triggered() ),
             SLOT( slotEditEvent() ) );
    connect( &m_actionDeleteEvent, SIGNAL( triggered() ),
             SLOT( slotDeleteEvent() ) );
    connect( &m_actionCreateTimeSheet, SIGNAL( triggered() ),
             SLOT( slotCreateTimeSheet() ) );
//     connect( &m_commitTimer, SIGNAL( timeout() ),
//              SLOT( slotCommitTimeout() ) );
//     m_commitTimer.setSingleShot( true );


    m_actionNewEvent.setText( tr( "New Event..." ) );
    m_actionNewEvent.setToolTip( tr( "Create a new Event" ) );
    m_actionNewEvent.setIcon( Data::newTaskIcon() );
    m_actionNewEvent.setShortcut( QKeySequence::New );
    toolBar->addAction( &m_actionNewEvent );

    m_actionEditEvent.setText( tr( "Edit Event...") );
    m_actionEditEvent.setShortcut( Qt::CTRL + Qt::Key_E );
    m_actionEditEvent.setIcon( Data::editEventIcon() );
    toolBar->addAction( &m_actionEditEvent );

    m_actionDeleteEvent.setText( tr( "Delete Event..." ) );
    QList<QKeySequence> deleteShortcuts;
    deleteShortcuts << QKeySequence::Delete;
#ifdef Q_WS_MAC
    deleteShortcuts << Qt::Key_Backspace;
#endif
    m_actionDeleteEvent.setShortcuts(deleteShortcuts);
    m_actionDeleteEvent.setIcon( Data::deleteTaskIcon() );
    toolBar->addAction( &m_actionDeleteEvent );

    m_actionCreateTimeSheet.setText( tr( "Time Sheet..." ) );
    m_actionCreateTimeSheet.setToolTip( tr( "Create a Time Sheet for this time period " ) );
    m_actionCreateTimeSheet.setIcon( Data::createReportIcon() );
    toolBar->addAction( &m_actionCreateTimeSheet );

    // disable all actions, action state will be set when the current
    // item changes:
    m_actionNewEvent.setEnabled( true ); // always on
    m_actionEditEvent.setEnabled( false );
    m_actionDeleteEvent.setEnabled( false );

    toolBar->addWidget( new QLabel( tr( "See events from:" ) , this ) );

    toolBar->addWidget( m_comboBox );
    connect( m_comboBox, SIGNAL( currentIndexChanged( int ) ),
             SLOT( timeFrameChanged( int ) ) );

    QWidget *spacer = new QWidget( this );
    QSizePolicy spacerSizePolicy = spacer->sizePolicy();
    spacerSizePolicy.setHorizontalPolicy( QSizePolicy::Expanding );
    spacer->setSizePolicy( spacerSizePolicy );
    toolBar->addWidget( spacer );

    toolBar->addWidget( m_labelTotal );

    QTimer::singleShot( 0, this, SLOT( delayedInitialization() ) );

    // I hate doing this but the stupid default view sizeHints suck badly.
    setMinimumHeight( 200 );
}
Пример #3
0
EventView::EventView( QWidget* parent )
    : QDialog( parent )
    , m_toolBar( new QToolBar( this ) )
    , m_actionUndo( this )
    , m_actionRedo( this )
    , m_actionNewEvent( this )
    , m_actionEditEvent( this )
    , m_actionDeleteEvent( this )
    , m_actionCreateTimeSheet( this )
    , m_actionFindAndReplace( this )
    , m_comboBox( new QComboBox( this ) )
    , m_labelTotal( new QLabel( this ) )
    , m_listView( new QListView( this ) )
{
    setWindowTitle( tr( "Event Editor" ) );
    auto layout = new QVBoxLayout( this );
    layout->setMargin( 0 );
    layout->setSpacing( 0 );
    layout->addWidget( m_toolBar );
    layout->addWidget( m_listView );

    m_listView->setAlternatingRowColors( true );
    m_listView->setContextMenuPolicy( Qt::CustomContextMenu );
    connect( m_listView,
             SIGNAL(customContextMenuRequested(QPoint)),
             SLOT(slotContextMenuRequested(QPoint)) );
    connect( m_listView,
             SIGNAL(doubleClicked(QModelIndex)),
             SLOT(slotEventDoubleClicked(QModelIndex)) );
    connect( &m_actionNewEvent, SIGNAL(triggered()),
             SLOT(slotNewEvent()) );
    connect( &m_actionEditEvent, SIGNAL(triggered()),
             SLOT(slotEditEvent()) );
    connect( &m_actionDeleteEvent, SIGNAL(triggered()),
             SLOT(slotDeleteEvent()) );
//     connect( &m_commitTimer, SIGNAL(timeout()),
//              SLOT(slotCommitTimeout()) );
//     m_commitTimer.setSingleShot( true );

    m_actionUndo.setText(tr("Undo"));
    m_actionUndo.setToolTip(tr("Undo the latest change"));
    m_actionUndo.setShortcut(QKeySequence::Undo);
    m_actionUndo.setEnabled(false);

    m_actionRedo.setText(tr("Redo"));
    m_actionRedo.setToolTip(tr("Redo the last undone change."));
    m_actionRedo.setShortcut(QKeySequence::Redo);
    m_actionRedo.setEnabled(false);

    m_undoStack = new QUndoStack(this);
    connect(m_undoStack, SIGNAL(canUndoChanged(bool)), &m_actionUndo, SLOT(setEnabled(bool)));
    connect(m_undoStack, SIGNAL(undoTextChanged(QString)), this, SLOT(slotUndoTextChanged(QString)));
    connect(&m_actionUndo, SIGNAL(triggered()), m_undoStack, SLOT(undo()));

    connect(m_undoStack, SIGNAL(canRedoChanged(bool)), &m_actionRedo, SLOT(setEnabled(bool)));
    connect(m_undoStack, SIGNAL(redoTextChanged(QString)), this, SLOT(slotRedoTextChanged(QString)));
    connect(&m_actionRedo, SIGNAL(triggered()), m_undoStack, SLOT(redo()));

    m_actionNewEvent.setText( tr( "New Event..." ) );
    m_actionNewEvent.setToolTip( tr( "Create a new Event" ) );
    m_actionNewEvent.setIcon( Data::newTaskIcon() );
    m_actionNewEvent.setShortcut( QKeySequence::New );
    m_toolBar->addAction( &m_actionNewEvent );

    m_actionEditEvent.setText( tr( "Edit Event...") );
    m_actionEditEvent.setShortcut( Qt::CTRL + Qt::Key_E );
    m_actionEditEvent.setIcon( Data::editEventIcon() );
    m_toolBar->addAction( &m_actionEditEvent );

    m_actionFindAndReplace.setText( tr( "Search/Replace Events..." ) );
    m_actionFindAndReplace.setToolTip( tr( "Change the task events belong to" ) );
    m_actionFindAndReplace.setIcon( Data::searchIcon() );
    m_toolBar->addAction( &m_actionFindAndReplace );

    connect( &m_actionFindAndReplace, SIGNAL(triggered()), SLOT(slotFindAndReplace()) );

    m_actionDeleteEvent.setText( tr( "Delete Event..." ) );
    QList<QKeySequence> deleteShortcuts;
    deleteShortcuts << QKeySequence::Delete;
#ifdef Q_OS_OSX
    deleteShortcuts << Qt::Key_Backspace;
#endif
    m_actionDeleteEvent.setShortcuts(deleteShortcuts);
    m_actionDeleteEvent.setIcon( Data::deleteTaskIcon() );
    m_toolBar->addAction( &m_actionDeleteEvent );

    // disable all actions, action state will be set when the current
    // item changes:
    m_actionNewEvent.setEnabled( true ); // always on
    m_actionEditEvent.setEnabled( false );
    m_actionDeleteEvent.setEnabled( false );

    m_toolBar->addWidget( m_comboBox );
    connect( m_comboBox, SIGNAL(currentIndexChanged(int)),
             SLOT(timeFrameChanged(int)) );

    auto spacer = new QWidget( this );
    QSizePolicy spacerSizePolicy = spacer->sizePolicy();
    spacerSizePolicy.setHorizontalPolicy( QSizePolicy::Expanding );
    spacer->setSizePolicy( spacerSizePolicy );
    m_toolBar->addWidget( spacer );

    m_toolBar->addWidget( m_labelTotal );

    QTimer::singleShot( 0, this, SLOT(delayedInitialization()) );

    // I hate doing this but the stupid default view sizeHints suck badly.
    setMinimumHeight( 200 );
}