Commit 24c14479 authored by Allen Winter's avatar Allen Winter
Browse files

Move korgac up 1-level and out from under KOrganizer's source tree.

parent bdbb7b3f
......@@ -310,6 +310,7 @@ else()
macro_optional_add_subdirectory(pimactivity)
macro_optional_add_subdirectory(korganizer)
macro_optional_add_subdirectory(korgac)
add_subdirectory(kaddressbookgrantlee)
if(KDEPIM_BUILD_DESKTOP)
macro_optional_add_subdirectory(agents)
......
remove_definitions(-DKDE_DEFAULT_DEBUG_AREA=5850) #remove korganizer debug area
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5890)
project(korgac)
option(KORGAC_AKONADI_AGENT FALSE "Build Korgac as Akonadi agent instead of a stand-alone process")
if(KORGAC_AKONADI_AGENT)
add_definitions(-DKORGAC_AKONADI_AGENT)
endif()
add_subdirectory(pixmaps)
add_subdirectory(tests)
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5890)
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
# enable exception handling
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
include_directories(
${CMAKE_SOURCE_DIR}/korganizer
${CMAKE_BINARY_DIR}/korganizer
${CMAKE_SOURCE_DIR}/calendarsupport
${CMAKE_BINARY_DIR}/calendarsupport
)
add_subdirectory(pixmaps)
add_subdirectory(tests)
########### next target ###############
set(korgac_SRCS
......@@ -92,10 +98,6 @@ if(RUNTIME_PLUGINS_STATIC)
target_link_libraries(korgac akonadi_serializer_kcalcore)
endif()
if(NOT WINCE)
target_link_libraries(korgac korganizer_core)
endif()
# TODO: move this to FindQt4.cmake
find_library(QT_QMAEMO5_LIBRARY QtMaemo5 HINTS ${QT_LIBRARY_DIR})
if(QT_QMAEMO5_LIBRARY)
......
......@@ -25,12 +25,12 @@
*/
#include "alarmdialog.h"
#include "kocore.h"
#include "korganizer_interface.h"
#include "mailclient.h"
#include <calendarsupport/next/incidenceviewer.h>
#include <calendarsupport/kcalprefs.h>
#include <calendarsupport/identitymanager.h>
#include <calendarsupport/utils.h>
#include <incidenceeditor-ng/incidencedialog.h>
......@@ -73,12 +73,36 @@ using namespace KCalUtils;
static int defSuspendVal = 5;
static int defSuspendUnit = 0; // 0=>minutes, 1=>hours, 2=>days, 3=>weeks
class ReminderListItem : public QTreeWidgetItem
class ReminderTree : public QTreeWidget
{
public:
ReminderListItem( const Akonadi::Item &incidence, QTreeWidget *parent )
ReminderTree( QWidget *parent ) : QTreeWidget( parent )
{
}
/*reimp*/
void mouseReleaseEvent( QMouseEvent *event );
};
void ReminderTree::mouseReleaseEvent( QMouseEvent *event )
{
QTreeWidgetItem *item = itemAt( event->pos() );
if ( item ) {
if ( event->button() == Qt::LeftButton ) {
emit itemActivated( item, 0 );
} else if ( event->button() == Qt::RightButton ) {
emit customContextMenuRequested( event->pos() );
}
}
}
class ReminderTreeItem : public QTreeWidgetItem
{
public:
ReminderTreeItem( const Akonadi::Item &incidence, QTreeWidget *parent )
: QTreeWidgetItem( parent ), mIncidence( incidence ), mNotified( false )
{}
{
}
bool operator<( const QTreeWidgetItem & other ) const;
QString mDisplayText;
......@@ -96,17 +120,17 @@ struct ConfItem {
QDateTime remindAt;
};
bool ReminderListItem::operator<( const QTreeWidgetItem &other ) const
bool ReminderTreeItem::operator<( const QTreeWidgetItem &other ) const
{
switch( treeWidget()->sortColumn() ) {
case 1: // happening datetime
{
const ReminderListItem *item = static_cast<const ReminderListItem *>( &other );
const ReminderTreeItem *item = static_cast<const ReminderTreeItem *>( &other );
return item->mHappening.secsTo( mHappening );
}
case 2: // trigger datetime
{
const ReminderListItem *item = static_cast<const ReminderListItem *>( &other );
const ReminderTreeItem *item = static_cast<const ReminderTreeItem *>( &other );
return item->mTrigger.secsTo( mTrigger );
}
default:
......@@ -114,7 +138,7 @@ bool ReminderListItem::operator<( const QTreeWidgetItem &other ) const
}
}
typedef QList<ReminderListItem *> ReminderList;
typedef QList<ReminderTreeItem *> ReminderList;
AlarmDialog::AlarmDialog( const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent )
: KDialog( parent, Qt::WindowStaysOnTopHint ),
......@@ -170,7 +194,7 @@ AlarmDialog::AlarmDialog( const Akonadi::ETMCalendar::Ptr &calendar, QWidget *pa
topBox );
mTopLayout->addWidget( label );
mIncidenceTree = new QTreeWidget( topBox );
mIncidenceTree = new ReminderTree( topBox );
mIncidenceTree->setColumnCount( 3 );
mIncidenceTree->setSortingEnabled( true );
const QStringList headerLabels =
......@@ -195,18 +219,11 @@ AlarmDialog::AlarmDialog( const Akonadi::ETMCalendar::Ptr &calendar, QWidget *pa
mTopLayout->addWidget( mIncidenceTree );
connect( mIncidenceTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
SLOT(update()) );
connect( mIncidenceTree, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
SLOT(update()) );
connect( mIncidenceTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
SLOT(toggleDetails(QTreeWidgetItem*,int)) );
connect( mIncidenceTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
SLOT(update()) );
connect( mIncidenceTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
SLOT(edit()) );
connect( mIncidenceTree, SIGNAL(itemSelectionChanged()),
SLOT(update()) );
connect( mIncidenceTree, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(popupItemMenu(const QPoint&)) );
mDetailView = new CalendarSupport::IncidenceViewer( mCalendar.data(), topBox );
QString s;
......@@ -260,19 +277,22 @@ AlarmDialog::AlarmDialog( const Akonadi::ETMCalendar::Ptr &calendar, QWidget *pa
connect( this, SIGNAL(user1Clicked()), this, SLOT(slotUser1()) );
connect( this, SIGNAL(user2Clicked()), this, SLOT(slotUser2()) );
connect( this, SIGNAL(user3Clicked()), this, SLOT(slotUser3()) );
mIdentityManager = new CalendarSupport::IdentityManager;
}
AlarmDialog::~AlarmDialog()
{
mIncidenceTree->clear();
delete mIdentityManager;
}
ReminderListItem *AlarmDialog::searchByItem( const Akonadi::Item &incidence )
ReminderTreeItem *AlarmDialog::searchByItem( const Akonadi::Item &incidence )
{
ReminderListItem *found = 0;
ReminderTreeItem *found = 0;
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
ReminderTreeItem *item = static_cast<ReminderTreeItem *>( *it );
if ( item->mIncidence == incidence ) {
found = item;
break;
......@@ -301,9 +321,9 @@ void AlarmDialog::addIncidence( const Akonadi::Item &incidenceitem,
const QString &displayText )
{
Incidence::Ptr incidence = CalendarSupport::incidence( incidenceitem );
ReminderListItem *item = searchByItem( incidenceitem );
ReminderTreeItem *item = searchByItem( incidenceitem );
if ( !item ) {
item = new ReminderListItem( incidenceitem, mIncidenceTree );
item = new ReminderTreeItem( incidenceitem, mIncidenceTree );
}
item->mNotified = false;
item->mHappening = KDateTime();
......@@ -345,7 +365,7 @@ void AlarmDialog::addIncidence( const Akonadi::Item &incidenceitem,
item->setData( 0, QTreeWidgetItem::UserType, false );
mIncidenceTree->setCurrentItem( item );
showDetails();
showDetails( item );
slotSave();
}
......@@ -388,7 +408,7 @@ void AlarmDialog::dismissAll()
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
if ( !(*it)->isDisabled() ) { //do not disable suspended reminders
selections.append( static_cast<ReminderListItem *>( *it ) );
selections.append( static_cast<ReminderTreeItem *>( *it ) );
}
++it;
}
......@@ -460,13 +480,13 @@ void AlarmDialog::suspend()
break;
}
ReminderListItem *selitem = 0;
ReminderTreeItem *selitem = 0;
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
if ( (*it)->isSelected() && !(*it)->isDisabled() ) { //suspend selected, non-suspended reminders
(*it)->setSelected( false );
(*it)->setDisabled( true );
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
ReminderTreeItem *item = static_cast<ReminderTreeItem *>( *it );
item->mRemindAt = QDateTime::currentDateTime().addSecs( unit * mSuspendSpin->value() );
item->mHappening = KDateTime( item->mRemindAt, KDateTime::Spec::LocalZone() );
item->mNotified = false;
......@@ -503,7 +523,7 @@ void AlarmDialog::setTimer()
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
ReminderTreeItem *item = static_cast<ReminderTreeItem *>( *it );
if ( item->mRemindAt > QDateTime::currentDateTime() ) {
const int secs = QDateTime::currentDateTime().secsTo( item->mRemindAt );
nextReminderAt = nextReminderAt <= 0 ? secs : qMin( nextReminderAt, secs );
......@@ -528,7 +548,7 @@ void AlarmDialog::show()
// select the first item that hasn't already been notified
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
ReminderTreeItem *item = static_cast<ReminderTreeItem *>( *it );
if ( !item->mNotified ) {
(*it)->setSelected( true );
break;
......@@ -580,7 +600,7 @@ void AlarmDialog::eventNotification()
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
ReminderTreeItem *item = static_cast<ReminderTreeItem *>( *it );
++it;
if ( item->isDisabled() || item->mNotified ) {
//skip suspended reminders or reminders that have been notified
......@@ -616,7 +636,7 @@ void AlarmDialog::eventNotification()
player->play();
} else if ( alarm->type() == Alarm::Email ) {
QString from = CalendarSupport::KCalPrefs::instance()->email();
Identity id = KOCore::self()->identityManager()->identityForAddress( from );
Identity id = mIdentityManager->identityForAddress( from );
QString to;
if ( alarm->mailAddresses().isEmpty() ) {
to = from;
......@@ -668,8 +688,12 @@ void AlarmDialog::wakeUp()
{
bool activeReminders = false;
QTreeWidgetItemIterator it( mIncidenceTree );
QTreeWidgetItem *firstItem = 0;
while ( *it ) {
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
if ( !firstItem ) {
firstItem = *it;
}
ReminderTreeItem *item = static_cast<ReminderTreeItem *>( *it );
Incidence::Ptr incidence = CalendarSupport::incidence( item->mIncidence );
if ( item->mRemindAt <= QDateTime::currentDateTime() ) {
......@@ -689,7 +713,7 @@ void AlarmDialog::wakeUp()
show();
}
setTimer();
showDetails();
showDetails( firstItem );
emit reminderCount( activeCount() );
}
......@@ -701,7 +725,7 @@ void AlarmDialog::slotSave()
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
ReminderTreeItem *item = static_cast<ReminderTreeItem *>( *it );
KConfigGroup incidenceConfig( config,
QString::fromLatin1( "Incidence-%1" ).arg( numReminders + 1 ) );
......@@ -724,7 +748,7 @@ ReminderList AlarmDialog::selectedItems() const
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
if ( (*it)->isSelected() ) {
list.append( static_cast<ReminderListItem *>( *it ) );
list.append( static_cast<ReminderTreeItem *>( *it ) );
}
++it;
}
......@@ -760,9 +784,12 @@ void AlarmDialog::updateButtons()
enableButton( Ok, count > 0 ); // enable Suspend, if >1 selected
}
void AlarmDialog::toggleDetails( QTreeWidgetItem *item, int column )
void AlarmDialog::toggleDetails( QTreeWidgetItem *item )
{
Q_UNUSED( column );
if ( !item ) {
return;
}
if ( !mDetailView->isHidden() ) {
if ( mLastItem == item ) {
resize( size().width(), size().height() - mDetailView->height() - 50 );
......@@ -770,31 +797,59 @@ void AlarmDialog::toggleDetails( QTreeWidgetItem *item, int column )
}
} else {
resize( size().width(), size().height() + mDetailView->height() + 50 );
showDetails( item );
mDetailView->show();
}
mLastItem = item;
}
void AlarmDialog::showDetails()
void AlarmDialog::showDetails( QTreeWidgetItem *item )
{
QList<QTreeWidgetItem*> items = mIncidenceTree->selectedItems();
ReminderListItem *item = items.isEmpty() ? 0 : dynamic_cast<ReminderListItem *>( items.first() );
if ( !item ) {
return;
}
ReminderTreeItem *reminderItem = dynamic_cast<ReminderTreeItem *>( item );
if ( !reminderItem ) {
mDetailView->setIncidence( Akonadi::Item() );
} else {
if ( !item->mDisplayText.isEmpty() ) {
QString txt = QLatin1String("<qt><p><b>") + item->mDisplayText + QLatin1String("</b></p></qt>");
if ( !reminderItem->mDisplayText.isEmpty() ) {
QString txt = QLatin1String("<qt><p><b>") + reminderItem->mDisplayText + QLatin1String("</b></p></qt>");
mDetailView->setHeaderText( txt );
}
mDetailView->setIncidence( item->mIncidence, item->mRemindAt.date() );
Incidence::Ptr incidence = CalendarSupport::incidence( reminderItem->mIncidence );
kDebug() << "SHOW FOR" << incidence->summary();
mDetailView->setIncidence( reminderItem->mIncidence, reminderItem->mRemindAt.date() );
}
}
void AlarmDialog::update()
{
updateButtons();
showDetails();
if ( !mIncidenceTree->selectedItems().isEmpty() ) {
QTreeWidgetItem *item = mIncidenceTree->selectedItems().first();
toggleDetails( item );
}
}
void AlarmDialog::popupItemMenu( const QPoint &point )
{
kDebug() << "HELLO";
QTreeWidgetItem *item = mIncidenceTree->itemAt( point );
if ( !item ) {
kDebug() << "SORRY NOT ITEM HERE";
return;
}
ReminderTreeItem *reminderItem = dynamic_cast<ReminderTreeItem *>( item );
if ( reminderItem ) {
Incidence::Ptr incidence = CalendarSupport::incidence( reminderItem->mIncidence );
if ( incidence ) {
kDebug() << "YES: INCIDENCE=" << incidence->summary();
}
}
}
void AlarmDialog::accept()
......@@ -841,7 +896,7 @@ void AlarmDialog::slotCalendarChanged()
Akonadi::Item::List items = mCalendar->itemList( incidences );
for ( Akonadi::Item::List::ConstIterator it = items.constBegin();
it != items.constEnd(); ++it ) {
ReminderListItem *item = searchByItem( *it );
ReminderTreeItem *item = searchByItem( *it );
if ( item ) {
Incidence::Ptr incidence = CalendarSupport::incidence( *it );
......
This diff is collapsed.
......@@ -33,15 +33,19 @@
#include <QPoint>
#include <QTimer>
namespace CalendarSupport {
class IncidenceViewer;
}
namespace Akonadi {
class Item;
}
class ReminderListItem;
namespace KPIMIdentities {
class IdentityManager;
}
namespace CalendarSupport {
class IncidenceViewer;
}
class ReminderTreeItem;
class KComboBox;
......@@ -90,7 +94,7 @@ class AlarmDialog : public KDialog
private Q_SLOTS:
void update();
void toggleDetails( QTreeWidgetItem *item, int column );
void popupItemMenu( const QPoint &point );
protected:
void keyPressEvent( QKeyEvent *e );
......@@ -111,18 +115,20 @@ class AlarmDialog : public KDialog
bool openIncidenceEditorNG( const Akonadi::Item &incidence );
bool startKOrganizer();
ReminderListItem *searchByItem( const Akonadi::Item &incidence );
ReminderTreeItem *searchByItem( const Akonadi::Item &incidence );
void setTimer();
void dismiss( QList<ReminderListItem *> selections );
void dismiss( QList<ReminderTreeItem *> selections );
int activeCount();
QList<ReminderListItem *> selectedItems() const;
QList<ReminderTreeItem *> selectedItems() const;
void updateButtons();
void showDetails();
void toggleDetails( QTreeWidgetItem *item );
void showDetails( QTreeWidgetItem *item );
Akonadi::ETMCalendar::Ptr mCalendar;
QVBoxLayout *mTopLayout;
QTreeWidget *mIncidenceTree;
CalendarSupport::IncidenceViewer *mDetailView;
KPIMIdentities::IdentityManager *mIdentityManager;
QPoint mPos;
QSpinBox *mSuspendSpin;
......
/*
This file is part of the KDE reminder agent.
Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KORGAC_ALARMDIALOG_H
#define KORGAC_ALARMDIALOG_H
#include <Akonadi/Calendar/ETMCalendar>
#include <Akonadi/Item>
#include <KDialog>
#include <KCalCore/Incidence>
#include <KDateTime>
#include <QPoint>
#include <QTimer>
namespace CalendarSupport {
class IncidenceViewer;
}
namespace Akonadi {
class Item;
}
class ReminderTreeItem;
class KComboBox;
class QDateTime;
class QTreeWidget;
class QTreeWidgetItem;
class QSpinBox;
class QVBoxLayout;
class AlarmDialog : public KDialog
{
Q_OBJECT
public:
explicit AlarmDialog( const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent = 0 );
~AlarmDialog();
void addIncidence( const Akonadi::Item &incidence, const QDateTime &reminderAt,
const QString &displayText );
void setRemindAt( const QDateTime &dt );
void eventNotification();
public slots:
void slotOk(); // suspend
void slotUser1(); // edit
void slotUser2(); // dismiss all
void slotUser3(); // dismiss selected
void slotSave();
void wakeUp();
void show();
void edit();
void suspend();
void suspendAll();
void dismissAll();
void dismissCurrent();
/*reimp*/
void accept();
/**
If an incidence changed, for example in korg, we must update
the date and summary shown in the list view.
*/
void slotCalendarChanged();
signals:
void reminderCount( int count );
private Q_SLOTS:
void update();
void popupItemMenu( const QPoint &point );
protected:
void keyPressEvent( QKeyEvent *e );
void closeEvent( QCloseEvent * );
private:
static KDateTime triggerDateForIncidence( const KCalCore::Incidence::Ptr &inc,
const QDateTime &reminderAt,
QString &displayStr );
// Removes each Incidence-X group that has one of the specified uids
void removeFromConfig( const QList<Akonadi::Item::Id> & );
// Opens through dbus, @deprecated
bool openIncidenceEditorThroughKOrganizer( const KCalCore::Incidence::Ptr &incidence );
// opens directly
bool openIncidenceEditorNG( const Akonadi::Item &incidence );
bool startKOrganizer();
ReminderTreeItem *searchByItem( const Akonadi::Item &incidence );
void setTimer();
void dismiss( QList<ReminderTreeItem *> selections );
int activeCount();
QList<ReminderTreeItem *> selectedItems() const;
void updateButtons();
void toggleDetails( QTreeWidgetItem *item );
void showDetails( QTreeWidgetItem *item );
Akonadi::ETMCalendar::Ptr mCalendar;
QVBoxLayout *mTopLayout;
QTreeWidget *mIncidenceTree;
CalendarSupport::IncidenceViewer *mDetailView;
QPoint mPos;
QSpinBox *mSuspendSpin;
KComboBox *mSuspendUnit;
QTimer mSuspendTimer;
QTreeWidgetItem *mLastItem;
};
#endif
......@@ -129,5 +129,3 @@ X-DBUS-StartupType=Unique
#do not uncomment the following line, else autostart fails
#NoDisplay=true
OnlyShowIn=KDE;