[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdegraphics/kpovmodeler
From: Leon Pennington <leon () leonscape ! co ! uk>
Date: 2004-07-13 18:20:02
Message-ID: 20040713182002.D522A16AF6 () office ! kde ! org
[Download RAW message or body]
CVS commit by leonp:
Improved drap n drop, fixed nameclash bug.
M +70 -30 pmlibraryiconview.cpp 1.9
M +2 -0 pmlibraryiconview.h 1.8
--- kdegraphics/kpovmodeler/pmlibraryiconview.cpp #1.8:1.9
@@ -19,4 +19,6 @@
#include "pmlibraryiconview.h"
+#include <unistd.h>
+
#include <qstring.h>
#include <qdir.h>
@@ -222,18 +224,26 @@ void PMLibraryIconViewItem::dropped( QDr
PMLibraryHandle* parentLib = source->library( );
PMLibraryHandle newParentLib = PMLibraryHandle( m_path );
+ if ( parentLib->isReadOnly() || newParentLib.isReadOnly() )
+ {
+ e->ignore();
+ return;
+ }
+
for( unsigned i = 0; i < pathList.count( ); ++i )
{
bool success = true;
QString path = pathList[i];
+ if( path != ( m_path +"/" + path.section( '/', -1 ) ) )
+ {
if( subLibList[i] )
{
+ QString newpath = newPath( path, true );
if( parentLib->deleteSubLibrary( path ) == PMLibraryHandle::Ok )
{
PMLibraryHandle lib = PMLibraryHandle( path );
- if( newParentLib.addSubLibrary( m_path + "/" + path.section( '/', -1 ),
- lib.name() ) == PMLibraryHandle::Ok )
+ if( newParentLib.addSubLibrary( newpath, lib.name() ) == PMLibraryHandle::Ok )
{
lib.changeParentLibrary( m_path );
- KIO::move( path, m_path );
+ KIO::move( path, newpath );
}
else
@@ -248,11 +258,11 @@ void PMLibraryIconViewItem::dropped( QDr
else
{
+ QString newpath = newPath( path, false );
if( parentLib->deleteObject( path ) == PMLibraryHandle::Ok )
{
PMLibraryObject obj = PMLibraryObject( path );
- if( newParentLib.addObject( m_path + "/" + path.section( '/', -1 ),
- obj.name() ) == PMLibraryHandle::Ok )
+ if( newParentLib.addObject( newpath, obj.name() ) == PMLibraryHandle::Ok )
{
- KIO::move( path, m_path );
+ KIO::move( path, newpath );
}
else
@@ -273,4 +283,5 @@ void PMLibraryIconViewItem::dropped( QDr
}
}
+ }
e->acceptAction( );
source->refresh( );
@@ -282,3 +293,32 @@ void PMLibraryIconViewItem::dropped( QDr
}
+QString PMLibraryIconViewItem::newPath( const QString oldPath, bool subLib )
+{
+ QString path = m_path + "/" + oldPath.section( '/', -1 );
+ if( subLib )
+ path += "/library_index.xml";
+ if( QFile::exists( path ) )
+ {
+ // we need to rename it.
+ QCString s = m_path.latin1();
+ if( subLib )
+ {
+ s += "/libXXXXXX";
+ char* dirname = mkdtemp( s.data() );
+ rmdir( dirname );
+ path = dirname;
+ }
+ else
+ {
+ s += "/objXXXXXX.kpml";
+ int fh = mkstemps( s.data( ), 5 );
+ close( fh );
+ unlink( s.data() );
+ path = s;
+ }
+ }
+
+ return path;
+}
+
#include "pmlibraryiconview.moc"
--- kdegraphics/kpovmodeler/pmlibraryiconview.h #1.7:1.8
@@ -113,4 +113,6 @@ protected:
/** Tokes a dropped item */
void dropped( QDropEvent *evt, const QValueList<QIconDragItem>& );
+ /** Checks for the existance of oldpath and generates a new path as required */
+ QString newPath( const QString oldPath, bool subLib );
private:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic