1
#include <KActionCollection>
2
#include <kmessagebox.h>
6
#include <kexidb/cursor.h>
9
#include "kexipartmanager.h"
11
#include "kexiproject.h"
12
#include "keximainwindow.h"
13
#include "kexiuseraction.h"
15
KexiUserAction::KexiUserAction(KActionCollection *parent, const QString &name, const QString &text, const QString &pixmap)
16
: KAction(KIcon(pixmap), text, parent)
20
connect(this, SIGNAL(triggered()), this, SLOT(execute()));
24
KexiUserAction::setMethod(int method, Arguments args)
31
KexiUserAction::execute()
33
kDebug() << "KexiUserAction::execute(): " << KexiUserActionMethod::methodName(m_method);
36
case OpenObject: { //open a project object
38
KexiPart::Info *i = Kexi::partManager().infoForMimeType(m_args[0].toString().toLatin1());
40
KMessageBox::error(KexiMainWindow::global()->thisWidget(), i18n("Specified part does not exist"));
44
Kexi::partManager().part(i); //load part if doesn't exists
45
KexiPart::Item *item = KexiMainWindow::global()->project()->item(i, m_args[1].toString());
46
bool openingCancelled;
47
if (!KexiMainWindow::global()->openObject(item, Kexi::DataViewMode, openingCancelled)
48
&& !openingCancelled) {
49
KMessageBox::error(KexiMainWindow::global()->thisWidget(), i18n("Specified document could not be opened."));
62
KexiUserAction::fromCurrentRecord(KActionCollection *parent, KexiDB::Cursor *c)
64
if (!c || c->bof() || c->eof())
67
KexiUserAction *a = new KexiUserAction(parent,
68
c->value(1).toString(), c->value(2).toString(), c->value(3).toString());
69
QString args = c->value(5).toString();
74
const int len = args.length();
75
for (int i = 0; i < len; i++) {
76
if (args[i] == '"') { // if current char is quoted unqote or other way round
78
} else if (args[i] == ',' && !quote) { //if item end add tmp to argumentstack and strip quotes if nessesery
79
if (tmp.left(1) == "\"" && tmp.right(1) == "\"")
80
tmp = tmp.mid(1, tmp.length() - 2);
82
arg.append(QVariant(tmp));
84
} else { //else simply add char to tmp
89
if (tmp.left(1) == "\"" && tmp.right(1) == "\"")
90
tmp = tmp.mid(1, tmp.length() - 2);
92
arg.append(QVariant(tmp));
94
a->setMethod(c->value(4).toInt(), arg);
98
KexiUserAction::~KexiUserAction()
102
#include "kexiuseraction.moc"