[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/kjotsrewrite
From: Stephen Kelly <steveire () gmail ! com>
Date: 2008-10-31 21:58:07
Message-ID: 1225490287.773957.13090.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 878321 by skelly:
Move the plasmoid code to a subdirectory and add an app directory serving as a test \
harness for those without plasma.
M +41 -35 CMakeLists.txt
A app (directory)
A app/CMakeLists.txt
A app/kjotsrewrite.cpp [License: LGPL (v2.1+)]
A app/kjotsrewrite.h [License: LGPL (v2.1+)]
A app/main.cpp [License: LGPL (v2.1+)]
D kjots-plasmoid.cpp
D kjots-plasmoid.desktop
D kjots-plasmoid.h
M +21 -31 kjotsresource.cpp
M +2 -0 kjotsresource.h
A plasmoid (directory)
A plasmoid/CMakeLists.txt
AM plasmoid/kjots-plasmoid.cpp kjots-plasmoid.cpp#878219 [License: LGPL \
(v2+)] AM plasmoid/kjots-plasmoid.desktop kjots-plasmoid.desktop#878217
AM plasmoid/kjots-plasmoid.h kjots-plasmoid.h#878219 [License: LGPL \
(v2+)]
--- trunk/playground/pim/kjotsrewrite/CMakeLists.txt #878320:878321
@@ -69,42 +69,48 @@
install(TARGETS akonadi_kjots_resource ${INSTALL_TARGETS_DEFAULT_ARGS})
-#########################################################################
-# Plasmoid SECTION
-#########################################################################
+#### Clients ####
-find_package(Plasma REQUIRED)
+add_subdirectory(plasmoid)
+add_subdirectory(app)
-add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
-include_directories(
- ${CMAKE_SOURCE_DIR}
- ${CMAKE_BINARY_DIR}
- ${KDE4_INCLUDES}
- )
-# We add our source code here
-set(kjots_plasmoid_SRCS
- kjots-plasmoid.cpp
- kjotsbookshelf.cpp
- kjotspage.cpp
- kjotsbook.cpp
- kjotswidget.cpp
- modeltest.cpp
- )
+# #########################################################################
+# # Plasmoid SECTION
+# #########################################################################
+#
+# find_package(Plasma REQUIRED)
+#
+# add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
+# include_directories(
+# ${CMAKE_SOURCE_DIR}
+# ${CMAKE_BINARY_DIR}
+# ${KDE4_INCLUDES}
+# )
+#
+# # We add our source code here
+# set(kjots_plasmoid_SRCS
+# kjots-plasmoid.cpp
+# kjotsbookshelf.cpp
+# kjotspage.cpp
+# kjotsbook.cpp
+# kjotswidget.cpp
+# modeltest.cpp
+# )
+#
+# # Now make sure all files get to the right place
+# kde4_add_plugin(plasma_applet_kjots ${kjots_plasmoid_SRCS})
+# target_link_libraries(plasma_applet_kjots
+# ${PLASMA_LIBS}
+# ${KDE4_KDEUI_LIBS}
+# ${KDE4_KIO_LIBS}
+# ${KDE4_AKONADI_LIBS}
+# )
+#
+# install(TARGETS plasma_applet_kjots
+# DESTINATION ${PLUGIN_INSTALL_DIR})
+#
+# install(FILES kjots-plasmoid.desktop
+# DESTINATION ${SERVICES_INSTALL_DIR})
+#
-# Now make sure all files get to the right place
-kde4_add_plugin(plasma_applet_kjots ${kjots_plasmoid_SRCS})
-target_link_libraries(plasma_applet_kjots
- ${PLASMA_LIBS}
- ${KDE4_KDEUI_LIBS}
- ${KDE4_KIO_LIBS}
- ${KDE4_AKONADI_LIBS}
- )
-
-install(TARGETS plasma_applet_kjots
- DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES kjots-plasmoid.desktop
- DESTINATION ${SERVICES_INSTALL_DIR})
-
-
--- trunk/playground/pim/kjotsrewrite/kjotsresource.cpp #878320:878321
@@ -182,7 +182,8 @@
void KJotsResource::retrieveItems ( const Akonadi::Collection &collection )
{
- KUrl bookUrl ( rootDataPath + collection.remoteId() );
+ QString collectionRemoteId = collection.remoteId();
+ KUrl bookUrl ( rootDataPath + collectionRemoteId );
QFile bookFile ( bookUrl.toLocalFile() );
@@ -212,9 +213,10 @@
Item item ( KJotsPage::mimeType() );
- item.setRemoteId ( e.attribute ( "filename" ) );
+ QString itemRemoteId = e.attribute ( "filename" );
+ item.setRemoteId ( itemRemoteId );
- KUrl pageUrl ( rootDataPath + item.remoteId() );
+ KUrl pageUrl ( rootDataPath + itemRemoteId );
QFile pageFile ( pageUrl.toLocalFile() );
KJotsPage page = KJotsPage::fromIODevice ( &pageFile );
@@ -230,7 +232,11 @@
items << item;
- aboveRemoteId = e.attribute ( "filename" );
+ aboveRemoteId = itemRemoteId;
+
+ // A map holding remote ids for items and their parents. Used to \
know when to update a collection + // for example on itemRemoved.
+ pageBook.insert( itemRemoteId, collectionRemoteId );
}
if ( e.tagName() == "KJotsBook" ) {
aboveRemoteId = e.attribute ( "filename" );
@@ -277,8 +283,6 @@
void KJotsResource::itemAdded ( const Akonadi::Item &item, const Akonadi::Collection \
&collection ) {
-// Q_UNUSED ( item );
-// Q_UNUSED ( collection );
kDebug() << "item id=" << item.id() << ", remoteId=" << item.remoteId()
<< "mimeType=" << item.mimeType() << collection.name() << collection.remoteId();
@@ -339,10 +343,10 @@
// will be the itemAbove the one being added.
QString entityAbove;
QDomNode lastChild = rootElement.lastChild();
- kDebug() << " lastChild.isNull()" << lastChild.isNull();
+ kDebug() << "lastChild.isNull()" << lastChild.isNull();
if ( !lastChild.isNull() ) {
QDomElement lastElement = lastChild.toElement();
- kDebug() << " lastElement.isNull()" << lastElement.isNull();
+ kDebug() << "lastElement.isNull()" << lastElement.isNull();
if ( !lastElement.isNull() ) {
if ( ( lastElement.tagName() == "KJotsBook" )
|| ( lastElement.tagName() == "KJotsPage" ) ) {
@@ -383,19 +387,10 @@
changeCommitted ( newItem );
}
-
-
- // TODO: this method is called when somebody else, e.g. a client application,
- // has created an item in a collection managed by your resource.
-
- // NOTE: There is an equivalent method for collections, but it isn't part
- // of this template code to keep it simple
}
void KJotsResource::itemChanged ( const Akonadi::Item &item, const QSet<QByteArray> \
&parts ) {
-// Q_UNUSED ( item );
-// Q_UNUSED ( parts );
kDebug() << "item id=" << item.id() << ", remoteId=" << item.remoteId()
<< "mimeType=" << item.mimeType() << "parts=" << parts;
@@ -434,7 +429,13 @@
pageFile.close();
}
+ // TODO: The change could be a change in the itemAbove attribute,
+ // in which case the book would need to write out to file.
+ // EntityAboveAttribute *aboveAttribute = new EntityAboveAttribute();
+ // aboveAttribute->setItemAbove( entityAbove );
+ // newItem.addAttribute( aboveAttribute );
+
// Then notify akonadi.
Item newItem = item;
@@ -448,21 +449,8 @@
displayAttribute->setDisplayName ( page.title() );
newItem.addAttribute ( displayAttribute );
-// EntityAboveAttribute *aboveAttribute = new EntityAboveAttribute();
-// aboveAttribute->setItemAbove( entityAbove );
-// newItem.addAttribute( aboveAttribute );
-
-
changeCommitted ( newItem );
- // The change could be a change in the itemAbove attribute,
- // in which case the book would need to write out to file.
-
- // TODO: this method is called when somebody else, e.g. a client application,
- // has changed an item managed by your resource.
-
- // NOTE: There is an equivalent method for collections, but it isn't part
- // of this template code to keep it simple
}
void KJotsResource::itemRemoved ( const Akonadi::Item &item )
@@ -472,8 +460,10 @@
QFile::remove ( rootDataPath + item.remoteId() );
- // Is there any way to get the parent collection here to update it?
+ QString colRemoteId = pageBook.value( item.remoteId() );
+ // edit the collection stored data. Then notify akonadi?
+
}
void KJotsResource::collectionAdded ( const Akonadi::Collection &collection, const \
Akonadi::Collection &parent )
--- trunk/playground/pim/kjotsrewrite/kjotsresource.h #878320:878321
@@ -63,6 +63,8 @@
private:
QString rootDataPath;
+
+ QMap <QString, QString> pageBook;
};
#endif
** trunk/playground/pim/kjotsrewrite/plasmoid/kjots-plasmoid.cpp #property \
svn:mergeinfo +
** trunk/playground/pim/kjotsrewrite/plasmoid/kjots-plasmoid.desktop #property \
svn:mergeinfo +
** trunk/playground/pim/kjotsrewrite/plasmoid/kjots-plasmoid.h #property \
svn:mergeinfo +
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic