[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: make_it_cool: kdeedu/kig/kig
From: Dominique Devriese <devriese () kde ! org>
Date: 2003-03-23 0:26:14
[Download RAW message or body]
CVS commit by domi:
fix some small bugs, remove unneccessary code
M +14 -11 kig_commands.cpp 1.7.2.7
M +6 -1 kig_commands.h 1.6.2.1
M +7 -3 kig_part.cpp 1.98.2.32
--- kdeedu/kig/kig/kig_commands.cpp #1.7.2.6:1.7.2.7
@@ -27,9 +27,17 @@
#include "../objects/object_imp.h"
+static int countRealObjects( const Objects& os )
+{
+ int ret = 0;
+ for ( Objects::const_iterator i = os.begin(); i != os.end(); ++i )
+ if ( !(*i)->isInternal() ) ++ret;
+ return ret;
+};
+
AddObjectsCommand::AddObjectsCommand(KigDocument* inDoc, const Objects& inOs)
: KigCommand( inDoc,
- inOs.size() == 1 ?
- ObjectImp::addAStatement( inOs.front()->imp()->id() ) :
- i18n( "Add %1 objects" ).arg( os.size() ) ),
+ countRealObjects( inOs ) == 1 ?
+ ObjectImp::addAStatement( inOs.back()->imp()->id() ) :
+ i18n( "Add %1 objects" ).arg( countRealObjects( inOs ) ) ),
undone(true),
os (inOs)
@@ -100,15 +108,10 @@ AddObjectsCommand::~AddObjectsCommand()
RemoveObjectsCommand::RemoveObjectsCommand(KigDocument* inDoc, const Objects& inOs)
: KigCommand(inDoc,
- inOs.size() == 1 ?
- ObjectImp::removeAStatement( inOs.front()->imp()->id() ) :
- i18n( "Remove %1 objects" ).arg( inOs.size()) ),
+ countRealObjects( inOs ) == 1 ?
+ ObjectImp::removeAStatement( inOs.back()->imp()->id() ) :
+ i18n( "Remove %1 objects" ).arg( countRealObjects( inOs ) ) ),
undone( false ),
os( inOs )
{
- Objects children;
- // we delete the children too
- for (Objects::iterator i = os.begin(); i != os.end(); ++i )
- children |= (*i)->children();
- os |= children;
}
--- kdeedu/kig/kig/kig_commands.h #1.6:1.6.2.1
@@ -61,4 +61,9 @@ class RemoveObjectsCommand
Q_OBJECT
public:
+ /**
+ * make sure that when you delete something, you are also deleting
+ * its parents. This class assumes you've done that.
+ * KigDocument::delObjects takes care of this for you.
+ */
RemoveObjectsCommand(KigDocument* inDoc, const Objects& o);
RemoveObjectsCommand( KigDocument* inDoc, Object* o );
--- kdeedu/kig/kig/kig_part.cpp #1.98.2.31:1.98.2.32
@@ -483,8 +483,12 @@ KCommandHistory* KigDocument::history()
void KigDocument::delObjects( const Objects& os )
{
- Objects dos;
- dos = os;
+ Objects tos;
+ tos = os;
for ( Objects::const_iterator i = os.begin(); i != os.end(); ++i )
- dos.upush( (*i)->getAllChildren() );
+ tos.upush( (*i)->getAllChildren() );
+ Objects dos = os;
+ for ( Objects::iterator i = tos.begin(); i != tos.end(); ++i )
+ if ( mObjs.contains( *i ) )
+ dos.upush( *i );
if ( dos.empty() ) return;
mhistory->addCommand( new RemoveObjectsCommand( this, dos ) );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic