Commit 7fefb4ff authored by Sergio Luis Martins's avatar Sergio Luis Martins
Browse files

kdepim branch for kcalcore

svn path=/branches/work/kdepim_kcalcore/runtime/; revision=1149030
parent 6cc9b104

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
add_subdirectory(kcal)
add_subdirectory(akonadi_next)
project(akonadi_next)
if(CMAKE_SOURCE_DIR STREQUAL "${akonadi_next_SOURCE_DIR}")
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
find_package(Akonadi REQUIRED)
find_package(KdepimLibs REQUIRED)
endif(CMAKE_SOURCE_DIR STREQUAL "${akonadi_next_SOURCE_DIR}")
include_directories(
${AKONADI_INCLUDE_DIR}
${KDE4_INCLUDES}
${KDEPIMLIBS_INCLUDE_DIR}
${QT_INCLUDES}
${Boost_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
set( akonadi_next_SRCS
note.cpp
notecreatorandselector.cpp
entityorderproxymodel.cpp
entityrightsfiltermodel.cpp
kbreadcrumbselectionmodel.cpp
krecursivefilterproxymodel.cpp
kmodelindexproxymapper.cpp
kviewstatesaver.cpp
kproxyitemselectionmodel.cpp
etmstatesaver.cpp
collectionchildorderattribute.cpp
collectionselectionproxymodel.cpp
modeltest.cpp
quotacolorproxymodel.cpp
checkableitemproxymodel.cpp
incidenceattachmentmodel.cpp
# TODO Move this to akonadi-kabc
contactsmodel.cpp
# TODO Move this to akonadi-mail?
mailmodel.cpp
amazingcompleter.cpp
amazingdelegate.cpp
modelstatesaver.cpp
entitymodelstatesaver.cpp
recursivecollectionfilterproxymodel.cpp
)
kde4_add_library(akonadi_next SHARED ${akonadi_next_SRCS} )
target_link_libraries(akonadi_next
${AKONADI_COMMON_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${KDEPIMLIBS_AKONADI_LIBS}
${KDE4_KIO_LIBS}
${KDEPIMLIBS_KABC_LIBS}
${KDEPIMLIBS_KMIME_LIBS}
${KDEPIMLIBS_KCAL_LIBS}
)
set_target_properties(akonadi_next PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
install(TARGETS akonadi_next ${INSTALL_TARGETS_DEFAULT_ARGS})
This diff is collapsed.
#!/bin/sh
$XGETTEXT *.cpp -o $podir/akonadi_next.pot
/* This file is part of the KDE project
Copyright (C) 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef AKONADI_NEXT_EXPORT_H
#define AKONADI_NEXT_EXPORT_H
/* needed for KDE_EXPORT and KDE_IMPORT macros */
#include <kdemacros.h>
#ifndef AKONADI_NEXT_EXPORT
# if defined(MAKE_AKONADI_NEXT_LIB)
/* We are building this library */
# define AKONADI_NEXT_EXPORT KDE_EXPORT
# else
/* We are using this library */
# define AKONADI_NEXT_EXPORT KDE_IMPORT
# endif
#endif
# ifndef AKONADI_NEXT_EXPORT_DEPRECATED
# define AKONADI_NEXT_EXPORT_DEPRECATED KDE_DEPRECATED AKONADI_NEXT_EXPORT
# endif
#endif
/*
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "amazingcompleter.h"
#include <kselectionproxymodel.h>
#include <qlistview.h>
#include <kdebug.h>
using namespace Akonadi;
class Akonadi::AmazingCompleterPrivate
{
public:
AmazingCompleterPrivate(AmazingCompleter *completer) //, QAbstractItemModel *model)
: m_matchingRole(Qt::DisplayRole),
m_completionRole(Qt::DisplayRole),
m_minumumLength(3),
q_ptr(completer)
{
}
QAbstractItemModel *m_model;
KSelectionProxyModel *m_selectionProxyModel;
QItemSelectionModel *m_itemSelectionModel;
QAbstractItemView *m_view;
QWidget *m_widget;
int m_matchingRole;
int m_completionRole;
AmazingCompleter::ViewHandler m_viewHandler;
QVariant m_matchData;
int m_minumumLength;
Q_DECLARE_PUBLIC(AmazingCompleter)
AmazingCompleter *q_ptr;
};
AmazingCompleter::AmazingCompleter( /* QAbstractItemModel* model, */ QObject* parent)
: QObject(parent), d_ptr(new AmazingCompleterPrivate(this) /* ,model) */)
{
}
AmazingCompleter::~AmazingCompleter()
{
delete d_ptr;
}
void AmazingCompleter::setCompletionPrefixString(const QString& matchData)
{
if (matchData.isEmpty())
setCompletionPrefix(QVariant());
else
setCompletionPrefix(matchData);
}
void AmazingCompleter::setCompletionPrefix(const QVariant& matchData)
{
Q_D(AmazingCompleter);
d->m_matchData = matchData;
d->m_itemSelectionModel->clearSelection();
if (!matchData.isValid())
{
d->m_view->hide();
return;
}
QString matchString = matchData.toString();
if (matchString.size() < d->m_minumumLength)
{
d->m_view->hide();
return;
}
QModelIndex idx = d->m_model->index(0, 0);
if (!idx.isValid())
return;
QModelIndexList matchingIndexes = d->m_model->match(idx, d->m_matchingRole, matchData, -1); // StartsWith
kDebug() << matchingIndexes.size();
if (matchingIndexes.size() > 0)
d->m_view->show();
else
d->m_view->hide();
foreach(const QModelIndex &matchingIndex, matchingIndexes)
d->m_itemSelectionModel->select(matchingIndex, QItemSelectionModel::Select); // Put this in a queued connection?
}
void AmazingCompleter::sourceRowsInserted(const QModelIndex &parent, int start, int end)
{
Q_UNUSED( parent );
Q_UNUSED( start );
Q_UNUSED( end );
Q_D(AmazingCompleter);
if (d->m_matchData.isValid())
setCompletionPrefix(d->m_matchData);
}
void AmazingCompleter::setModel(QAbstractItemModel* model)
{
Q_D(AmazingCompleter);
d->m_model = model;
d->m_itemSelectionModel = new QItemSelectionModel(model, this);
d->m_selectionProxyModel = new KSelectionProxyModel(d->m_itemSelectionModel, this);
d->m_selectionProxyModel->setSourceModel(d->m_model);
connect(d->m_model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
SLOT(sourceRowsInserted(const QModelIndex &, int, int)));
}
void AmazingCompleter::setView(QAbstractItemView* view, ViewHandler handler)
{
Q_D(AmazingCompleter);
d->m_view = view;
QSize size = d->m_widget->size();
size.setHeight(size.height()*10);
size.setWidth(size.width() * 2.5);
view->move(50, 50);
view->resize(size);
view->hide();
connectModelToView(d->m_selectionProxyModel, view);
}
void AmazingCompleter::connectModelToView(QAbstractItemModel *model, QAbstractItemView *view)
{
view->setModel(model);
}
void AmazingCompleter::setWidget(QWidget* widget)
{
Q_D(AmazingCompleter);
d->m_widget = widget;
}
void AmazingCompleter::setCompletionRole(int role)
{
Q_D(AmazingCompleter);
d->m_completionRole = role;
}
void AmazingCompleter::setMatchingRole(int role)
{
Q_D(AmazingCompleter);
d->m_matchingRole = role;
}
/*
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef AMAZING_COMPLETER_H
#define AMAZING_COMPLETER_H
#include <QObject>
#include <QWidget>
#include <QAbstractItemModel>
#include "akonadi_next_export.h"
class QAbstractItemView;
namespace Akonadi
{
class AmazingCompleterPrivate;
class AKONADI_NEXT_EXPORT AmazingCompleter : public QObject
{
Q_OBJECT
public:
enum ViewHandler { Popup, NoPopup };
AmazingCompleter(/* QAbstractItemModel *model, */ QObject *parent = 0);
~AmazingCompleter();
void setWidget(QWidget *widget);
void setView(QAbstractItemView *view, ViewHandler = Popup);
void setModel(QAbstractItemModel *model);
/**
The data from this is put into the lineedit
*/
void setCompletionRole(int role);
/**
This role is passed to match().
*/
void setMatchingRole(int role);
void setMinimumLength(int length);
public slots:
void setCompletionPrefixString(const QString &matchData);
void setCompletionPrefix(const QVariant &matchData);
void sourceRowsInserted(const QModelIndex &parent, int start, int end);
protected:
virtual void connectModelToView(QAbstractItemModel *model, QAbstractItemView *view);
private:
Q_DECLARE_PRIVATE(AmazingCompleter)
AmazingCompleterPrivate *d_ptr;
};
}
#endif
/*
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "amazingdelegate.h"
#include <QPainter>
#include <kdebug.h>
#include <akonadi/entitytreemodel.h>
#include <kabc/addressee.h>
#include <klocalizedstring.h>
#include <akonadi/entitydisplayattribute.h>
using namespace Akonadi;
AmazingContactItemDelegate::AmazingContactItemDelegate(QObject* parent): QStyledItemDelegate(parent)
{
}
void AmazingContactItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
Item item = index.data(EntityTreeModel::ItemRole).value<Item>();
if (!item.isValid())
QStyledItemDelegate::paint(painter, option, index);
if (!item.hasPayload<KABC::Addressee>())
{
kWarning() << "Not a KABC::Addressee" << item.id() << item.remoteId();
return;
}
KABC::Addressee addressee = item.payload<KABC::Addressee>();
painter->save();
if (option.state & QStyle::State_Selected)
painter->fillRect(option.rect, option.palette.highlight());
int PaintingScaleFactor = 2;
int yOffset = (option.rect.height() - PaintingScaleFactor) / 2;
painter->translate(option.rect.x(), option.rect.y() + yOffset);
Collection parentCollection = index.data(EntityTreeModel::ParentCollectionRole).value<Collection>();
QString name = addressee.givenName() + QLatin1Char( ' ' ) + addressee.familyName();
KABC::Picture pic =addressee.photo();
if (!pic.isEmpty())
{
QImage image = pic.data();
painter->drawImage(QRect(0, 0, 40, 40), image);
}
QString parentName;
if (parentCollection.hasAttribute<EntityDisplayAttribute>() && !parentCollection.attribute<EntityDisplayAttribute>()->displayName().isEmpty())
{
parentName = parentCollection.attribute<EntityDisplayAttribute>()->displayName();
} else
{
parentName = parentCollection.name();
}
QString email = addressee.preferredEmail();
if (email.isEmpty())
email = i18nc("An email address is not known for a contact. This is the default text provided", "<no email>");
painter->drawText(50, 0, name);
painter->drawText(50, 15, email);
painter->drawText(50, 30, parentName);
painter->restore();
}
QSize AmazingContactItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{
Item item = index.data(EntityTreeModel::ItemRole).value<Item>();
if (!item.isValid())
return QStyledItemDelegate::sizeHint(option, index);
QSize s = QStyledItemDelegate::sizeHint(option, index);
s.setHeight( s.height() * 4.5);
return s;
}
/*
Copyright (c) 2010 Klarälvdalens Datakonsult AB,
a KDAB Group company <info@kdab.com>
Author: Kevin Ottens <kevin@kdab.com>
Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
......@@ -19,35 +17,24 @@
02110-1301, USA.
*/
#ifndef RETRIEVEITEMTASK_H
#define RETRIEVEITEMTASK_H
#include <kimap/fetchjob.h>
#ifndef AMAZING_DELEGATE_H
#define AMAZING_DELEGATE_H
#include "resourcetask.h"
#include <QStyledItemDelegate>
class RetrieveItemTask : public ResourceTask
#include "akonadi_next_export.h"
class AKONADI_NEXT_EXPORT AmazingContactItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit RetrieveItemTask( ResourceStateInterface::Ptr resource, QObject *parent = 0 );
virtual ~RetrieveItemTask();
private slots:
void onSelectDone( KJob *job );
void onMessagesReceived( const QString &mailBox, const QMap<qint64, qint64> &uids,
const QMap<qint64, KIMAP::MessagePtr> &messages );
void onContentFetchDone( KJob *job );
AmazingContactItemDelegate(QObject* parent = 0);
protected:
virtual void doStart( KIMAP::Session *session );
void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
private:
void triggerFetchJob();
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
KIMAP::Session *m_session;
qint64 m_uid;
};
#endif
/*
This file is part of KDE.
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
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.
*/
#include "checkableitemproxymodel.h"
#include <QItemSelectionModel>
class CheckableItemProxyModelPrivate
{
Q_DECLARE_PUBLIC(CheckableItemProxyModel)
CheckableItemProxyModel *q_ptr;
CheckableItemProxyModelPrivate(CheckableItemProxyModel *checkableModel)
: q_ptr(checkableModel),
m_itemSelectionModel(0)
{
}
QItemSelectionModel *m_itemSelectionModel;
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
};
CheckableItemProxyModel::CheckableItemProxyModel(QObject* parent)
: QSortFilterProxyModel(parent), d_ptr(new CheckableItemProxyModelPrivate(this))
{
}
void CheckableItemProxyModel::setSelectionModel(QItemSelectionModel* itemSelectionModel)
{