From b54d247b7b4d7dd992a2fe012d28ef9f6020ef43 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 8 Apr 2010 21:15:34 +0200 Subject: [PATCH] Remove mutabletags from the 0.1 release. The feature may be redesinged and added again in the future. --- CMakeLists.txt | 2 - corelib/CMakeLists.txt | 2 - corelib/engine.cpp | 28 --- corelib/engine.h | 17 +- corelib/grantlee_core.h | 1 - corelib/mutabletemplate.cpp | 39 ---- corelib/mutabletemplate.h | 59 ------ corelib/node.cpp | 40 ---- corelib/node.h | 22 -- corelib/templateloader.cpp | 38 ---- corelib/templateloader.h | 10 - dox/examples.dox | 2 - dox/internals.dox | 2 +- examples/dbus-chat/CMakeLists.txt | 54 ----- examples/dbus-chat/chat.cpp | 232 ---------------------- examples/dbus-chat/chat.h | 101 ---------- examples/dbus-chat/chat_adaptor.cpp | 35 ---- examples/dbus-chat/chat_adaptor.h | 57 ------ examples/dbus-chat/chat_interface.cpp | 25 --- examples/dbus-chat/chat_interface.h | 49 ----- examples/dbus-chat/chatitem.cpp | 47 ----- examples/dbus-chat/chatitem.h | 53 ----- examples/dbus-chat/chatmainwindow.ui | 192 ------------------ examples/dbus-chat/chatsetnickname.ui | 149 -------------- examples/dbus-chat/com.trolltech.chat.xml | 15 -- examples/dbus-chat/dbus-chat.pro | 19 -- examples/dbus-chat/grantlee_paths.h.cmake | 3 - examples/dbus-chat/themes/boxes.html | 62 ------ examples/dbus-chat/themes/colored.html | 36 ---- examples/dbus-chat/themes/plain.html | 23 --- loadertags/extends.cpp | 4 - mutabletags/CMakeLists.txt | 24 --- mutabletags/mutabletags.cpp | 27 --- mutabletags/mutabletags.h | 50 ----- mutabletags/raw.cpp | 58 ------ mutabletags/raw.h | 60 ------ mutabletags/repeater.cpp | 58 ------ mutabletags/repeater.h | 57 ------ tests/CMakeLists.txt | 1 - tests/testbuiltins.cpp | 6 - tests/testmutabletags.cpp | 227 --------------------- 41 files changed, 2 insertions(+), 1984 deletions(-) delete mode 100644 corelib/mutabletemplate.cpp delete mode 100644 corelib/mutabletemplate.h delete mode 100644 examples/dbus-chat/CMakeLists.txt delete mode 100644 examples/dbus-chat/chat.cpp delete mode 100644 examples/dbus-chat/chat.h delete mode 100644 examples/dbus-chat/chat_adaptor.cpp delete mode 100644 examples/dbus-chat/chat_adaptor.h delete mode 100644 examples/dbus-chat/chat_interface.cpp delete mode 100644 examples/dbus-chat/chat_interface.h delete mode 100644 examples/dbus-chat/chatitem.cpp delete mode 100644 examples/dbus-chat/chatitem.h delete mode 100644 examples/dbus-chat/chatmainwindow.ui delete mode 100644 examples/dbus-chat/chatsetnickname.ui delete mode 100644 examples/dbus-chat/com.trolltech.chat.xml delete mode 100644 examples/dbus-chat/dbus-chat.pro delete mode 100644 examples/dbus-chat/grantlee_paths.h.cmake delete mode 100644 examples/dbus-chat/themes/boxes.html delete mode 100644 examples/dbus-chat/themes/colored.html delete mode 100644 examples/dbus-chat/themes/plain.html delete mode 100644 mutabletags/CMakeLists.txt delete mode 100644 mutabletags/mutabletags.cpp delete mode 100644 mutabletags/mutabletags.h delete mode 100644 mutabletags/raw.cpp delete mode 100644 mutabletags/raw.h delete mode 100644 mutabletags/repeater.cpp delete mode 100644 mutabletags/repeater.h delete mode 100644 tests/testmutabletags.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f4dff38..0f8a6436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,8 +63,6 @@ if (BUILD_MAIN_PLUGINS) add_subdirectory(defaulttags) add_subdirectory(defaultfilters) - - add_subdirectory(mutabletags) endif() if (BUILD_SCRIPT_PLUGIN) diff --git a/corelib/CMakeLists.txt b/corelib/CMakeLists.txt index 0f55d836..dc20b7f6 100644 --- a/corelib/CMakeLists.txt +++ b/corelib/CMakeLists.txt @@ -14,7 +14,6 @@ set (grantlee_core_SRCS engine.cpp filterexpression.cpp lexer.cpp - mutabletemplate.cpp node.cpp nodebuiltins.cpp outputstream.cpp @@ -59,7 +58,6 @@ install(FILES filterexpression.h grantlee_core_export.h ${PROJECT_BINARY_DIR}/grantlee_version.h - mutabletemplate.h node.h outputstream.h parser.h diff --git a/corelib/engine.cpp b/corelib/engine.cpp index 0e42159d..69a004c5 100644 --- a/corelib/engine.cpp +++ b/corelib/engine.cpp @@ -271,34 +271,6 @@ Template Engine::loadByName( const QString &name ) const return t; } -MutableTemplate Engine::loadMutableByName( const QString &name ) const -{ - Q_D( const Engine ); - - QListIterator it( d->m_loaders ); - - while ( it.hasNext() ) { - AbstractTemplateLoader::Ptr loader = it.next(); - MutableTemplate t = loader->loadMutableByName( name, this ); - if ( t ) { - return t; - } - } - MutableTemplate t = MutableTemplate( new MutableTemplateImpl( this ) ); - t->setObjectName( name ); - t->d_ptr->m_error = TagSyntaxError; - t->d_ptr->m_errorString = QString::fromLatin1( "Template not found, %1" ).arg( name ); - return t; -} - -MutableTemplate Engine::newMutableTemplate( const QString &content, const QString &name ) const -{ - MutableTemplate t = MutableTemplate( new MutableTemplateImpl( this ) ); - t->setObjectName( name ); - t->setContent( content ); - return t; -} - Template Engine::newTemplate( const QString &content, const QString &name ) const { Template t = Template( new TemplateImpl( this ) ); diff --git a/corelib/engine.h b/corelib/engine.h index a987f899..1886c747 100644 --- a/corelib/engine.h +++ b/corelib/engine.h @@ -21,7 +21,6 @@ #ifndef GRANTLEE_ENGINE_H #define GRANTLEE_ENGINE_H -#include "mutabletemplate.h" #include "template.h" #include "templateloader.h" @@ -36,7 +35,7 @@ class EnginePrivate; /** @brief Grantlee::Engine is the main entry point for creating %Grantlee Templates. - The Grantlee::Engine is responsible for configuring and creating Template and MutableTemplate objects. + The Grantlee::Engine is responsible for configuring and creating Template objects. In typical use, one or more TemplateLoader objects will be added to the Engine to load template objects, and plugin directories will be set to enable finding template tags and filters. @@ -123,20 +122,6 @@ class GRANTLEE_CORE_EXPORT Engine : public QObject */ Template newTemplate( const QString &content, const QString &name ) const; - /** - Load the MutableTemplate identified by @p name. - - The Templates and plugins loaded and will be determined by the Engine configuration. - */ - MutableTemplate loadMutableByName( const QString &name ) const; - - /** - Create a new MutableTemplate with the content @p content identified by @p name. - - The secondary Templates and plugins loaded will be determined by the Engine configuration. - */ - MutableTemplate newMutableTemplate( const QString &content, const QString &name ) const; - /** Returns the libraries available by default to new Templates. */ diff --git a/corelib/grantlee_core.h b/corelib/grantlee_core.h index 4ed6a3fc..abf29da3 100644 --- a/corelib/grantlee_core.h +++ b/corelib/grantlee_core.h @@ -28,7 +28,6 @@ #include "grantlee/filterexpression.h" #include "grantlee/grantlee_core_export.h" #include "grantlee/grantlee_version.h" -#include "grantlee/mutabletemplate.h" #include "grantlee/node.h" #include "grantlee/outputstream.h" #include "grantlee/parser.h" diff --git a/corelib/mutabletemplate.cpp b/corelib/mutabletemplate.cpp deleted file mode 100644 index 616a32e7..00000000 --- a/corelib/mutabletemplate.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of the Grantlee template system. - - Copyright (c) 2009,2010 Stephen Kelly - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version - 2 of the Licence, 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 Lesser General Public - License along with this library. If not, see . - -*/ - -#include "mutabletemplate.h" - -using namespace Grantlee; - -MutableTemplateImpl::MutableTemplateImpl( Engine const *engine, QObject *parent ) - : TemplateImpl( engine, parent ) -{ - -} - -QString MutableTemplateImpl::render( Context* c ) -{ - c->setMutating( true ); - return TemplateImpl::render( c ); - -} - -#include "mutabletemplate.moc" - diff --git a/corelib/mutabletemplate.h b/corelib/mutabletemplate.h deleted file mode 100644 index 1d92528d..00000000 --- a/corelib/mutabletemplate.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of the Grantlee template system. - - Copyright (c) 2009,2010 Stephen Kelly - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version - 2 of the Licence, 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 Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef GRANTLEE_MUTABLE_TEMPLATE_H -#define GRANTLEE_MUTABLE_TEMPLATE_H - -#include "template.h" - -namespace Grantlee -{ -class MutableTemplateImpl; - -typedef QWeakPointer MutableTemplateWeakPtr; -typedef QSharedPointer MutableTemplate; - -/// @headerfile mutabletemplate.h grantlee/mutabletemplate.h - -/** - A Template which is mutated each time it is rendered. -*/ -class MutableTemplateImpl : public TemplateImpl -{ - Q_OBJECT -public: - /** - Constructor. - */ - explicit MutableTemplateImpl( Engine const *engine, QObject *parent = 0 ); - - /** - Renders the Template, possibly mutating it. - */ - /* reimp */ QString render( Context *c ); - -}; - -} - -Q_DECLARE_METATYPE( Grantlee::MutableTemplate ) - -#endif - diff --git a/corelib/node.cpp b/corelib/node.cpp index 6f1df986..6887d173 100644 --- a/corelib/node.cpp +++ b/corelib/node.cpp @@ -152,9 +152,6 @@ bool NodeList::containsNonText() const void NodeList::render( OutputStream *stream, Context *c ) { - if ( c->isMutating() ) - return mutableRender( stream, c ); - for ( int i = 0; i < this->size(); ++i ) { this->at( i )->render( stream, c ); } @@ -162,43 +159,6 @@ void NodeList::render( OutputStream *stream, Context *c ) return; } -void NodeList::mutableRender( OutputStream *stream, Context *c ) -{ - QString renderedTemplate; - QString renderedNode; - - QTextStream textStream( &renderedNode ); - QSharedPointer nodeStream = stream->clone( &textStream ); - - QList::iterator it; - QList::iterator first = begin(); - QList::iterator last = end(); - - for ( it = first; it != last; ++it ) { - renderedNode.clear(); - Grantlee::Node *node = *it; - node->render( nodeStream.data(), c ); - renderedTemplate += renderedNode; - bool isPersistent = node->isPersistent(); - if ( it != first ) { - Grantlee::Node *lastNode = *( it - 1 ); - TextNode *textNode = qobject_cast( lastNode ); - if ( textNode && ( !isPersistent || node->isRepeatable() ) ) { - textNode->appendContent( renderedNode ); - } - if ( *it == *( last - 1 ) ) { - break; - } - if ( !isPersistent && !lastNode->isPersistent() ) { - it = erase( it ); - // TODO: This --it is broken. Fix this iteration. - --it; - } - } - } - ( *stream ) << renderedTemplate; -} - AbstractNodeFactory::AbstractNodeFactory( QObject *parent ) : QObject( parent ), d_ptr( new AbstractNodeFactoryPrivate( this ) ) { diff --git a/corelib/node.h b/corelib/node.h index aebf7367..1991c2a1 100644 --- a/corelib/node.h +++ b/corelib/node.h @@ -98,22 +98,6 @@ class GRANTLEE_CORE_EXPORT Node : public QObject // This can't be const because CycleNode needs to change on each render. virtual void render( OutputStream *stream, Context *c ) = 0; - /** - Reimplement this to return whether the node is persistent. - @see mutable_templates - */ - virtual bool isPersistent() { // krazy:exclude:inline - return isRepeatable(); - } - - /** - Reimplement this to return whether the node is repeatable. - @see mutable_templates - */ - virtual bool isRepeatable() { // krazy:exclude:inline - return false; - } - #ifndef Q_QDOC /** @internal @@ -218,12 +202,6 @@ class GRANTLEE_CORE_EXPORT NodeList : public QList */ void render( OutputStream *stream, Context *c ); -protected: - /** - Renders the list of Nodes in the Context @p c, possibly mutating the nodes contained in it. - */ - void mutableRender( OutputStream *stream, Context *c ); - private: bool m_containsNonText; }; diff --git a/corelib/templateloader.cpp b/corelib/templateloader.cpp index d03b6548..77befe4c 100644 --- a/corelib/templateloader.cpp +++ b/corelib/templateloader.cpp @@ -90,35 +90,6 @@ bool FileSystemTemplateLoader::canLoadTemplate( const QString &name ) const return true; } -// TODO Refactor these two. -MutableTemplate FileSystemTemplateLoader::loadMutableByName( const QString &fileName, Engine const *engine ) const -{ - int i = 0; - QFile file; - - while ( !file.exists() ) { - if ( i >= m_templateDirs.size() ) - break; - - file.setFileName( m_templateDirs.at( i ) + '/' + m_themeName + '/' + fileName ); - - QFileInfo fi( file ); - if ( !fi.canonicalFilePath().contains( QDir( m_templateDirs.at( i ) ).canonicalPath() ) ) - return MutableTemplate(); - ++i; - } - - if ( !file.exists() || !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { - throw Grantlee::Exception( TagSyntaxError, QString( "Couldn't load template from %1. File does not exist." ).arg( fileName ) ); - } - - QString content; - content = file.readAll(); - - MutableTemplate t = engine->newMutableTemplate( content, fileName ); - return t; -} - Template FileSystemTemplateLoader::loadByName( const QString &fileName, Engine const *engine ) const { int i = 0; @@ -189,15 +160,6 @@ Template InMemoryTemplateLoader::loadByName( const QString& name, Engine const * throw Grantlee::Exception( TagSyntaxError, QString( "Couldn't load template %1. Template does not exist." ).arg( name ) ); } -MutableTemplate InMemoryTemplateLoader::loadMutableByName( const QString& name, Engine const *engine ) const -{ - if ( m_namedTemplates.contains( name ) ) { - MutableTemplate t = engine->newMutableTemplate( m_namedTemplates.value( name ), name ); - return t; - } - throw Grantlee::Exception( TagSyntaxError, QString( "Couldn't load template %1. Template does not exist." ).arg( name ) ); -} - QPair InMemoryTemplateLoader::getMediaUri( const QString& fileName ) const { Q_UNUSED( fileName ) diff --git a/corelib/templateloader.h b/corelib/templateloader.h index b5958279..7f2bdf90 100644 --- a/corelib/templateloader.h +++ b/corelib/templateloader.h @@ -23,7 +23,6 @@ #include -#include "mutabletemplate.h" #include "template.h" #include "grantlee_core_export.h" @@ -56,11 +55,6 @@ class GRANTLEE_CORE_EXPORT AbstractTemplateLoader */ virtual ~AbstractTemplateLoader(); - /** - Load a MutableTemplate called @p name. Return an invalid Template if no content by that name exists. - */ - virtual MutableTemplate loadMutableByName( const QString &name, Engine const *engine ) const = 0; - /** Load a Template called @p name. Return an invalid Template if no content by that name exists. */ @@ -140,8 +134,6 @@ class GRANTLEE_CORE_EXPORT FileSystemTemplateLoader : public AbstractTemplateLoa */ virtual ~FileSystemTemplateLoader(); - /* reimp */ MutableTemplate loadMutableByName( const QString &name, Engine const *engine ) const; - /* reimp */ Template loadByName( const QString &name, Engine const *engine ) const; /* reimp */ bool canLoadTemplate( const QString &name ) const; @@ -187,8 +179,6 @@ class GRANTLEE_CORE_EXPORT InMemoryTemplateLoader : public AbstractTemplateLoade InMemoryTemplateLoader(); virtual ~InMemoryTemplateLoader(); - /* reimp */ MutableTemplate loadMutableByName( const QString &name, Engine const *engine ) const; - /* reimp */ Template loadByName( const QString &name, Engine const *engine ) const; /* reimp */ bool canLoadTemplate( const QString &name ) const; diff --git a/dox/examples.dox b/dox/examples.dox index f8676094..bcf73934 100644 --- a/dox/examples.dox +++ b/dox/examples.dox @@ -22,8 +22,6 @@ namespace Grantlee @image html grantlee_chat_coloured.png "Simple version with some colouring." @image html grantlee_chat_boxes.png "A version with content in boxes." - The idea for the Mutable Tags comes from this blog. - @section kjots KJots Rewrite. (see playground/pim/akonadi) KJots shows a use of %Grantlee by retrieving items from a Model using a custom role, and allows arbitrary nesting by recursively including templates. diff --git a/dox/internals.dox b/dox/internals.dox index 48717b55..57a70e09 100644 --- a/dox/internals.dox +++ b/dox/internals.dox @@ -19,7 +19,7 @@ namespace Grantlee Plugins can return Filters as well as AbstractNodeFactories. Filters can manipulate Variables in some way before rendering them to the output. - Loading templates to include or extend is accomplished using the load{Mutable,}ByName methods. The secondary template should use the same state as the initially created/loaded template, so that it uses the same template loaders, has the same plugins available by default and uses the same search directories to find additional plugins. + Loading templates to include or extend is accomplished using the loadByName methods. The secondary template should use the same state as the initially created/loaded template, so that it uses the same template loaders, has the same plugins available by default and uses the same search directories to find additional plugins. */ diff --git a/examples/dbus-chat/CMakeLists.txt b/examples/dbus-chat/CMakeLists.txt deleted file mode 100644 index 49240cea..00000000 --- a/examples/dbus-chat/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -project(dbus_chat_grantlee) - -cmake_minimum_required(VERSION 2.6) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/ ) - -find_package(Qt4 REQUIRED) -find_package(Automoc4 REQUIRED) -find_package(Grantlee REQUIRED) - - -add_definitions(${QT_DEFINITIONS}) -add_definitions(-DQT_GUI_LIB) - -include_directories( - ${QT_INCLUDES} - ${QT_QTGUI_INCLUDE_DIR} - ${Grantlee_INCLUDE_DIR} - ${PROJECT_BINARY_DIR} -) - -configure_file(grantlee_paths.h.cmake ${PROJECT_BINARY_DIR}/grantlee_paths.h) - -set(dbus_chat_example_SRCS - chat.cpp - chatitem.cpp - chat_adaptor.cpp - chat_interface.cpp -) - -set(dbus_chat_example_UI - chatmainwindow.ui - chatsetnickname.ui -) - -QT4_WRAP_UI(dbus_chat_example_UI_SRCS - ${dbus_chat_example_UI} -) - -automoc4_add_executable(dbus_chat - ${dbus_chat_example_SRCS} - ${dbus_chat_example_UI_SRCS} -) - -target_link_libraries( - dbus_chat - ${QT_QTCORE_LIBRARIES} - ${QT_QTGUI_LIBRARIES} - ${QT_QTDBUS_LIBRARIES} - ${Grantlee_LIBRARY} -) - - - diff --git a/examples/dbus-chat/chat.cpp b/examples/dbus-chat/chat.cpp deleted file mode 100644 index e877f306..00000000 --- a/examples/dbus-chat/chat.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// krazy:excludeall=qclasses - -#include "chat.h" -#include -#include -#include - -#include -#include - -#include "chat_adaptor.h" -#include "chat_interface.h" -#include "chatitem.h" -#include "grantlee_paths.h" - -ChatMainWindow::ChatMainWindow() - : m_nickname(QLatin1String("nickname")) -{ - m_availableColours << "#000066" << "#009966" << "#0000FF" << "#00CCFF" << "#FF0000"; - setupUi(this); - sendButton->setEnabled(false); - - connect(messageLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(textChangedSlot(QString))); - connect(sendButton, SIGNAL(clicked(bool)), this, SLOT(sendClickedSlot())); - connect(actionChangeNickname, SIGNAL(triggered(bool)), this, SLOT(changeNickname())); - connect(actionAboutQt, SIGNAL(triggered(bool)), this, SLOT(aboutQt())); - connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(exiting())); - - // add our D-Bus interface and connect to D-Bus - new ChatAdaptor(this); - QDBusConnection::sessionBus().registerObject("/", this); - - com::trolltech::chat *iface; - iface = new com::trolltech::chat(QString(), QString(), QDBusConnection::sessionBus(), this); - //connect(iface, SIGNAL(message(QString,QString)), this, SLOT(messageSlot(QString,QString))); - QDBusConnection::sessionBus().connect(QString(), QString(), "com.trolltech.chat", "message", this, SLOT(messageSlot(QString,QString))); - connect(iface, SIGNAL(action(QString,QString)), this, SLOT(actionSlot(QString,QString))); - - NicknameDialog dialog; - dialog.cancelButton->setVisible(false); - dialog.exec(); - m_nickname = dialog.nickname->text().trimmed(); - - themeChooser->insertItems(0, QStringList() << "plain" << "colored" << "boxes"); - connect(themeChooser, SIGNAL(activated(const QString &)), SLOT(changeTheme(const QString &))); - - m_engine = Grantlee::Engine::instance(); - - Grantlee::FileSystemTemplateLoader::Ptr loader = Grantlee::FileSystemTemplateLoader::Ptr( new Grantlee::FileSystemTemplateLoader() ); - loader->setTemplateDirs(QStringList() << GRANTLEE_TEMPLATE_PATH ); - m_engine->addTemplateLoader(loader); - m_engine->setPluginPaths(QStringList() << GRANTLEE_PLUGIN_PATH ); - - m_engine->addDefaultLibrary( "grantlee_mutabletags_library" ); - - changeTheme("plain"); - - emit action(m_nickname, QLatin1String("joins the chat")); -} - -ChatMainWindow::~ChatMainWindow() -{ - delete m_engine; -} - -void ChatMainWindow::addColour(const QString &nickname, const QString &colour) -{ - QVariantHash h; - QVariantList nameColours; - QVariantList innerPair; - innerPair << nickname << colour; - nameColours.append(QVariant(innerPair)); - m_nameColours.insert( nickname, QVariant(innerPair)); - - h.insert("name_colours", nameColours); - Grantlee::Context c(h); - QString content = m_template->render(&c); -} - -void ChatMainWindow::addItem(ChatItem *item) -{ - QVariantHash h; - QVariant chatVariant = QVariant::fromValue(static_cast(item)); - m_chatItems.append(chatVariant); - h.insert("chat_items", QVariantList() << chatVariant); - Grantlee::Context c(h); - QString content = m_template->render(&c); - chatHistory->setHtml(content); - QScrollBar *sb = chatHistory->verticalScrollBar(); - sb->setValue(sb->maximum()); -} - -void ChatMainWindow::rebuildHistory() -{ - QVariantHash h; - h.insert("chat_items", m_chatItems); - h.insert("mynickname", m_nickname); - h.insert("name_colours", m_nameColours.values()); - Grantlee::Context c(h); - QString content = m_template->render(&c); - chatHistory->setHtml(content); - QScrollBar *sb = chatHistory->verticalScrollBar(); - sb->setValue(sb->maximum()); -} - -void ChatMainWindow::messageSlot(const QString &nickname, const QString &text) -{ - if (!m_nameColours.contains(nickname)) - { - QString colour = m_availableColours.at(qrand() % m_availableColours.size()); - addColour(nickname, colour); - } - - ChatItem *message = new ChatItem(nickname, text, ChatItem::Message, this); - addItem(message); -} - -void ChatMainWindow::actionSlot(const QString &nickname, const QString &text) -{ - ChatItem *message = new ChatItem(nickname, text, ChatItem::Action, this); - addItem(message); -} - -void ChatMainWindow::textChangedSlot(const QString &newText) -{ - sendButton->setEnabled(!newText.isEmpty()); -} - -void ChatMainWindow::sendClickedSlot() -{ - QString content = messageLineEdit->text(); - if (content.startsWith(QLatin1String("/me "))) - { - content.remove(0, 4); - action(m_nickname, content); - } else { - //emit message(m_nickname, messageLineEdit->text()); - QDBusMessage msg = QDBusMessage::createSignal("/", "com.trolltech.chat", "message"); - msg << m_nickname << content; - QDBusConnection::sessionBus().send(msg); - } - messageLineEdit->setText(QString()); -} - -void ChatMainWindow::changeNickname() -{ - NicknameDialog dialog(this); - if (dialog.exec() == QDialog::Accepted) { - QString old = m_nickname; - m_nickname = dialog.nickname->text().trimmed(); - emit action(old, QString("is now known as %1").arg(m_nickname)); - } -} - -void ChatMainWindow::changeTheme(const QString &themeName) -{ - m_template = m_engine->loadMutableByName(themeName + ".html"); - rebuildHistory(); -} - -void ChatMainWindow::aboutQt() -{ - QMessageBox::aboutQt(this); -} - -void ChatMainWindow::exiting() -{ - emit action(m_nickname, QLatin1String("leaves the chat")); -} - -NicknameDialog::NicknameDialog(QWidget *parent) - : QDialog(parent) -{ - setupUi(this); -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - if (!QDBusConnection::sessionBus().isConnected()) { - qWarning("Cannot connect to the D-Bus session bus.\n" - "Please check your system settings and try again.\n"); - return 1; - } - - ChatMainWindow chat; - chat.show(); - return app.exec(); -} diff --git a/examples/dbus-chat/chat.h b/examples/dbus-chat/chat.h deleted file mode 100644 index e5f2f17a..00000000 --- a/examples/dbus-chat/chat.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHAT_H -#define CHAT_H - -#include -#include -#include "ui_chatmainwindow.h" -#include "ui_chatsetnickname.h" - -#include - -class ChatItem; - -namespace Grantlee -{ -class Engine; -} - -class ChatMainWindow: public QMainWindow, Ui::ChatMainWindow -{ - Q_OBJECT - QString m_nickname; - QStringList m_messages; - QVariantList m_chatItems; - QVariantHash m_nameColours; - QStringList m_availableColours; - Grantlee::MutableTemplate m_template; -public: - ChatMainWindow(); - ~ChatMainWindow(); - - void rebuildHistory(); - void addItem(ChatItem *item); - void addColour(const QString &nickname, const QString &colour); - -Q_SIGNALS: - void message(const QString &nickname, const QString &text); - void action(const QString &nickname, const QString &text); - -private Q_SLOTS: - void messageSlot(const QString &nickname, const QString &text); - void actionSlot(const QString &nickname, const QString &text); - void textChangedSlot(const QString &newText); - void sendClickedSlot(); - void changeNickname(); - void changeTheme(const QString &themeName); - void aboutQt(); - void exiting(); - -private: - Grantlee::Engine *m_engine; -}; - -class NicknameDialog: public QDialog, public Ui::NicknameDialog -{ - Q_OBJECT -public: - NicknameDialog(QWidget *parent = 0); -}; - -#endif diff --git a/examples/dbus-chat/chat_adaptor.cpp b/examples/dbus-chat/chat_adaptor.cpp deleted file mode 100644 index 4292a58d..00000000 --- a/examples/dbus-chat/chat_adaptor.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file was generated by dbusxml2cpp version 0.6 - * Command line was: dbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml - * - * dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#include "chat_adaptor.h" -#include -#include -#include -#include -#include -#include -#include - -/* - * Implementation of adaptor class ChatAdaptor - */ - -ChatAdaptor::ChatAdaptor(QObject *parent) - : QDBusAbstractAdaptor(parent) -{ - // constructor - setAutoRelaySignals(true); -} - -ChatAdaptor::~ChatAdaptor() -{ - // destructor -} - diff --git a/examples/dbus-chat/chat_adaptor.h b/examples/dbus-chat/chat_adaptor.h deleted file mode 100644 index 9d8e7a6d..00000000 --- a/examples/dbus-chat/chat_adaptor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file was generated by dbusxml2cpp version 0.6 - * Command line was: dbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml - * - * dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#ifndef CHAT_ADAPTOR_H_142741156243605 -#define CHAT_ADAPTOR_H_142741156243605 - -#include -#include - -QT_BEGIN_NAMESPACE -class QByteArray; -template class QList; -template class QMap; -class QString; -class QStringList; -class QVariant; -QT_END_NAMESPACE - -/* - * Adaptor class for interface com.trolltech.chat - */ -class ChatAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.trolltech.chat") - Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" - "") -public: - ChatAdaptor(QObject *parent); - virtual ~ChatAdaptor(); - -public: // PROPERTIES -public Q_SLOTS: // METHODS -Q_SIGNALS: // SIGNALS - void action(const QString &nickname, const QString &text); - void message(const QString &nickname, const QString &text); -}; - -#endif diff --git a/examples/dbus-chat/chat_interface.cpp b/examples/dbus-chat/chat_interface.cpp deleted file mode 100644 index 5e2d2a72..00000000 --- a/examples/dbus-chat/chat_interface.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file was generated by dbusxml2cpp version 0.6 - * Command line was: dbusxml2cpp -i chat_interface.h -p :chat_interface.cpp chat/com.trolltech.chat.xml - * - * dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "chat_interface.h" -/* - * Implementation of interface class ComTrolltechChatInterface - */ - -ComTrolltechChatInterface::ComTrolltechChatInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -ComTrolltechChatInterface::~ComTrolltechChatInterface() -{ -} - diff --git a/examples/dbus-chat/chat_interface.h b/examples/dbus-chat/chat_interface.h deleted file mode 100644 index 75140cc2..00000000 --- a/examples/dbus-chat/chat_interface.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file was generated by dbusxml2cpp version 0.6 - * Command line was: dbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml - * - * dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef CHAT_INTERFACE_H_143021156243606 -#define CHAT_INTERFACE_H_143021156243606 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Proxy class for interface com.trolltech.chat - */ -class ComTrolltechChatInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.trolltech.chat"; } - -public: - ComTrolltechChatInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~ComTrolltechChatInterface(); - -public Q_SLOTS: // METHODS -Q_SIGNALS: // SIGNALS - void action(const QString &nickname, const QString &text); - void message(const QString &nickname, const QString &text); -}; - -namespace com { - namespace trolltech { - typedef ::ComTrolltechChatInterface chat; - } -} -#endif diff --git a/examples/dbus-chat/chatitem.cpp b/examples/dbus-chat/chatitem.cpp deleted file mode 100644 index 3aef6bf6..00000000 --- a/examples/dbus-chat/chatitem.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of the Grantlee template system. - - Copyright (c) 2009 Stephen Kelly - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License version 3 only, as published by the Free Software Foundation. - - 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 - Lesser General Public License version 3 for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "chatitem.h" - -ChatItem::ChatItem(const QString &sender, const QString &content, Type type, QObject *parent) - : QObject(parent), m_sender(sender), m_content(content), m_type(type) -{ - -} - -QString ChatItem::sender() const -{ - return m_sender; -} - -QString ChatItem::content() const -{ - return m_content; -} - -bool ChatItem::isMessage() const -{ - return m_type == Message; -} - -bool ChatItem::isAction() const -{ - return m_type == Action; -} - diff --git a/examples/dbus-chat/chatitem.h b/examples/dbus-chat/chatitem.h deleted file mode 100644 index fafcd76c..00000000 --- a/examples/dbus-chat/chatitem.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of the Grantlee template system. - - Copyright (c) 2009 Stephen Kelly - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License version 3 only, as published by the Free Software Foundation. - - 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 - Lesser General Public License version 3 for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef CHATITEM_H -#define CHATITEM_H - -#include - -class ChatItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString sender READ sender) - Q_PROPERTY(QString content READ content) - Q_PROPERTY(bool is_message READ isMessage) - Q_PROPERTY(bool is_action READ isAction) -public: - enum Type { - Message, - Action - }; - - ChatItem(const QString &sender, const QString &content, Type type, QObject *parent = 0); - - QString sender() const; - QString content() const; - bool isMessage() const; - bool isAction() const; - -private: - QString m_sender; - QString m_content; - Type m_type; -}; - - - -#endif diff --git a/examples/dbus-chat/chatmainwindow.ui b/examples/dbus-chat/chatmainwindow.ui deleted file mode 100644 index ac273362..00000000 --- a/examples/dbus-chat/chatmainwindow.ui +++ /dev/null @@ -1,192 +0,0 @@ - - - - - ChatMainWindow - - - - 0 - 0 - 800 - 600 - - - - QtDBus Chat - - - - - 9 - - - 6 - - - - - 0 - - - 6 - - - - - true - - - - - - - false - - - Messages sent and received from other users - - - true - - - - - - - 0 - - - 6 - - - - - Message: - - - messageLineEdit - - - - - - - - - - - 1 - 0 - 0 - 0 - - - - Sends a message to other people - - - - - - Send - - - - - - - - - - - - - 0 - 0 - 800 - 31 - - - - - Help - - - - - - File - - - - - - - - - - - - Quit - - - Ctrl+Q - - - - - About Qt... - - - - - Change nickname... - - - Ctrl+N - - - - - - chatHistory - messageLineEdit - sendButton - - - - - messageLineEdit - returnPressed() - sendButton - animateClick() - - - 299 - 554 - - - 744 - 551 - - - - - actionQuit - triggered(bool) - ChatMainWindow - close() - - - -1 - -1 - - - 399 - 299 - - - - - diff --git a/examples/dbus-chat/chatsetnickname.ui b/examples/dbus-chat/chatsetnickname.ui deleted file mode 100644 index fb9894e0..00000000 --- a/examples/dbus-chat/chatsetnickname.ui +++ /dev/null @@ -1,149 +0,0 @@ - - - - - NicknameDialog - - - - 0 - 0 - 396 - 105 - - - - - 1 - 1 - 0 - 0 - - - - Set nickname - - - - 9 - - - 6 - - - - - 0 - - - 6 - - - - - - 1 - 1 - 0 - 0 - - - - New nickname: - - - - - - - - - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 131 - 31 - - - - - - - - OK - - - - - - - Cancel - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - okButton - clicked() - NicknameDialog - accept() - - - 278 - 253 - - - 96 - 254 - - - - - cancelButton - clicked() - NicknameDialog - reject() - - - 369 - 253 - - - 179 - 282 - - - - - diff --git a/examples/dbus-chat/com.trolltech.chat.xml b/examples/dbus-chat/com.trolltech.chat.xml deleted file mode 100644 index 618c8c4d..00000000 --- a/examples/dbus-chat/com.trolltech.chat.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/dbus-chat/dbus-chat.pro b/examples/dbus-chat/dbus-chat.pro deleted file mode 100644 index a0940488..00000000 --- a/examples/dbus-chat/dbus-chat.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -CONFIG += qdbus - -# Input -HEADERS += chat.h chat_adaptor.h chat_interface.h -SOURCES += chat.cpp chat_adaptor.cpp chat_interface.cpp -FORMS += chatmainwindow.ui chatsetnickname.ui - -#DBUS_ADAPTORS += com.trolltech.chat.xml -#DBUS_INTERFACES += com.trolltech.chat.xml - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/dbus/chat -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xml -sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/chat -INSTALLS += target sources diff --git a/examples/dbus-chat/grantlee_paths.h.cmake b/examples/dbus-chat/grantlee_paths.h.cmake deleted file mode 100644 index 1d21e0fd..00000000 --- a/examples/dbus-chat/grantlee_paths.h.cmake +++ /dev/null @@ -1,3 +0,0 @@ -#define GRANTLEE_PLUGIN_PATH "@Grantlee_PLUGIN_PATH@" -#define GRANTLEE_TEMPLATE_PATH "@PROJECT_SOURCE_DIR@/themes" - diff --git a/examples/dbus-chat/themes/boxes.html b/examples/dbus-chat/themes/boxes.html deleted file mode 100644 index e6a37f29..00000000 --- a/examples/dbus-chat/themes/boxes.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - -

{{ mynickname }} - Chat History

- - -
-{% repeater %} - {% for chat_item in chat_items %} - {% if chat_item.is_message %} -{# The cycle tag makes the background colour of the content field change each iteration #} - - - - {% else %}{% if chat_item.is_action %} -
{{ chat_item.sender }}
{{ chat_item.content }}
- - - {% endif %}{% endif %} -
{{ chat_item.sender }}
*** {{ chat_item.content }}
-
- {% endfor %} -{% endrepeater %} -
- - - \ No newline at end of file diff --git a/examples/dbus-chat/themes/colored.html b/examples/dbus-chat/themes/colored.html deleted file mode 100644 index 70b01818..00000000 --- a/examples/dbus-chat/themes/colored.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - -

{{ mynickname }} - Chat History

- -
-{% repeater %} - {% for chat_item in chat_items %} - {% if chat_item.is_message %} -

<{{ chat_item.sender }}> {{ chat_item.content }}

- {% else %}{% if chat_item.is_action %} -

*** {{ chat_item.sender }} {{ chat_item.content }}

- {% endif %}{% endif %} - {% endfor %} -{% endrepeater %} -
- diff --git a/examples/dbus-chat/themes/plain.html b/examples/dbus-chat/themes/plain.html deleted file mode 100644 index bd90812c..00000000 --- a/examples/dbus-chat/themes/plain.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - -

{{ mynickname }} - Chat History

- -
-{% repeater %} - {% for chat_item in chat_items %} - {% if chat_item.is_message %} -

<{{ chat_item.sender }}> {{ chat_item.content }}

- {% else %}{% if chat_item.is_action %} -

*** {{ chat_item.sender }} {{ chat_item.content }}

- {% endif %}{% endif %} - {% endfor %} -{% endrepeater %} -
- \ No newline at end of file diff --git a/loadertags/extends.cpp b/loadertags/extends.cpp index 9baa84ac..6485451f 100644 --- a/loadertags/extends.cpp +++ b/loadertags/extends.cpp @@ -105,10 +105,6 @@ Template ExtendsNode::getParent( Context *c ) return parentTemplate; } - if ( parentVar.userType() == qMetaTypeId() ) { - Template parentTemplate = parentVar.value