-Subproject commit 83e078e50120072b6800377a8cbf8479c44ec839
+Subproject commit b25f4db535f14b366431f27a6fb9ccaa29a977fa
-Subproject commit 533122de7a6e48191f7785fc2d167125eeb342dd
+Subproject commit a49453f1414ea094eb5fbd67865659b7d1a65c04
-Subproject commit 53c34c16932383dcd020fb3ec899820fc093fcd3
+Subproject commit 692556212a82a27a2563852923b89b83faebbb3d
QMessageBox::warning(this,tr("Warning"),tr("Unable to open file %1 for writing: %2").arg(fn[0]).arg(fd.errorString()));
return;
}
- QString chk=QCryptographicHash::hash(key.toAscii(),QCryptographicHash::Md5).toHex();
+ QString chk=QCryptographicHash::hash(key.toLatin1(),QCryptographicHash::Md5).toHex();
QString out="MagicSmokeHostKey\n"+host+"\n"+key+"\n"+chk;
- fd.write(out.toAscii());
+ fd.write(out.toLatin1());
fd.close();
}
return;
}
//read content (max: 10k to limit potential damage)
- QStringList fc=QString::fromAscii(fd.read(10240)).split("\n",QString::SkipEmptyParts);
+ QStringList fc=QString::fromLatin1(fd.read(10240)).split("\n",QString::SkipEmptyParts);
fd.close();
//check content
if(fc.size()<3){
QMessageBox::warning(this,tr("Warning"),tr("This host key file does not contain a valid key."));
return;
}
- QString chk=QCryptographicHash::hash(key.toAscii(),QCryptographicHash::Md5).toHex();
+ QString chk=QCryptographicHash::hash(key.toLatin1(),QCryptographicHash::Md5).toHex();
if(chk!=fc[3].trimmed()){
QMessageBox::warning(this,tr("Warning"),tr("The key check sum did not match. Please get a clean copy of the host key file."));
return;
.value(0)
#endif
)
- .arg(QString::fromAscii(c.digest(QCryptographicHash::Sha1).toHex()))
+ .arg(QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex()))
.arg(errs[i].errorString());
}
err+=tr("Accept connection anyway?");
sslmodel->insertRows(0,lst.size());
for(int i=0;i<lst.size();i++){
sslmodel->setData(sslmodel->index(i,0),lst[i].first.subjectInfo(QSslCertificate::CommonName));
- sslmodel->setData(sslmodel->index(i,1),QString::fromAscii(lst[i].first.digest(QCryptographicHash::Sha1).toHex()));
+ sslmodel->setData(sslmodel->index(i,1),QString::fromLatin1(lst[i].first.digest(QCryptographicHash::Sha1).toHex()));
sslmodel->setData(sslmodel->index(i,2),QSslError((QSslError::SslError)lst[i].second).errorString());
}
}
#include "customerdlg.h"
#include "msinterface.h"
#include "misc.h"
-#include "lambda.h"
-#include "vlambda.h"
#include "MTChangeCustomer"
#include "MTChangeCustomerMail"
connect(p,SIGNAL(clicked()),this,SLOT(reject()));
hl->addWidget(pprev=p=new QPushButton(tr("Back")));
p->setIcon(QIcon(":/prev.png"));
- connect(p,SIGNAL(clicked()),new MLambda([=](){sl->setCurrentIndex(sl->currentIndex()-1);},sl),SLOT(call()));
+ connect(p,&QPushButton::clicked,[=](){sl->setCurrentIndex(sl->currentIndex()-1);});
hl->addWidget(pnext=p=new QPushButton(tr("Next")));
p->setIcon(QIcon(":/next.png"));
- connect(p,SIGNAL(clicked()),new MLambda([=](){sl->setCurrentIndex(sl->currentIndex()+1);},sl),SLOT(call()));
+ connect(p,&QPushButton::clicked,[=](){sl->setCurrentIndex(sl->currentIndex()+1);});
hl->addWidget(pdone=p=new QPushButton(tr("Finish")));
p->setIcon(QIcon(":/done.png"));
connect(p,SIGNAL(clicked()),this,SLOT(save()));
- auto pagechange=new MVLambda<void(int)>([=](int idx){
+ auto pagechange=[=](int idx){
pprev->setEnabled(idx>0);
int max=sl->count()-1;
pnext->setEnabled(idx<max);
pdone->setEnabled(idx>=max);
- },sl);
- connect(sl,SIGNAL(currentChanged(int)),pagechange,SLOT(call(int)));
+ };
+ connect(sl,&QStackedLayout::currentChanged,pagechange);
//get helper data
MTGetCreateCustomerHints cch=req->queryGetCreateCustomerHints();
gl->setRowStretch(row,1);
//make sure buttons are initialized
- pagechange->call(sl->currentIndex());
+ pagechange(sl->currentIndex());
//make size changeable
setSizeGripEnabled(true);
}
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setFileMode(QFileDialog::AnyFile);
fd.setConfirmOverwrite(true);
- fd.setFilter(tr("Open Document File (*.%1)").arg(tf.targetExtension()));
+ fd.setNameFilter(tr("Open Document File (*.%1)").arg(tf.targetExtension()));
fd.setDefaultSuffix(tf.targetExtension());
fd.setDirectory(currentDir());
QString fname;
{
const QMetaObject*mobj=obj->metaObject();
//look for property
- int id=mobj->indexOfProperty(n.toAscii().data());
+ int id=mobj->indexOfProperty(n.toLatin1().data());
if(id>=0)return true;
//look for method
- id=mobj->indexOfMethod(n.toAscii().data());
+ id=mobj->indexOfMethod(n.toLatin1().data());
if(id<0)return false;
QMetaMethod mm=mobj->method(id);
if(mm.parameterNames().size()!=0)return false;
{
const QMetaObject*mobj=obj->metaObject();
//look for property
- int id=mobj->indexOfProperty(n.toAscii().data());
+ int id=mobj->indexOfProperty(n.toLatin1().data());
if(id>=0)return mobj->property(id).read(obj);
//look for method
- id=mobj->indexOfMethod(n.toAscii().data());
+ id=mobj->indexOfMethod(n.toLatin1().data());
if(id<0)return QVariant();
QMetaMethod mm=mobj->method(id);
if(mm.parameterNames().size()!=0)return QVariant();
if(QString(mm.typeName()).isEmpty())return QVariant();
//try to invoke
int dataid=QMetaType::type(mm.typeName());
- void *data=QMetaType::construct(dataid);
+ void *data=QMetaType::create(dataid);
QVariant ret;
if(mm.invoke(obj, Qt::DirectConnection, QGenericReturnArgument(mm.typeName(),data)))
ret=QVariant(dataid,data);
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setFileMode(QFileDialog::AnyFile);
fd.setConfirmOverwrite(true);
- fd.setFilter(tr("Open Document File (*.%1)").arg(tf.targetExtension()));
+ fd.setNameFilter(tr("Open Document File (*.%1)").arg(tf.targetExtension()));
fd.setDefaultSuffix(tf.targetExtension());
fd.setDirectory(currentDir());
QString fname;
bool isperc=false;
foreach(QChar c,dpat){
if(isperc){
- switch(c.toAscii()){
+ switch(c.toLatin1()){
case '%':dtxt+='%';break;
case 'Y':dtxt+=QString::number(QDate::currentDate().year());break;
case 'M':dtxt+=QDate::currentDate().toString("MM");break;
m_uname=username;m_passwd=passwd;
MTLogin lg=MTLogin::query(username,passwd,m_host,m_hostkey);
if(lg.stage()==lg.Error)
- QMessageBox::warning(0,tr("Warning"),tr("Login failed: %1").arg(tr(lg.errorString().toAscii())));
+ QMessageBox::warning(0,tr("Warning"),tr("Login failed: %1").arg(tr(lg.errorString().toLatin1())));
else
setSessionId(lg.getsessionid());
if(lg.stage()!=lg.Success)return false;
WTransaction::WaitForAll()<<mrt<<mrl;
QStringList rsl=mrt.getright();
for(int i=0;i<rsl.size();i++){
-// qDebug("have right %s",rsl[i].toAscii().data());
+// qDebug("have right %s",rsl[i].toLatin1().data());
Right x=stringToRight(rsl[i]);
if(x!=NoRight)userrights<<x;
}
userflags=mrt.getflag();
// qDebug()<<"have flags"<<userflags;
userroles=mrl.getrole();
-// for(int i=0;i<userroles.size();i++)qDebug("have role %s",userroles[i].toAscii().data());
+// for(int i=0;i<userroles.size();i++)qDebug("have role %s",userroles[i].toLatin1().data());
return true;
}
MTServerInfo si;
try{si=MTServerInfo::query();}catch(WException e){
qDebug("caught exception while getting server info (%s): %s",
- e.component().toAscii().data(),
- e.error().toAscii().data());
+ e.component().toLatin1().data(),
+ e.error().toLatin1().data());
QMessageBox::warning(0,tr("Error"),tr("Communication problem while talking to the server, see log for details."));
return false;
}
MTGetLanguage gl=MTGetLanguage::query(lang,"qm");
if(gl.hasError()){
qDebug("MSInterface: error while retrieving language %s from server: (%s) %s",
- lang.toAscii().data(),
- gl.errorType().toAscii().data(),
- gl.errorString().toAscii().data());
+ lang.toLatin1().data(),
+ gl.errorType().toLatin1().data(),
+ gl.errorString().toLatin1().data());
//go to fallback
gl=MTGetLanguage::query("C","qm");
if(gl.hasError()){
QTranslator *trn=new QTranslator(this);
trn->load((const uchar*)servertranslation.data(),servertranslation.size());
qApp->installTranslator(trn);
- qDebug("MSInterface: successfully loaded server language %s",lang.toAscii().data());
+ qDebug("MSInterface: successfully loaded server language %s",lang.toLatin1().data());
MLocalFormat::setDefaultFormat(gl.getformats().value());
}
}
QDomElement el=nl.at(i).toElement();
int e=el.attribute("errorId",0).toInt();
if(e<=0)continue;
- QSslCertificate c(el.text().toAscii());
+ QSslCertificate c(el.text().toLatin1());
if(c.isNull())continue;
sslexcept.append(QPair<QSslCertificate,int>(c,e));
qDebug()<<"Note: will ignore SSL exception of type"<<e<<"from certificate (hash)"<<c.digest(QCryptographicHash::Sha1).toHex().data();
INCLUDEPATH += ../elam/include
# Chester DPtr library
-INCLUDEPATH += ../dptr
\ No newline at end of file
+INCLUDEPATH += ../dptr
+
+#QCA
+#LIBS += -lqca
.arg(prog).arg(lang)
.arg(lpath[i])
.arg(ok?"ok":"failed");
- qDebug("%s",msg.toAscii().data());
+ qDebug("%s",msg.toLatin1().data());
if(ok)return;
}
}
lang=choseLanguage(false);
}
QLocale::setDefault(QLocale(lang));
- qDebug("Loading language %s",lang.toAscii().data());
+ qDebug("Loading language %s",lang.toLatin1().data());
QTranslator qttrans;
loadTranslation(qttrans,lang,"qt");
app.installTranslator(&qttrans);
--- /dev/null
+//
+// C++ Interface: misc
+//
+// Description: miscellaneous helper functions
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2012
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_LAMBDACLEAN_H
+#define MAGICSMOKE_LAMBDACLEAN_H
+
+#include <functional>
+
+///clean-up function: executes a lambda expression when it is destructed (i.e. when the instance leaves its scope
+class MCleanup
+{
+ std::function<void()>m_ptr;
+ public:
+ ///instantiates a new cleanup object and remembers the given function for later execution
+ MCleanup(const std::function<void()>&f):m_ptr(f){}
+
+ ///sets a new cleanup function, removing the old one
+ void setFunction(const std::function<void()>&f){m_ptr=f;}
+
+ ///destructs the object and executes the cleanup function
+ ~MCleanup(){if(m_ptr)m_ptr();}
+};
+
+#endif
int sum=0;
for(int i=0;i<str.size();i++)
sum+=c39mod.indexOf(str[i]);
- return c39mod[sum%43].toAscii();
+ return c39mod[sum%43].toLatin1();
}
QImage code39(QString str)
str=str.toUpper();
for(int i=0;i<str.size();i++){
if(!c39mod.contains(str[i])){
- qDebug("Warning: invalid barcode requested: %s.",str.toAscii().data());
+ qDebug("Warning: invalid barcode requested: %s.",str.toLatin1().data());
return QImage();
}
}
//create 01-list
QString rstr=c39map['*'];
for(int i=0;i<str.size();i++)
- rstr+=c39map[str[i].toAscii()];
+ rstr+=c39map[str[i].toLatin1()];
rstr+=c39map[code39mod(str)];
rstr+=c39map['*'];
-// qDebug("Code-39, encoding: %s -> %c",str.toAscii().data(),code39mod(str));
+// qDebug("Code-39, encoding: %s -> %c",str.toLatin1().data(),code39mod(str));
//define xpm
const char *xpm[4];
- QByteArray xpmsz=QString().sprintf("%i 1 2 1",rstr.size()).toAscii();
+ QByteArray xpmsz=QString().sprintf("%i 1 2 1",rstr.size()).toLatin1();
xpm[0]=xpmsz.data();
xpm[1]="0\tg #000000";
xpm[2]="1\tg #FFFFFF";
- QByteArray xpmc=rstr.toAscii();
+ QByteArray xpmc=rstr.toLatin1();
xpm[3]=xpmc.data();
//create pixmap
return QImage(xpm);
// Description:
//
//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2012
//
// Copyright: See README/COPYING.GPL files that come with this distribution
//
static QFile*mylogFile=0;
-static void mymsghandler(QtMsgType, const char *msg)
+static void mymsghandler(QtMsgType,const QMessageLogContext&, const QString&msg)
{
if(mylogFile){
- mylogFile->write(msg,strlen(msg));
+ mylogFile->write(msg.toLatin1());
mylogFile->write("\n",1);
mylogFile->flush();
}
#ifdef Q_OS_UNIX
- fprintf(stderr,"%s\n",msg);
+ fprintf(stderr,"%s\n",msg.toLatin1().data());
#endif
}
//...open it
if(mylogFile->open(QIODevice::WriteOnly|QIODevice::Append|QIODevice::Text)){
//install as default log
- qDebug("Installing debuglog in %s",mylogFile->fileName().toAscii().data());
- qInstallMsgHandler(mymsghandler);
+ qDebug("Installing debuglog in %s",mylogFile->fileName().toLatin1().data());
+ qInstallMessageHandler(mymsghandler);
}else{
//hmm, failed to open, well hope that stderr is working...
delete mylogFile;
+++ /dev/null
-//
-// C++ Interface: misc
-//
-// Description: miscellaneous helper functions
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2012
-//
-// Copyright: See README/COPYING.GPL files that come with this distribution
-//
-//
-
-#ifndef MAGICSMOKE_LAMBDA_H
-#define MAGICSMOKE_LAMBDA_H
-
-#include <functional>
-
-#include <QObject>
-
-///wrapper for simple lambda expression, so it can be used with signals
-class MLambda:public QObject
-{
- Q_OBJECT
- private:
- std::function<void()>m_ptr;
- public:
- ///instantiates the lambda object, e.g.
- /// \code
- ///int x=55;
- ///QPushButton button("Push me!");
- ///MLambda lambda([&x](){qDebug()<<"x is"<<x;});
- ///connect(&button,SIGNAL(clicked()),&lambda,SLOT(call()));
- ///button.show();
- /// \endcode
- ///the above code will show the value of the variable 'x' whenever the user clicks the button
- MLambda(std::function<void ()>l,QObject* parent = 0):QObject(parent),m_ptr(l){}
- public slots:
- ///generic slot that transparently executes the lambda expression
- void call(){if(m_ptr)m_ptr();}
-};
-
-///clean-up function: executes a lambda expression when it is destructed (i.e. when the instance leaves its scope
-class MCleanup
-{
- std::function<void()>m_ptr;
- public:
- ///instantiates a new cleanup object and remembers the given function for later execution
- MCleanup(const std::function<void()>&f):m_ptr(f){}
-
- ///sets a new cleanup function, removing the old one
- void setFunction(const std::function<void()>&f){m_ptr=f;}
-
- ///destructs the object and executes the cleanup function
- ~MCleanup(){if(m_ptr)m_ptr();}
-};
-
-#endif
$$PWD/waitcursor.h \
$$PWD/sclock.h \
$$PWD/formula.h \
- $$PWD/lambda.h \
- $$PWD/vlambda.h \
$$PWD/msengine.h \
$$PWD/dommodel.h
$$PWD/waitcursor.cpp \
$$PWD/sclock.cpp \
$$PWD/formula.cpp \
- $$PWD/vlambda.cpp \
$$PWD/msengine.cpp \
$$PWD/dommodel.cpp
INCLUDEPATH += $$PWD
-QMAKE_CXXFLAGS += -std=gnu++0x
\ No newline at end of file
+++ /dev/null
-//
-// C++ Interface: misc
-//
-// Description: miscellaneous helper functions
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2012
-//
-// Copyright: See README/COPYING.GPL files that come with this distribution
-//
-//
-
-#include "vlambda.h"
-// #include <QDebug>
-
-using namespace std;
-using namespace MVLambdaNS;
-
-
-//the static metacall was introduced in Qt 4.8
-#if QT_VERSION >= 0x040800
-//static
-void MVLambdaBase::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
-{
- if (_c == QMetaObject::InvokeMetaMethod) {
- //Q_ASSERT(staticMetaObject.cast(_o));//there is no static meta-object
- MVLambdaBase *_t = static_cast<MVLambdaBase *>(_o);
- if(_id== 0 && _t != nullptr) _t->do_call(_a);
- }
-}
-
-//static
-const QMetaObjectExtraData MVLambdaBase::staticMetaObjectExtraData = {
- 0, MVLambdaBase::qt_static_metacall
-};
-
-static const short qtmetaversion=6;
-#else
-const QMetaObjectExtraData MVLambdaBase::staticMetaObjectExtraData = {0,0};
-static const short qtmetaversion=6;
-#endif
-
-MVLambdaBase::MVLambdaBase(int cnt,QByteArray rt, QByteArray cn, QObject* parent)
-:QObject(parent),m_count(cnt),m_callparm(cn),m_callret(rt),
-qt_meta_data({ // content:
- qtmetaversion, // revision
- 0, // classname
- 0, 0, // classinfo
- 1, 14, // methods (14 is start of method info)
- 0, 0, // properties
- 0, 0, // enums/sets
- 0, 0, // constructors
- 0, // flags
- 0, // signalCount
-
- // slots: signature, parameters, type, tag, flags
- 10, 8, 8, 8, 0x0a,
- 0 // eod
-})
-{
-// qDebug()<<"instantiated "<<QString("%2 call(%1)").arg(cn.data()).arg(rt.data());
- //init string data and meta data array
- string_metadata=QByteArray("MVLambda\0\0call(",15)+cn+QByteArray(")\0",2);
- qt_meta_data[15]=string_metadata.size();
- for(int i=1;i<m_count;i++)string_metadata+=",";//params have no name
- string_metadata.append(char(0));
- qt_meta_data[16]=string_metadata.size();
- string_metadata+=rt;
- string_metadata.append(char(0));
- // !!!!!!!
- // after this line string_metadata must not be changed
- // !!!!!!!
- //register meta object
- meta_object=QMetaObject({{
- &QObject::staticMetaObject,
- string_metadata.data(),
- qt_meta_data,
-#if QT_VERSION >= 0x040800
- &MVLambdaBase::staticMetaObjectExtraData
-#else
- 0
-#endif
- }});
-}
-
-void* MVLambdaNS::MVLambdaBase::qt_metacast(const char* _clname)
-{
- if (!_clname) return 0;
- if (!strcmp(_clname, "MVLambda"))
- return static_cast<void*>(this);
- return QObject::qt_metacast(_clname);
-}
-
-int MVLambdaBase::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
-{
- _id = QObject::qt_metacall(_c, _id, _a);
- if (_id < 0)
- return _id;
- if (_c == QMetaObject::InvokeMetaMethod) {
- if (_id < 1)
- do_call(_a);
- _id -= 1;
- }
- return _id;
-}
+++ /dev/null
-//
-// C++ Interface: variadic lambda class
-//
-// Description: a lambda to slot wrapper that can use arbitrary slot signatures
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2012
-//
-// Copyright: See README/COPYING.GPL files that come with this distribution
-//
-//
-
-#ifndef MAGICSMOKE_VLAMBDA_H
-#define MAGICSMOKE_VLAMBDA_H
-
-#include <functional>
-#include <QObject>
-#include "vlambda_p.h"
-
-/// @cond HIDDEN_CODE
-
-/// Namespace for functions and sub-templates that are internal to the variadic lambda wrapper MVLambda.
-namespace MVLambdaNS {
-/// workarout for missing "final" keyword in GCC 4.6
-//TODO: remove this as soon as "final" is available
-class MVLFinal{protected:MVLFinal(){}};
-
-/// abstract base class for variadic lambda wrapper, simulates most of the Q_OBJECT macro
-/// you do not need to understand the details, unless you want to enhance it or fix bugs
-class MVLambdaBase:public QObject
-{
- ///amount of parameters
- const int m_count;
- ///store the call-signature
- const QByteArray m_callparm,m_callret;
- ///pointers into the meta data
- uint qt_meta_data[20];
- ///the mata data of the artificial slot
- QByteArray string_metadata;
- ///the meta object of this instance, not static since it is calculated
- QMetaObject meta_object;
- ///overridden by the template to implement the actual call
- virtual void do_call(void**)=0;
- ///used by Qt to schedule a call
- static void qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a);
- ///simulated extra meta data of the lambda class in general
- static const QMetaObjectExtraData staticMetaObjectExtraData;
- protected:
- ///instantiates the instance, used by the template
- MVLambdaBase ( int c,QByteArray rt, QByteArray cn, QObject* parent);
-
- public:
- ///returns a pointer to the meta object of this instance (never manipulate it!)
- const QMetaObject *metaObject() const{return &meta_object;}
- ///cast function, used by Qt
- void *qt_metacast(const char *_clname);
- ///used by Qt to deliver a call
- int qt_metacall(QMetaObject::Call _c, int _id, void **_a);
-
- ///returns the parameter types of the call method
- const QByteArray callParams()const{return m_callparm;}
- ///returns the return type of the call method
- const QByteArray callReturn()const{return m_callret;}
-};
-
-//end of namespace
-};
-/// @endcond
-
-///forward declare the lambda wrapper template
-template<typename _Signature>class MVLambda;
-
-/** \brief Wrapper for lambda expression, so it can be used with signals.
-
-This template allows to connect any lambda expression (or closure, function pointer, object method pointer or functor object) to a signal with compatible argument types by creating a slot with identical signature.
-
-In its simplest form the slot and lambda expression take no argument and return no values:
-\code
-int x=55;
-QPushButton button("Push me!");
-MVLambda<void()> lambda([&x](){qDebug()<<"x is"<<x;});
-connect(&button,SIGNAL(clicked()),&lambda,SLOT(call()));
-button.show();
-\endcode
-the above code will show the value of the variable 'x' whenever the user clicks the button.
-
-A more complex variation takes arguments and returns a value:
-\code
-MVLambda<int(double,int)> lambda([](double d,int i)->int{return d*i;});
-connect(&someobject,SIGNAL(mysig(double,int)),&lambda,SLOT(call(double,int)));
-...
-\endcode
-
-The wrapper object will automatically tell Qt about its virtual slot call(...) and will make sure it is called when a connected signal triggers. You can also request its meta object and inquire about its properties. Instances of this template are derived from QObject, so all functionality available in QObject is also available in lambda wrappers.
-
-\param Ret return type of the lambda being wrapped, also the return type of the generated slot
-\param Args variadic list of types of the argument list of the lambda and slot
-*/
-template<typename Ret,typename...Args>
-class MVLambda<Ret(Args...)> :public MVLambdaNS::MVLambdaBase,virtual private MVLambdaNS::MVLFinal
-{
- private:
- ///function pointer...
- std::function<Ret(Args...)>m_ptr;
- /// interface for the Qt meta object system
- virtual void do_call(void**a){
- MVLambdaNS::Call<Ret(Args...)>(a,[&](Args...args)->Ret{return this->call(args...);});
- }
- public:
- ///instantiates the lambda wrapper object
- /// \param l the lambda, closure, functor, function or method pointer to execute as a slot
- /// \param parent optional: the parent object of this wrapper, you can use this to limit the lifetime of the wrapper object
- MVLambda(std::function<Ret(Args...)>l,QObject* parent = 0)
- :MVLambdaBase(MVLambdaNS::Count<Args...>::count, MVLambdaNS::TypeStr<Ret>::get(), MVLambdaNS::TypeStr<Args...>::get(), parent), m_ptr(l){}
-
- ///overwrites the lambda/function that is executed as slot, this does
- ///not alter signal-slot-connections
- /// \param l new lambda, functor, function or method pointer
- void setFunction(std::function<Ret(Args...)>l)
- {m_ptr=l;}
-
- ///Generic slot that transparently executes the lambda expression.
- ///If the wrapper was initialized with a nullptr this slot will return a default constructed instance of the return type.
- /// \param Args variadic list of arguments (depends on template parameters)
- /// \returns an object of the configured return type - either the result of the lambda or a default constructed object
- Ret call(Args...args){if(m_ptr)return m_ptr(args...);else return Ret();}
-};
-
-#endif
+++ /dev/null
-//
-// C++ Interface: variadic lambda
-//
-// Description: helpers for variadic lambda
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2012
-//
-// Copyright: See README/COPYING.GPL files that come with this distribution
-//
-//
-
-#ifndef MAGICSMOKE_VLAMBDA_P_H
-#define MAGICSMOKE_VLAMBDA_P_H
-
-#include <functional>
-#include <QObject>
-#include <QVariant>
-#include <QByteArray>
-
-/// @cond HIDDEN_CODE
-
-namespace MVLambdaNS {
-/// helper for lambda template: determines the string representation of the functions type signature
-template<typename...A>class TypeStr;
-
-///recursive version: determines all typenames for more than one type in an argument list
-template <typename F,typename...Args>
-class TypeStr<F,Args...>{
-public:
-static const QByteArray get()
-{return TypeStr<F>::get()+","+TypeStr<Args...>::get();}
-};
-
-///determines name of a simple type
-template <typename T>
-class TypeStr<T>{
-public: static const QByteArray get()
-{T t;return QVariant::fromValue(t).typeName();}
-};
-
-///determines name of a reference type
-template <typename T>
-class TypeStr<T&>{
-public: static const QByteArray get()
-{T t;return QByteArray(QVariant::fromValue(t).typeName())+"&";}
-};
-///determine name of a const reference type
-template <typename T>
-class TypeStr<const T&>{
-public: static const QByteArray get()
-{T t;return QByteArray("const ")+QVariant::fromValue(t).typeName()+"&";}
-};
-///determine name of a pointer type
-template <typename T>
-class TypeStr<T*>{
-public: static const QByteArray get()
-{T t;return QByteArray(QVariant::fromValue(t).typeName())+"*";}
-};
-///determine name of a const pointer type
-template <typename T>
-class TypeStr<const T*>{
-public: static const QByteArray get()
-{T t;return QByteArray("const ")+QVariant::fromValue(t).typeName()+"*";}
-};
-
-///fallback for no argument list: returns empty string
-template<>
-class TypeStr<>{
-public: static const QByteArray get()
-{return QByteArray();}
-};
-
-///returns empty string for a void argument list
-template<>
-class TypeStr<void>{
-public: static const QByteArray get()
-{return QByteArray();}
-};
-
-
-
-//////////////////////////////////////////////////////
-///template to count an argument list
-template<typename ...Args>class Count;
-
-///recursive version to count a list with at least one element
-template<typename T,typename ...Args>
-class Count<T,Args...>{public: static const int count=Count<Args...>::count + 1;};
-
-///fallback to count an empty argument list or to terminate a list
-template<>
-class Count<>{public: static const int count=0;};
-
-
-
-///////////////////////////////////////////////////////
-///wrapper type to turn a Qt internal meta call into an actual method call - it turns a void** list into a typed argument list and a return argument
-template<typename Sig>class Call;
-
-///turns a Qt internal meta call into a method call with return type and multiple arguments
-template<typename R,typename T,typename...Args>
-class Call<R(T,Args...)>
-{
- public:
- Call(void**vl,std::function<R(T,Args...)>cb)
- {
- R r;
- Call<void(Args...)>(vl+1,[&](Args...args){r=cb(*reinterpret_cast<T*>(vl[0]),args...);});
- if(vl[0])*reinterpret_cast<R*>(vl[0])=r;
- }
-};
-///turns a Qt internal meta call into a method call with return type and a single argument
-template<typename R,typename T>
-class Call<R(T)>
-{
- public:
- Call(void**vl,std::function<R(T)>cb)
- {
- R r=cb(*reinterpret_cast<T*>(vl[1]));
- if(vl[0])*reinterpret_cast<R*>(vl[0])=r;
- }
-};
-///turns a Qt internal meta call into a method call with return type and no arguments
-template<typename R>
-class Call<R()>
-{
- public:
- Call(void**vl,std::function<R()>cb)
- {
- R r=cb();
- if(vl[0])*reinterpret_cast<R*>(vl[0])=r;
- }
-};
-
-///turns a Qt internal meta call into a method call returning void and multiple arguments
-template<typename T,typename...Args>
-class Call<void(T,Args...)>
-{
- public:
- Call(void**vl,std::function<void(T,Args...)>cb)
- {
- Call<void(Args...)>(vl+1,[&](Args...args){cb(*reinterpret_cast<T*>(vl[1]),args...);});
- }
-};
-///turns a Qt internal meta call into a method call returning void and a single argument
-template<typename T>
-class Call<void(T)>
-{
- public:
- Call(void**vl,std::function<void(T)>cb)
- {
- cb(*reinterpret_cast<T*>(vl[1]));
- }
-};
-///turns a Qt internal meta call into a method call returning void and no arguments
-template<>
-class Call<void()>
-{
- public:
- Call(void**,std::function<void()>cb)
- {
- cb();
- }
-};
-
-//end of namespace
-};
-
-/// @endcond
-
-#endif
QMessageBox::warning(this,tr("Warning"),tr("Unable to open file %1 for writing: %2").arg(fn[0]).arg(fd.errorString()));
return;
}
- QString chk=QCryptographicHash::hash(key.toAscii(),QCryptographicHash::Md5).toHex();
+ QString chk=QCryptographicHash::hash(key.toLatin1(),QCryptographicHash::Md5).toHex();
QString out="MagicSmokeHostKey\n"+name+"\n"+key+"\n"+chk;
- fd.write(out.toAscii());
+ fd.write(out.toLatin1());
fd.close();
//convert key to hash
key=key2hash(key);
return;
}
//read content (max: 10k to limit potential damage)
- QStringList fc=QString::fromAscii(fd.read(10240)).split("\n",QString::SkipEmptyParts);
+ QStringList fc=QString::fromLatin1(fd.read(10240)).split("\n",QString::SkipEmptyParts);
fd.close();
//check content
if(fc.size()<3){
return;
}
QString key=fc[2].trimmed();
- QString chk=QCryptographicHash::hash(key.toAscii(),QCryptographicHash::Md5).toHex();
+ QString chk=QCryptographicHash::hash(key.toLatin1(),QCryptographicHash::Md5).toHex();
if(chk!=fc[3].trimmed()){
QMessageBox::warning(this,tr("Warning"),tr("The key check sum did not match. Please get a clean copy of the host key file."));
return;
if(mkg.exec()!=QDialog::Accepted)
return key;
salt=mkg.getKey(8);
- return salt+" "+ QCryptographicHash::hash((salt+key).toAscii(),QCryptographicHash::Sha1).toHex();
+ return salt+" "+ QCryptographicHash::hash((salt+key).toLatin1(),QCryptographicHash::Sha1).toHex();
}
QMessageBox::warning(this,tr("Warning"),tr("Unable to open file %1 for writing: %2").arg(fn[0]).arg(fd.errorString()));
return;
}
- QString chk=QCryptographicHash::hash(key.toAscii(),QCryptographicHash::Md5).toHex();
+ QString chk=QCryptographicHash::hash(key.toLatin1(),QCryptographicHash::Md5).toHex();
QString out="MagicSmokeHostHash\n"+name+"\n"+key+"\n"+chk;
- fd.write(out.toAscii());
+ fd.write(out.toLatin1());
fd.close();
}
QModelIndex idx0=cartmodel->index(j,0);
if(cartmodel->data(idx0,CART_TYPEROLE).toInt() != CART_TICKET)continue;
QModelIndex idx1=cartmodel->index(j,1);
- cartmodel->setData(idx1,Qt::red,Qt::BackgroundRole);
+ cartmodel->setData(idx1,QColor(Qt::red),Qt::BackgroundRole);
//check state, color it
switch(ticks[i].status().value()){
case MOCartTicket::EventOver:
cartmodel->setData(idx1,tr("You cannot order tickets for this event anymore, ask a more privileged user."),Qt::ToolTipRole);
break;
case MOCartTicket::Exhausted:{
- cartmodel->setData(idx0,Qt::red,Qt::BackgroundRole);
+ cartmodel->setData(idx0,QColor(Qt::red),Qt::BackgroundRole);
QString tt=tr("The event is (almost) sold out, there are %1 tickets left.").arg(ticks[i].maxamount());
cartmodel->setData(idx0,tt,Qt::ToolTipRole);
cartmodel->setData(idx1,tt,Qt::ToolTipRole);
QModelIndex idx0=cartmodel->index(j,0);
if(cartmodel->data(idx0,CART_TYPEROLE).toInt() != CART_VOUCHER)continue;
QModelIndex idx1=cartmodel->index(j,1);
- cartmodel->setData(idx1,Qt::red,Qt::BackgroundRole);
+ cartmodel->setData(idx1,QColor(Qt::red),Qt::BackgroundRole);
//check state, color it
switch(voucs[i].status().value()){
case MOCartVoucher::InvalidValue:
//get events
MTGetAllEvents gae=req->queryGetAllEvents();
if(gae.stage()!=gae.Success){
- qDebug("Error getting all events (%s): %s",gae.errorType().toAscii().data(),gae.errorString().toAscii().data());
+ qDebug("Error getting all events (%s): %s",gae.errorType().toLatin1().data(),gae.errorString().toLatin1().data());
return;
}
QList<MOEvent>evl=gae.getevents();
{
//ask for OrderID
bool ok;
- int oid=QInputDialog::getInteger(this,tr("Enter Order ID"),tr("Please enter the ID of the order you want to display:"),0,0,2147483647,1,&ok);
+ int oid=QInputDialog::getInt(this,tr("Enter Order ID"),tr("Please enter the ID of the order you want to display:"),0,0,2147483647,1,&ok);
if(!ok)return;
//display
MTGetOrder go=req->queryGetOrder(oid);
//store new data
QFile fd(path);
if(fd.open(QIODevice::WriteOnly|QIODevice::Truncate)){
- fd.write(bc.getbackup().value().toAscii());
+ fd.write(bc.getbackup().value().toLatin1());
fd.close();
set.setValue("backuptime",QDateTime::currentDateTime().toTime_t());
QMessageBox::information(this,tr("Backup"),tr("The backup was successful."));
h+=QString::number(l,16);
return *this;
}
- ~MScriptEngine_DebugHelper(){qDebug()<<h.toAscii().data();}
+ ~MScriptEngine_DebugHelper(){qDebug()<<h.toLatin1().data();}
};
QScriptValue MScriptEngine::evalFile(QString fn)
#make sure the correct Qt DLLs are used
CONFIG += qt thread link_prl
QT += xml network script scripttools
-contains(QT_MAJOR_VERSION,"5") {
- QT += widgets printsupport
-}
+QT += widgets printsupport
#add the icon for windoze
win32-* {
QMAKE_CXXFLAGS += -fPIE
QMAKE_LFLAGS += -pie
}
+
+#activate C++11 for g++
+gcc {
+ message("detected GCC, activating C++11 with GNU extensions")
+ QMAKE_CXXFLAGS += -std=gnu++11
+}
\ No newline at end of file
//
#include "labeldlg.h"
-#include "lambda.h"
#include "msinterface.h"
hl->addWidget(t_prn=new QLabel(ticket.printerName()),1);
hl->addWidget(p=new QToolButton);
p->setText("...");
- MLambda settprn([&]{
+ auto settprn=[&]{
QPrintDialog pd(&t_printer,&d);
if(pd.exec()!=QDialog::Accepted)return;
t_prn->setText(t_printer.printerName());
- });
- d.connect(p,SIGNAL(clicked()),&settprn,SLOT(call()));
+ };
+ d.connect(p,&QToolButton::clicked,settprn);
QFrame*frm;
fl->addRow(frm=new QFrame);
frm->setFrameStyle(QFrame::HLine|QFrame::Sunken);
hl->addWidget(v_prn=new QLabel(voucher.printerName()),1);
hl->addWidget(p=new QToolButton);
p->setText("...");
- MLambda setvprn([&]{
+ auto setvprn=[&]{
QPrintDialog pd(&v_printer,&d);
if(pd.exec()!=QDialog::Accepted)return;
v_prn->setText(pd.printer()->printerName());
- });
- d.connect(p,SIGNAL(clicked()),&setvprn,SLOT(call()));
+ };
+ d.connect(p,&QToolButton::clicked,setvprn);
//button...
fl->addRow(new QLabel(" "));
fl->addRow(hl=new QHBoxLayout);
#include "misc.h"
#include "odtrender.h"
#include "dommodel.h"
-#include "lambda.h"
-#include "vlambda.h"
+#include "cleanup.h"
#include "orderwin.h"
#include "eventsummary.h"
#include <QZip>
#include <MTGetOrder>
+#include <functional>
+
class DPTR_CLASS_NAME(MOdfEditor)
{
d->mDomTree->setSelectionMode(QAbstractItemView::ContiguousSelection);
d->mDomTree->setSelectionBehavior(QAbstractItemView::SelectRows);
d->mDomTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- d->mDomTree->header()->setResizeMode(0,QHeaderView::ResizeToContents);
+ d->mDomTree->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
d->mDomTree->header()->setStretchLastSection(false);
connect(d->mDomTree->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,SLOT(selectionChange()));
- MVLambda<void(QPoint)> *ml;
- ml=new MVLambda<void(QPoint)>([=](QPoint p){
+ auto ml=[=](QPoint p){
QModelIndex idx=d->mDomTree->indexAt(p);
if(idx.isValid())
medit->popup(d->mDomTree->mapToGlobal(p));
- },this);
- connect(d->mDomTree,SIGNAL(customContextMenuRequested(QPoint)),ml,SLOT(call(QPoint)));
+ };
+ connect(d->mDomTree,&QTreeView::customContextMenuRequested,ml);
d->mDomTree->setContextMenuPolicy(Qt::CustomContextMenu);
//the editors...
connect(d->mTagAttrModel,SIGNAL(rowsRemoved(const QModelIndex&,int,int)), this,SLOT(setChanged()));
connect(d->mTagAttrModel,SIGNAL(rowsInserted(const QModelIndex&,int,int)), this,SLOT(setChanged()));
vl->addLayout(hl=new QHBoxLayout);
- MLambda *btn;QPushButton*p;
- btn=new MLambda([=](){d->mTagAttrModel->insertRow(d->mTagAttrModel->rowCount());},this);
+ QPushButton*p;
+ std::function<void()> btn=[=](){d->mTagAttrModel->insertRow(d->mTagAttrModel->rowCount());};
hl->addStretch(1);
hl->addWidget(p=new QPushButton("Add"));
- connect(p,SIGNAL(clicked()),btn,SLOT(call()));
- btn=new MLambda([=](){
+ connect(p,&QPushButton::clicked,btn);
+ btn=[=](){
QModelIndex idx=d->mTagAttrs->currentIndex();
if(idx.isValid())
d->mTagAttrModel->removeRow(idx.row(),idx.parent());
- },this);
+ };
hl->addWidget(p=new QPushButton("Remove"));
- connect(p,SIGNAL(clicked()),btn,SLOT(call()));
+ connect(p,&QPushButton::clicked,btn);
//loop editor
d->st_loop=stack->addWidget(w=new QWidget);
w->setLayout(vl=new QVBoxLayout);
//find the first real tag and insert the new start tag there
if(st!="<?" && st!="<!" && st[0]=='<'){
nba+="<msmoketpl:template xmlns:msmoketpl=\"";
- nba+=OdfTemplateNS.toAscii();
+ nba+=OdfTemplateNS.toLatin1();
nba+="\">\n";
hstarted=true;
}
QSettings set;
set.beginGroup("templates/"+profileid+"/"+n);
QString o=set.value("description").toString();
- qDebug("setting %s '%s' -> '%s'",n.toAscii().data(),o.toAscii().data(),d.toAscii().data());
+ qDebug("setting %s '%s' -> '%s'",n.toLatin1().data(),o.toLatin1().data(),d.toLatin1().data());
if(o==d)return true;
//send to server
MTSetTemplateDescription std=req->querySetTemplateDescription(n,d);
QSettings set;
set.beginGroup("templates/"+profileid+"/"+n);
QString o=set.value("flags").toString();
- qDebug("setting %s '%s' -> '%s'",n.toAscii().data(),o.toAscii().data(),flags.toAscii().data());
+ qDebug("setting %s '%s' -> '%s'",n.toLatin1().data(),o.toLatin1().data(),flags.toLatin1().data());
if(o==flags)return true;
//send to server
MTSetTemplateFlags std=req->querySetTemplateFlags(n,flags);
continue;
}
if(fndb.contains(fn)){
- qDebug("Label renderer warning: Font file %s was loaded more than once. Line %i Column %i.",fn.toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer warning: Font file %s was loaded more than once. Line %i Column %i.",fn.toLatin1().data(),el.lineNumber(),el.columnNumber());
continue;
}
fndb.append(fn);
QByteArray fdata=buffer.data();
int fid=QFontDatabase::addApplicationFontFromData(fdata);
if(fid<0){
- qDebug("Label renderer warning: Font could not be loaded: %s (size: %i, md5: %s)",fn.toAscii().data(),fdata.size(),QCryptographicHash::hash(fdata,QCryptographicHash::Md5).toHex().data());
+ qDebug("Label renderer warning: Font could not be loaded: %s (size: %i, md5: %s)",fn.toLatin1().data(),fdata.size(),QCryptographicHash::hash(fdata,QCryptographicHash::Md5).toHex().data());
continue;
}
fdb.append(fid);
temp.getCurrentFile(buffer);
QImage img;
if(!img.loadFromData(buffer.data())){
- qDebug("Label renderer error: Picture file %s could not be interpreted.",fn.toAscii().data());
+ qDebug("Label renderer error: Picture file %s could not be interpreted.",fn.toLatin1().data());
//failed pictures are fatal
canrender=false;
return;
QStringList off=el.attribute("offset").split(" ");
if(off.size()!=2){
if(isfatal){
- qDebug("Label renderer error: Illegal offset in %s at line %i column %i.",el.tagName().toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer error: Illegal offset in %s at line %i column %i.",el.tagName().toLatin1().data(),el.lineNumber(),el.columnNumber());
canrender=false;
}
return QPointF();
ret.setX(off[0].toDouble(&b));
if(!b){
if(isfatal){
- qDebug("Label renderer error: Illegal offset in %s at line %i column %i.",el.tagName().toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer error: Illegal offset in %s at line %i column %i.",el.tagName().toLatin1().data(),el.lineNumber(),el.columnNumber());
canrender=false;
}
return QPointF();
ret.setY(off[1].toDouble(&b));
if(!b){
if(isfatal){
- qDebug("Label renderer error: Illegal offset in %s at line %i column %i.",el.tagName().toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer error: Illegal offset in %s at line %i column %i.",el.tagName().toLatin1().data(),el.lineNumber(),el.columnNumber());
canrender=false;
}
return QPointF();
QStringList lst=el.attribute("size").split(" ");
if(lst.size()!=2){
if(isfatal){
- qDebug("Label renderer error: Illegal size (%i items) in %s at line %i column %i.",lst.size(),el.tagName().toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer error: Illegal size (%i items) in %s at line %i column %i.",lst.size(),el.tagName().toLatin1().data(),el.lineNumber(),el.columnNumber());
canrender=false;
}
return QSizeF();
ret.setWidth(lst[0].toDouble(&b));
if(!b){
if(isfatal){
- qDebug("Label renderer error: Illegal size (invalid width) in %s at line %i column %i.",el.tagName().toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer error: Illegal size (invalid width) in %s at line %i column %i.",el.tagName().toLatin1().data(),el.lineNumber(),el.columnNumber());
canrender=false;
}
return QSizeF();
ret.setHeight(lst[1].toDouble(&b));
if(!b){
if(isfatal){
- qDebug("Label renderer error: Illegal size (invalid height) in %s at line %i column %i.",el.tagName().toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer error: Illegal size (invalid height) in %s at line %i column %i.",el.tagName().toLatin1().data(),el.lineNumber(),el.columnNumber());
canrender=false;
}
return QSizeF();
QRectF rect(tonatural(pdev,off)+noff,tonatural(pdev,sz));
paint->drawImage(rect,code39(cd));
}else{
- qDebug("Label renderer error: unknown element %s in label template at line %i column %i.",enm.toAscii().data(),el.lineNumber(),el.columnNumber());
+ qDebug("Label renderer error: unknown element %s in label template at line %i column %i.",enm.toLatin1().data(),el.lineNumber(),el.columnNumber());
canrender=false;
return;
}
if(fdbl.contains(fnt2))if(fdbl[fnt2].size())
font=fdbl[fnt2][0];
if(font.isEmpty()){
- qDebug("Label renderer warning: font file %s did not contain font families, using %s instead.",fnt.toAscii().data(),dfont.toAscii().data());
+ qDebug("Label renderer warning: font file %s did not contain font families, using %s instead.",fnt.toLatin1().data(),dfont.toLatin1().data());
font=dfont;
}
getfontdb.insert(fnt,font);
if(!getfontdb.contains(fnt)){
QStringList fonts=QFontDatabase().families();
if(!fonts.contains(fnt)){
- qDebug("Label renderer warning: font %s not found, searching a close match...",fnt.toAscii().data());
+ qDebug("Label renderer warning: font %s not found, searching a close match...",fnt.toLatin1().data());
QString font;
for(int i=0;i<fonts.size();i++){
if(i)font+=", ";
font+=fonts[i];
}
- qDebug("Label renderer hint - found the following fonts: %s",font.toAscii().data());
+ qDebug("Label renderer hint - found the following fonts: %s",font.toLatin1().data());
font=dfont;
for(int i=0;i<fonts.size();i++)
if(fonts[i].startsWith(fnt)){
font=fonts[i];
break;
}
- qDebug("Label renderer hint: replacing font %s with %s",fnt.toAscii().data(),font.toAscii().data());
+ qDebug("Label renderer hint: replacing font %s with %s",fnt.toLatin1().data(),font.toLatin1().data());
getfontdb.insert(fnt,font);
}else
getfontdb.insert(fnt,fnt);
-Subproject commit 968c00cf87fb14ec04c687ac8746cbefa8d9fb1a
+Subproject commit 460de61d1f264f4559cc298e58bc853b6097febe
tt.setHMS(fi.tmu_date.tm_hour,
fi.tmu_date.tm_min, fi.tmu_date.tm_sec);
- d.setYMD(fi.tmu_date.tm_year,
+ d.setDate(fi.tmu_date.tm_year,
fi.tmu_date.tm_mon+1, fi.tmu_date.tm_mday);
*t = QDateTime(d, tt);
}