diff options
| author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 | 
|---|---|---|
| committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 | 
| commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
| tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/core/kexiuseraction.cpp | |
| download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip | |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/core/kexiuseraction.cpp')
| -rw-r--r-- | kexi/core/kexiuseraction.cpp | 108 | 
1 files changed, 108 insertions, 0 deletions
| diff --git a/kexi/core/kexiuseraction.cpp b/kexi/core/kexiuseraction.cpp new file mode 100644 index 000000000..eb521de54 --- /dev/null +++ b/kexi/core/kexiuseraction.cpp @@ -0,0 +1,108 @@ +#include <kmessagebox.h> +#include <kdebug.h> +#include <kshortcut.h> + +#include <kexidb/cursor.h> + +#include "kexipart.h" +#include "kexipartmanager.h" + +#include "kexiproject.h" +#include "keximainwindow.h" +#include "kexiuseraction.h" + +KexiUserAction::KexiUserAction(KexiMainWindow *win, KActionCollection *parent, const QString &name, const QString &text, const QString &pixmap) + : KAction(text, pixmap, KShortcut::null(), this, SLOT(execute()), parent, name.latin1()) +{ +	m_win = win; +	m_method = 0; +	connect(this, SIGNAL(activated()), this, SLOT(execute())); +} + +void +KexiUserAction::setMethod(int method, Arguments args) +{ +	m_method = method; +	m_args = args; +} + +void +KexiUserAction::execute() +{ +	kdDebug() << "KexiUserAction::execute(): " << KexiUserActionMethod::methodName(m_method) << endl; + +	switch(m_method) +	{ +		case OpenObject: //open a project object +		{ +			//get partinfo +			KexiPart::Info *i = Kexi::partManager().infoForMimeType(m_args[0].toString().latin1()); +			if (!i) { +				KMessageBox::error(m_win, i18n("Specified part does not exist")); +				return; +			} + +			Kexi::partManager().part(i); //load part if doesn't exists +			KexiPart::Item *item = m_win->project()->item(i, m_args[1].toString()); +			bool openingCancelled; +			if(!m_win->openObject(item, Kexi::DataViewMode, openingCancelled) && !openingCancelled) { +				KMessageBox::error(m_win, i18n("Specified document could not be opened.")); +				return; +			} +			if (openingCancelled) +				return; +			break; +		}	 +		default: +			break; +	} +} + +KexiUserAction * +KexiUserAction::fromCurrentRecord(KexiMainWindow *context, KActionCollection *parent, KexiDB::Cursor *c) +{ +	if(!c || c->bof() || c->eof()) +		return 0; + +	KexiUserAction *a = new KexiUserAction(context, parent, c->value(1).toString(), c->value(2).toString(), c->value(3).toString()); +	QString args = c->value(5).toString(); +	bool quote = false; + +	Arguments arg; +	QString tmp; +	const int len = args.length(); +	for(int i=0; i < len; i++) +	{ +		if(args[i] == '"') // if current char is quoted unqote or other way round +		{ +			quote = !quote; +		} +		else if(args[i] == ',' && !quote) //if item end add tmp to argumentstack and strip quotes if nessesery +		{ +			if(tmp.left(1)=="\"" && tmp.right(1)=="\"") +				tmp = tmp.mid(1, tmp.length()-2); + +			arg.append(QVariant(tmp)); +			tmp = ""; +		} +		else //else simply add char to tmp +		{ +			tmp += args[i]; +		} +	} + +	if(tmp.left(1)=="\"" && tmp.right(1)=="\"") +		tmp = tmp.mid(1, tmp.length()-2); + +	arg.append(QVariant(tmp)); + +	a->setMethod(c->value(4).toInt(), arg); +	return a; +} + +KexiUserAction::~KexiUserAction() +{ +} + +#include "kexiuseraction.moc" + | 
