:QDialog(parent, f),m_parent(parent)
{
setWindowTitle(tr("Wizard"));
+
+ m_top=m_bottom=m_left=m_right=0;
+
//main layout
QVBoxLayout*vl;
- QHBoxLayout*hl;
- setLayout(vl=new QVBoxLayout);
- vl->addLayout(m_stack=new QStackedLayout,1);
- //bottom buttons
- vl->addLayout(hl=new QHBoxLayout);
- hl->addStretch(1);
- QPushButton*p;
- hl->addWidget(p=new QPushButton(tr("Start Over")));
- connect(p,SIGNAL(clicked()),this,SLOT(gotoStart()));
- hl->addWidget(p=new QPushButton(tr("Close Wizard")));
- connect(p,SIGNAL(clicked()),this,SLOT(accept()));
- hl->addWidget(p=new QPushButton(tr("Exit")));
- connect(p,SIGNAL(clicked()),this,SLOT(accept()));
- connect(p,SIGNAL(clicked()),parent,SLOT(close()));
+ setLayout(m_mainlayout=new QGridLayout);
+ m_mainlayout->addLayout(m_stack=new QStackedLayout,1,1);
+ m_mainlayout->setColumnStretch(1,1);
+ m_mainlayout->setRowStretch(1,1);
+ QMargins mrg=m_stack->contentsMargins();
+ m_mainlayout->setContentsMargins(0,0,0,0);
+ m_stack->setContentsMargins(mrg);
//page: start
QWidget*w;
{
return m_stack->widget(pg);
}
+
+void MWizard::setBottomWidget(QWidget* w)
+{
+ if(m_bottom)delete m_bottom;
+ m_mainlayout->addWidget(m_bottom=w,2,0,1,3);
+}
+
+void MWizard::setTopWidget(QWidget* w)
+{
+ if(m_top)delete m_top;
+ m_mainlayout->addWidget(m_top=w,0,0,1,3);
+}
+
+void MWizard::setLeftWidget(QWidget* w)
+{
+ if(m_left)delete m_left;
+ m_mainlayout->addWidget(m_left=w,1,0);
+}
+
+void MWizard::setRightWidget(QWidget* w)
+{
+ if(m_right)delete m_right;
+ m_mainlayout->addWidget(m_right=w,1,2);
+}
#include <QDialog>
+class QGridLayout;
class QSignalMapper;
class QVBoxLayout;
class QStackedLayout;
void gotoPage(int);
QWidget* pageWidget(int);
QPushButton* modeButton(int);
+ void setTopWidget(QWidget*);
+ void setBottomWidget(QWidget*);
+ void setRightWidget(QWidget*);
+ void setLeftWidget(QWidget*);
private:
MOverview*m_parent;
MScriptEngine*m_jseng;
QStackedLayout*m_stack;
QVBoxLayout*m_modelayout;
+ QGridLayout*m_mainlayout;
QSignalMapper*m_modemap;
+ QWidget*m_top,*m_bottom,*m_left,*m_right;
int m_startid;
};
Right x=stringToRight(rsl[i]);
if(x!=NoRight)userrights<<x;
}
+ userflags=mrt.getflag();
//get roles
MTGetMyRoles mrl=MTGetMyRoles::query();
userroles=mrl.getrole();
static MSInterface* instance(){return qobject_cast<MSInterface*>(MInterface::instance());}
/**returns the name of the current user*/
- QString currentUser()const{return m_uname;}
+ Q_INVOKABLE QString currentUser()const{return m_uname;}
/**returns the name used for the host in this session*/
- QString hostName()const{return m_host;}
+ Q_INVOKABLE QString hostName()const{return m_host;}
/**returns whether the user is part of this role*/
Q_INVOKABLE bool hasRole(QString s)const{return userroles.contains(s);}
/**returns whether the user has a particular right*/
Q_INVOKABLE bool hasRight(Right)const;
+ ///returns whether the user has a particular flag
+ Q_INVOKABLE bool hasFlag(QString f)const{return userflags.contains(f);}
+
/**returns the directory where to store data retrieved from the server*/
- QString dataDir()const;
+ Q_INVOKABLE QString dataDir()const;
/**returns the group in which to find settings in QSettings, this group can be used by any class that accesses the profile*/
- QString settingsGroup()const;
+ Q_INVOKABLE QString settingsGroup()const;
/**returns the group where central profile settings are stored, this group is read-only for anything but the configuration dialog*/
- QString configSettingsGroup()const;
+ Q_INVOKABLE QString configSettingsGroup()const;
/**checks the server for compatibility*/
bool checkServer();
/**returns the current session ID*/
- QString sessionId()const{return m_sessid;}
+ Q_INVOKABLE QString sessionId()const{return m_sessid;}
/**returns the branch/trunk part of the repository*/
- static QString repoPart();
+ Q_INVOKABLE static QString repoPart();
/**returns default headers, ie. session ID*/
virtual QMap<QString,QString> headers(QString)const;
/**returns the profile ID of this session*/
QString profileId()const{return profileid;}
+
+ ///return all rights of the current user
+ QList<Right> allRights()const{return userrights;}
+
+ ///return all roles of the current user
+ QStringList allRoles()const{return userroles;}
+
+ ///return all flags of the current user
+ QStringList allFlags()const{return userflags;}
public slots:
/**logs into the server, returns true on success*/
private:
QString profileid,m_sessid,m_uname,m_passwd,m_host,m_hostkey;
mutable QList<Right>userrights;
- mutable QStringList userroles;
+ mutable QStringList userroles,userflags;
QByteArray servertranslation;
MSslExceptions*sslexcept;
bool didsslerror;
+//init.js
+
+// This script is executed whenever a script engine starts up.
+// Use it to load whatever extensions you often need or to shift things around
+// in the environment...
+
//initialize environment
+
+// loads wrappers for the QtCore classes
importExtension("qt.core");
+// loads wrappers for the QtGui classes (depends on qt.core being loaded first)
importExtension("qt.gui");
+
+// other relevant extensions are: qt.xml qt.xmlpatterns qt.network
-//startup code
-mainWindow.wizardMode();
\ No newline at end of file
+//startup.js
+
+// this startup code is executed as soon as the main window is initialized and visible;
+// the engine executing it does not stay open
+
+// this example code switches to the wizard if the user has the _useWizard flag set
+if(wob.interface.hasFlag("_useWizard"))
+ mainWindow.wizardMode();
+//wizard.js
+//
+// This script is executed when the wizard starts.
+// The engine stays active until the wizard is closed, you can use it to schedule
+// actions and/or to react to GUI events.
+
+// The wizard contains a stack of pages that can be used create functionality for the user.
+// The start page is controlled by the wizard itself, it contains buttons that start work flows.
+// Around this stack there are four areas wher you can put widgets that are permanently visible.
+
+// The methods are:
+// wizard.addMode("text") -> adds a button to the start page and an initial
+// page for that work flow, it return the page ID of that initial page
+// wizard.addPage() -> adds a page and returns its ID
+// wizard.pageWidget(ID) -> returns the QWidget for the given page ID
+// wizard.modeButton(ID) -> returns the QPushButton for the given mode, the
+// ID supplied to it is the return value of addMode
+// wizard.gotoStart() -> switches to the start page
+// wizard.gotoPage(ID) -> switches to the given page, ID is the return value
+// of addMode or addPage
+// wizard.setTopWidget(widget) -> sets the top permanent widget
+// wizard.setBottomWidget(widget) -> sets the bottom permanent widget
+// wizard.setLeftWidget(widget) -> sets the left permanent widget
+// wizard.setRightWidget(widget) -> sets the right permanent widget
+// there are more methods: all the slots of QDialog are available
+
+// The wizard layout looks roughly like this:
+// ____________________________________
+// | Wizard Title Bar [x]
+// +----------------------------------+
+// | top permanent widget |
+// +------+--------------------+------+
+// | left | wizard pages |right |
+// | perm.| |perm. |
+// |widget| |widget|
+// . . .
+// | | | |
+// +------+--------------------+------+
+// | bottom permanent widget |
+// +----------------------------------+
+
+//////////
+//lower buttons, those are always visible
+function createButtons()
+{
+ var w=new QWidget;
+ wizard.setBottomWidget(w);
+ var hl;
+ var p;
+ w.setLayout(hl=new QHBoxLayout);
+ hl.addWidget(p=new QPushButton("Debug"),0,0);
+ p.clicked.connect(function(){debugger;});
+ hl.addStretch(1);
+ hl.addWidget(p=new QPushButton("Start Over"),0,0);
+ p.clicked.connect(wizard.gotoStart);
+ hl.addWidget(p=new QPushButton("Close Wizard"),0,0);
+ p.clicked.connect(wizard.accept);
+ hl.addWidget(p=new QPushButton("Exit"),0,0);
+ p.clicked.connect(wizard.accept);
+ p.clicked.connect(mainWindow.close);
+}
+createButtons();
+
+//////////
//example ticket sale wizard
function startSale()
{
}
startSale();
+//////////
//dump built in scripts
+
+//you used this to dump these scripts.... ;-)
var dumpbtn;
var dumppath;
var dumplog;
wizard.gotoStart();
-//wizard.show();
-
-//debugger
\ No newline at end of file
+/////////
+//uncomment this line if you want to force the debugger visible
+//debugger
</Transaction>
<Transaction name="GetMyRights" mode="auth" updating="no">
<Input/>
- <Call lang="php" method="$this->setright(array_unique(Session::instance()->getRights()));"/>
+ <Call lang="php" method="$this->setright(array_unique(Session::instance()->getRights()));$this->setflag(array_unique(Session::instance()->getFlags()));"/>
<Output>
<Var name="right" type="List:astring"/>
+ <Var name="flag" type="List:astring"/>
</Output>
</Transaction>