void createFolder(QString name) void createFolder(QString name,QString parent) void addUrl(KURL url,QString parent) void addUrls(KURL::List urls,QString parent) void removeItem(QString path) void renameItem(QString path,QString newName) void setVolumeID(QString id) bool isFolder(QString path) QStringList children(QString path)
Using this interface it is possible to fill a data project with files and folders from a script
or determine the contents of a data projects.
The following script for example creates a new data project,
adds several folders to the project, and adds files to the newly
created folders:
#!/bin/bash PROJECT=$(dcop k3b K3bInterface createDataCDProject) dcop $PROJECT createFolder test dcop $PROJECT createFolder foo dcop $PROJECT createFolder bar /foo dcop $PROJECT addUrl /home/trueg/somefile.txt /foo/bar
To do the same thing when it is unknown if K3b is running or not we can use the power of
KUniqueApplication and simply start K3b:
k3b --datacd PROJECT=$(dcop k3b K3bInterface currentProject)
When using the K3bInterface in C++ code KApplication
provides a nice way to make sure K3b is running:
// start the process and block until it returnes // one may also test the return value on success KApplication::startServiceByDesktopName( "k3b" );
// now use DCOP to do the stuff (the tricky part) QByteArray replyData; QCString replyType; KApplication::dcopClient()->call( "k3b", "K3bInterface", "currentProject", QByteArray(), replyType, replyData, false, -1 ); QDataStream reply( replyData, IO_ReadOnly ); DCOPRef ref; reply >> ref;
// now we can simply use the DCOPRef (the easy part) ref.call( "createFolder", QString("test") );
|