Commit 23d69297 authored by Jarosław Staniek's avatar Jarosław Staniek

Remove the koproperty lib, it will be replaced by external KProperty

(also add the proper name KProperty to linking commands)
parent 135fabb8
......@@ -800,12 +800,6 @@ set(KOPAGEAPP_INCLUDES ${TEXTLAYOUT_INCLUDES}
${CMAKE_SOURCE_DIR}/libs/widgets
${CMAKE_SOURCE_DIR}/libs/kopageapp ${CMAKE_SOURCE_DIR}/libs/kopageapp/commands ${CMAKE_BINARY_DIR}/libs/kopageapp )
# koproperty
set(KOPROPERTY_INCLUDES ${KOODF_INCLUDES}
${CMAKE_SOURCE_DIR}/libs
${CMAKE_SOURCE_DIR}/libs/widgets)
set(KOPROPERTY_LIBS koproperty)
# koreport
set(KOREPORT_INCLUDES
${CMAKE_SOURCE_DIR}/libs/
......
......@@ -64,9 +64,8 @@ calligra_define_product(BUILDTOOL_RNG2CPP "rng2cpp")
# Calligra-independent utility libs
calligra_define_product(LIB_KOVECTORIMAGE "libkovectorimage")
calligra_define_product(LIB_KOPROPERTY "libkoproperty" UNPORTED)
calligra_define_product(LIB_CALLIGRADB "libcalligradb" UNPORTED)
calligra_define_product(LIB_KOREPORT "libkoreport" UNPORTED REQUIRES LIB_KOPROPERTY LIB_CALLIGRADB)
calligra_define_product(LIB_KOREPORT "libkoreport" UNPORTED REQUIRES LIB_CALLIGRADB)
# calligra libs
calligra_define_product(LIB_CALLIGRA "Calligra core libs" REQUIRES BUILDTOOL_RNG2CPP)
......
......@@ -25,10 +25,6 @@ if (SHOULD_BUILD_LIB_KOPAGEAPP)
add_subdirectory( kopageapp )
endif ()
if(SHOULD_BUILD_LIB_KOPROPERTY)
add_subdirectory( koproperty ) # TODO move to independent place like kdesupport
endif()
if (SHOULD_BUILD_LIB_CALLIGRADB)
add_subdirectory( db ) # used by Kexi and Word's Biblio; TODO: remove when Predicate lib arrives
endif ()
......
#! /bin/sh
source ../calligra_xgettext.sh
EXCLUDE="-path ./koproperty -o -path ./db/drivers/sqlite" # TODO: -o -path ./koreport"
EXCLUDE="-o -path ./db/drivers/sqlite" # TODO: -o -path ./koreport"
LIST=`find . \( $EXCLUDE \) -prune -o \( -name \*.ui -o -name \*.rc \) -type f -print | grep -v -e '/\.'`
$EXTRACTRC $LIST >> rc.cpp
LIST=`find . \( $EXCLUDE \) -prune -o \( -name \*.cpp -o -name \*.cc -o -name \*.h \) -type f -print | grep -v '/tests/' | grep -v -e '/\.'`
......
add_subdirectory( tests )
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=44022)
set(libkopropertyeditors_SRCS
editors/utils.cpp
editors/booledit.cpp
editors/coloredit.cpp
editors/combobox.cpp
editors/cursoredit.cpp
editors/dateedit.cpp
editors/datetimeedit.cpp
# editors/dummywidget.cpp
editors/fontedit.cpp
editors/pixmapedit.cpp
editors/pointedit.cpp
editors/pointfedit.cpp
editors/rectedit.cpp
editors/sizeedit.cpp
editors/sizefedit.cpp
editors/sizepolicyedit.cpp
editors/spinbox.cpp
editors/stringedit.cpp
editors/linestyleedit.cpp
# editors/stringlistedit.cpp
# editors/symbolcombo.cpp
editors/timeedit.cpp
# editors/urledit.cpp
)
include_directories(${KOPROPERTY_INCLUDES})
########### next target ###############
set(koproperty_LIB_SRCS
Property.cpp
Set.cpp
Factory.cpp
DefaultFactory.cpp
EditorView.cpp
EditorDataModel.cpp
Utils.cpp
${libkopropertyeditors_SRCS}
)
add_library(koproperty SHARED ${koproperty_LIB_SRCS})
target_link_libraries(koproperty KF5::KIOWidgets kowidgets)
target_link_libraries(koproperty LINK_INTERFACE_LIBRARIES KF5::KIOWidgets kowidgets)
set_target_properties(koproperty PROPERTIES VERSION ${GENERIC_CALLIGRA_LIB_VERSION} SOVERSION ${GENERIC_CALLIGRA_LIB_SOVERSION})
install(TARGETS koproperty ${INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
ecm_install_icons(${DATA_INSTALL_DIR}/koproperty/icons)
if(FALSE) # TODO: install when we move to independent place
install( FILES
Factory.h
koproperty_global.h
koproperty_export.h
Property.h
Set.h
Utils.h
Factory.h
EditorView.h
DESTINATION ${INCLUDE_INSTALL_DIR}/koproperty COMPONENT Devel
)
install( FILES
editors/utils.h
editors/booledit.h
editors/coloredit.h
editors/combobox.h
editors/cursoredit.h
editors/dateedit.h
editors/datetimeedit.h
editors/dummywidget.h
editors/fontedit.h
editors/linestyleedit.h
editors/pixmapedit.h
editors/pointedit.h
editors/rectedit.h
editors/sizeedit.h
editors/sizepolicyedit.h
editors/spinbox.h
editors/spinbox.h
editors/stringedit.h
editors/stringlistedit.h
editors/symbolcombo.h
editors/timeedit.h
editors/urledit.h
DESTINATION ${INCLUDE_INSTALL_DIR}/koproperty/editors COMPONENT Devel)
endif()
/* This file is part of the KDE project
Copyright (C) 2008 Jarosław Staniek <staniek@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.
*/
#include "DefaultFactory.h"
#include "Property.h"
/*
#include "customproperty.h"*/
#include "editors/booledit.h"
#include "editors/combobox.h"
#include "editors/coloredit.h"
#include "editors/cursoredit.h"
#include "editors/dateedit.h"
#include "editors/datetimeedit.h"
// #include "editors/dummywidget.h"
#include "editors/pixmapedit.h"
#include "editors/pointedit.h"
#include "editors/pointfedit.h"
#include "editors/fontedit.h"
#include "editors/rectedit.h"
#include "editors/sizeedit.h"
#include "editors/sizefedit.h"
#include "editors/sizepolicyedit.h"
#include "editors/spinbox.h"
/*#include "stringlistedit.h"*/
#include "editors/linestyleedit.h"
#include "editors/stringedit.h"
// #include "symbolcombo.h"
#include "editors/timeedit.h"
// #include "urledit.h"
#include <kdebug.h>
using namespace KoProperty;
DefaultFactory::DefaultFactory()
: Factory()
{
addEditor( KoProperty::Bool, new BoolDelegate );
addEditor( KoProperty::Cursor, new CursorDelegate );
addEditor( KoProperty::Color, new ColorComboDelegate );
addEditor( KoProperty::Date, new DateDelegate );
addEditor( KoProperty::DateTime, new DateTimeDelegate );
addEditor( KoProperty::Double, new DoubleSpinBoxDelegate );
addEditor( KoProperty::Font, new FontDelegate );
addEditor( KoProperty::Int, new IntSpinBoxDelegate );
addEditor( KoProperty::LineStyle, new LineStyleComboDelegate );
//! @todo addEditor( KoProperty::LongLong, new LongLongSpinBoxDelegate );
addEditor( KoProperty::Pixmap, new PixmapDelegate );
addEditor( KoProperty::Point, new PointDelegate );
addEditor( KoProperty::PointF, new PointFDelegate );
addEditor( KoProperty::Rect, new RectDelegate );
addEditor( KoProperty::Size, new SizeDelegate );
addEditor( KoProperty::SizeF, new SizeFDelegate );
addEditor( KoProperty::SizePolicy, new SizePolicyDelegate );
addEditor( KoProperty::String, new StringDelegate );
addEditor( KoProperty::Time, new TimeDelegate );
addEditor( KoProperty::UInt, new IntSpinBoxDelegate );
//! @todo addEditor( KoProperty::ULongLong, new LongLongSpinBoxDelegate );
addEditor( KoProperty::ValueFromList, new ComboBoxDelegate );
}
DefaultFactory::~DefaultFactory()
{
}
/* This file is part of the KDE project
Copyright (C) 2008 Jarosław Staniek <staniek@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 KPROPERTY_DEFAULT_FACTORY_H
#define KPROPERTY_DEFAULT_FACTORY_H
#include "Factory.h"
namespace KoProperty
{
class DefaultFactory : public Factory
{
public:
DefaultFactory();
~DefaultFactory();
};
}
#endif
/* This file is part of the KDE project
Copyright (C) 2008-2009 Jarosław Staniek <staniek@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.
*/
#include "EditorDataModel.h"
#include "Factory.h"
#include "Property.h"
#include "Set.h"
#include <QHash>
#include <klocale.h>
#include <kdebug.h>
using namespace KoProperty;
class EditorDataModel::Private
{
public:
explicit Private(Set *_set, Set::Order _order = Set::InsertionOrder) : set(_set), order(_order)
{
}
Set *set;
Property rootItem;
QHash<QByteArray, QPersistentModelIndex> indicesForNames;
Set::Order order; //!< order of properties
};
// -------------------
//! A property selector offering functor selecting only visible properties.
/*! Used e.g. in EditorDataModel::index(). */
class VisiblePropertySelector : public Set::PropertySelector
{
public:
VisiblePropertySelector() {}
virtual bool operator()(const Property& prop) const {
return prop.isVisible();
}
Set::PropertySelector* clone() const { return new VisiblePropertySelector(); }
};
// -------------------
EditorDataModel::EditorDataModel(Set &propertySet, QObject *parent,
Set::Order order)
: QAbstractItemModel(parent)
, d(new Private(&propertySet, order))
{
collectIndices();
}
EditorDataModel::~EditorDataModel()
{
delete d;
}
typedef QPair<QByteArray, QString> NameAndCaption;
bool nameAndCaptionLessThan(const NameAndCaption &n1, const NameAndCaption &n2)
{
return QString::compare(n1.second, n2.second, Qt::CaseInsensitive) < 0;
}
void EditorDataModel::collectIndices() const
{
Set::Iterator it(*d->set, VisiblePropertySelector());
if (d->order == Set::AlphabeticalOrder) {
it.setOrder(Set::AlphabeticalOrder);
}
d->indicesForNames.clear();
for (int row = 0; it.current(); row++, ++it) {
// kDebug() << it.current()->name() << "->" << row;
d->indicesForNames.insert( it.current()->name(), QPersistentModelIndex( createIndex(row, 0, it.current()) ) );
}
}
QModelIndex EditorDataModel::indexForPropertyName(const QByteArray& propertyName) const
{
return (const QModelIndex &)d->indicesForNames.value(propertyName);
}
QModelIndex EditorDataModel::indexForColumn(const QModelIndex& index, int column) const
{
if (column == 0)
return index;
return createIndex(index.row(), column, propertyForItem(index));
}
int EditorDataModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 2;
}
QVariant EditorDataModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const int col = index.column();
if (col == 0) {
Property *prop = propertyForItem(index);
if (role == Qt::DisplayRole) {
if (!prop->caption().isEmpty())
return prop->caption();
return prop->name();
}
else if (role == PropertyModifiedRole) {
return prop->isModified();
}
}
else if (col == 1) {
Property *prop = propertyForItem(index);
if (role == Qt::EditRole) {
return prop->value();
}
else if (role == Qt::DisplayRole) {
return FactoryManager::self()->convertValueToText(prop);
}
}
return QVariant();
}
Qt::ItemFlags EditorDataModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return Qt::ItemIsEnabled;
const int col = index.column();
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
Property *prop = propertyForItem(index);
if (prop) {
if (col == 1) {
f |= Qt::ItemIsEditable;
}
}
return f;
}
Property *EditorDataModel::propertyForItem(const QModelIndex &index) const
{
if (index.isValid()) {
Property *item = static_cast<Property*>(index.internalPointer());
if (item)
return item;
}
return &d->rootItem;
}
QVariant EditorDataModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
if (section == 0) {
return i18nc("Property name", "Name");
} else {
return i18nc("Property value", "Value");
}
}
return QVariant();
}
QModelIndex EditorDataModel::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid() && parent.column() != 0)
return QModelIndex();
Property *parentItem = propertyForItem(parent);
Property *childItem;
if (parentItem == &d->rootItem) { // special case: top level
int visibleRows = 0;
Set::Iterator it(*d->set, VisiblePropertySelector());
if (d->order == Set::AlphabeticalOrder) {
it.setOrder(Set::AlphabeticalOrder);
}
//! @todo use qBinaryFind()?
for (; visibleRows < row && it.current(); visibleRows++, ++it)
;
childItem = it.current();
} else {
const QList<Property*>* children = parentItem->children();
if (!children)
return QModelIndex();
childItem = children->value(row);
}
if (!childItem)
return QModelIndex();
return createIndex(row, column, childItem);
}
QModelIndex EditorDataModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
Property *childItem = propertyForItem(index);
Property *parentItem = childItem->parent();
if (!parentItem)
return QModelIndex();
const QList<Property*>* children = parentItem->children();
Q_ASSERT(children);
const int indexOfItem = children->indexOf(childItem);
Q_ASSERT(indexOfItem != -1);
return createIndex(indexOfItem, 0, parentItem);
}
int EditorDataModel::rowCount(const QModelIndex &parent) const
{
Property *parentItem = propertyForItem(parent);
if (!parentItem || parentItem == &d->rootItem) { // top level
return d->set->count(VisiblePropertySelector());
}
const QList<Property*>* children = parentItem->children();
return children ? children->count() : 0;
}
bool EditorDataModel::setData(const QModelIndex &index, const QVariant &value,
int role)
{
if (role != Qt::EditRole)
return false;
Property *item = propertyForItem(index);
if (item == &d->rootItem)
return false;
item->setValue(value);
return true;
}
bool EditorDataModel::setHeaderData(int section, Qt::Orientation orientation,
const QVariant &value, int role)
{
Q_UNUSED(section);
Q_UNUSED(orientation);
Q_UNUSED(value);
Q_UNUSED(role);
return false;
}
QModelIndex EditorDataModel::buddy(const QModelIndex & idx) const
{
if (idx.column() == 0)
return index( idx.row(), 1, parent(idx));
return idx;
}
Set& EditorDataModel::propertySet() const
{
return *d->set;
}
void EditorDataModel::setOrder(Set::Order order)
{
if (d->order != order) {
d->order = order;
collectIndices();
}
}
Set::Order EditorDataModel::order() const
{
return d->order;
}
bool EditorDataModel::hasChildren(const QModelIndex & parent) const
{
Property *parentItem = propertyForItem(parent);
if (!parentItem || parentItem == &d->rootItem) { // top level
return d->set->hasVisibleProperties();
}
const QList<Property*>* children = parentItem->children();
return children && !children->isEmpty();
}
#include "EditorDataModel.moc"
/* This file is part of the KDE project
Copyright (C) 2008 Jarosław Staniek <staniek@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 KPROPERTY_EDITORDATAMODEL_H
#define KPROPERTY_EDITORDATAMODEL_H
#include <QAbstractItemModel>
#include <QModelIndex>
#include "Set.h"
namespace KoProperty
{
class Property;
/*! @short A data model for using Set objects within the Qt's model/view API.
@see EditorView
*/
class KOPROPERTY_EXPORT EditorDataModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit EditorDataModel(Set &propertySet, QObject *parent = 0,
Set::Order order = Set::InsertionOrder);
~EditorDataModel();
enum Role {
PropertyModifiedRole = Qt::UserRole + 0
};
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole);
bool setHeaderData(int section, Qt::Orientation orientation,
const QVariant &value, int role = Qt::EditRole);
QModelIndex buddy(const QModelIndex & index) const;
//! @return property set object for this model.
Set& propertySet() const;
//! @return property object for model index @a index
//! or 0 for invalid index or index without property assigned.
Property *propertyForItem(const QModelIndex& index) const;
//! @return model index for property named @a propertyName
//! or invalid index if such property could not be found.
QModelIndex indexForPropertyName(const QByteArray& propertyName) const;
//! @return a sibling for model index @a index and columnd @a column
QModelIndex indexForColumn(const QModelIndex& index, int column) const;
//! Sets order for properties. Restarts the iterator.
void setOrder(Set::Order order);
//! @return order for properties.
Set::Order order() const;
//! Reimplemented for optimization.
bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
private:
void collectIndices() const;
class Private;
Private * const d;
friend class EditorView;
};
}
#endif
This diff is collapsed.
/* This file is part of the KDE project
Copyright (C) 2008-2009 Jarosław Staniek <staniek@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 KPROPERTY_EDITORVIEW_H
#define KPROPERTY_EDITORVIEW_H
#include "koproperty_export.h"
#include <QTreeView>
namespace KoProperty
{
class Property;
class Set;
//! @brief A widget for editing properties
//! @todo review this .............
/*! Editor widgets use property options using Property::option(const char *)
to override default behaviour of editor items.
Currently supported options are: