From 2bf133d5701fd4789f8bc6100dbd05e8741465b7 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Mon, 26 Jul 2021 18:51:20 +0200 Subject: [PATCH] compat with Qt5.15, more steps towards Qt6 --- Makefile | 3 +- basics.pri | 5 +- commonlib/configdialog.cpp | 25 +- commonlib/mapplication.cpp | 10 +- commonlib/misc/code39.cpp | 4 +- commonlib/templates/labeldlg.cpp | 994 ++++++++++++++++++------------------ commonlib/templates/labeldlg.h | 46 +- commonlib/templates/odtrender.cpp | 24 +- commonlib/widgets/centbox.h | 18 +- commonlib/widgets/seatplanview.cpp | 19 +- iface/iface.pro | 3 + iface/misc/misc.cpp | 30 +- iface/misc/misc.h | 78 ++-- iface/msinterface.cpp | 6 +- iface/templates/templates.cpp | 24 +- iface/wext/event.cpp | 6 +- iface/wext/event.h | 17 +- iface/wext/seatplanobj.cpp | 6 +- pack | 2 +- src/mwin/carttab.cpp | 14 +- taurus | 2 +- 21 files changed, 678 insertions(+), 658 deletions(-) diff --git a/Makefile b/Makefile index b11bea6..f9abb5f 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ #global configuration #change this if the correct Qt is not in your PATH -QMAKE = qmake +#QMAKE = qmake +QMAKE = /usr/lib/x86_64-linux-gnu/qt5/bin/qmake #QMAKE = /usr/local/Qt-5.6.0/bin/qmake #set this if you want additional arguments to qmake diff --git a/basics.pri b/basics.pri index ea115eb..645e54e 100644 --- a/basics.pri +++ b/basics.pri @@ -13,6 +13,9 @@ CONFIG += separate_debug_info #enable C++-11 features CONFIG += c++11 +#FIXME: compat +equals(QT_MAJOR_VERSION, 6): QT += core5compat + #compilation output: OBJECTS_DIR = .ctmp MOC_DIR = .ctmp @@ -25,7 +28,7 @@ LIBS += -L$$PWD/bin QMAKE_CFLAGS += -fstack-protector-all -Wstack-protector QMAKE_CXXFLAGS += -fstack-protector-all -Wstack-protector -#ASLR for windows +#ASLR for windows win32 { QMAKE_LFLAGS += -Wl,--nxcompat -Wl,--dynamicbase LIBS += -lssp diff --git a/commonlib/configdialog.cpp b/commonlib/configdialog.cpp index d4aab14..160bea0 100644 --- a/commonlib/configdialog.cpp +++ b/commonlib/configdialog.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: config dialog // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2007-2011 @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,7 @@ MConfigDialog::MConfigDialog() { setWindowTitle(tr("Magic Smoke Configuration")); - + oldrow=-1; sslexcept=0; //main layout @@ -76,7 +77,7 @@ MConfigDialog::MConfigDialog() m->addAction(tr("Set &Default Label Font..."),this,SLOT(setDefaultFont())); m->addAction(tr("Set &Application Style..."),this,SLOT(setAppStyle())); mb->addMenu(MApplication::helpMenu()); - + //create list view hl->addWidget(profiles=new MListView); profilemodel=new QStandardItemModel(this); @@ -116,7 +117,7 @@ MConfigDialog::MConfigDialog() connect(useproxy,SIGNAL(toggled(bool)),proxyuser,SLOT(setEnabled(bool))); connect(useproxy,SIGNAL(toggled(bool)),proxypass,SLOT(setEnabled(bool))); gl->setRowStretch(++lctr,10); - + tab->addTab(w=new QWidget,tr("Authentication")); w->setLayout(gl=new QGridLayout); lctr=0; @@ -134,7 +135,7 @@ MConfigDialog::MConfigDialog() gl->addWidget(userhint=new QLineEdit,lctr,1); gl->setRowStretch(++lctr,10); gl->addLayout(hl=new QHBoxLayout,++lctr,0,1,2); - + tab->addTab(w=new QWidget,tr("SSL Exceptions")); w->setLayout(vl=new QVBoxLayout); vl->addWidget(new QLabel(tr("List of non-fatal SSL exceptions:")),0); @@ -149,7 +150,7 @@ MConfigDialog::MConfigDialog() connect(pb,SIGNAL(clicked()),this,SLOT(clearSslExceptions())); hl->addWidget(pb=new QPushButton(tr("Probe Server"))); connect(pb,SIGNAL(clicked()),this,SLOT(serverProbe())); - + tab->addTab(w=new QWidget,tr("Scripting")); w->setLayout(gl=new QGridLayout); gl->setColumnStretch(4,1); @@ -178,9 +179,9 @@ MConfigDialog::MConfigDialog() lab->setAlignment(Qt::AlignRight); gl->addWidget(usrscript=new QLineEdit,lctr,1,1,4); gl->setRowStretch(++lctr,1); - + setSizeGripEnabled(true); - + initProfiles(); loadProfile(); } @@ -469,7 +470,7 @@ void MConfigDialog::importKey() QModelIndex idx=profiles->currentIndex(); if(!idx.isValid())return; QString profkey=profilemodel->data(idx,Qt::UserRole).toString(); - + if(QMessageBox::warning(this,tr("Warning"),tr("Importing a key overwrites the host key that is currently used by this profile. This may disable your accounts. Do you still want to continue?"),QMessageBox::Yes|QMessageBox::Abort,QMessageBox::Abort)!=QMessageBox::Yes) return; QStringList fn; @@ -488,7 +489,7 @@ void MConfigDialog::importKey() return; } //read content (max: 10k to limit potential damage) - QStringList fc=QString::fromLatin1(fd.read(10240)).split("\n",QString::SkipEmptyParts); + QStringList fc=QString::fromLatin1(fd.read(10240)).split("\n",Qt::SkipEmptyParts); fd.close(); //check content if(fc.size()<3){ @@ -641,14 +642,14 @@ MAppStyleDialog::MAppStyleDialog(QWidget*par) style->addItems(k); if(k.contains(cs)) style->setCurrentIndex(k.indexOf(cs)+1); - + gl->addWidget(new QLabel(tr("Stylesheet:")),1,0); gl->addWidget(css=new QLineEdit,1,1); css->setText(QSettings().value("appstylesheet").toString()); QPushButton*p; gl->addWidget(p=new QPushButton("..."),1,2); connect(p,SIGNAL(clicked()),this,SLOT(selectCSS())); - + gl->setRowMinimumHeight(2,15); QHBoxLayout*hl; gl->addLayout(hl=new QHBoxLayout,3,0,1,3); diff --git a/commonlib/mapplication.cpp b/commonlib/mapplication.cpp index 176f215..e709b50 100644 --- a/commonlib/mapplication.cpp +++ b/commonlib/mapplication.cpp @@ -194,7 +194,7 @@ void MApplication::versionDlg() } -struct HelpUrl { +struct HelpUrl { enum Type {None, Item, Separator} type=None; QString label,url; HelpUrl(Type t,QString l,QString u=QString()):type(t),label(l),url(u){} @@ -296,19 +296,19 @@ MApplication::MApplication(int&ac,char**av) //locate settings setOrganizationName("MagicSmoke"); setApplicationName("MagicSmoke2"); - + //set icon setWindowIcon(QIcon(":/icon.png")); //install event filter for random generator installEventFilter(ef=new EFilter); - + //init GUI wrappers MBoxWrapper::setWarning([](QString title,QString text){QMessageBox::warning(nullptr,title,text);}); MProgressWrapper::setFactory([](QString label,QString button)->MProgressWrapper*{ return new MProgressWrapperGui(label,button); }); - + //check environment if(qEnvironmentVariableIsSet(ENV_DATADIR)) setDataDir(QString::fromLocal8Bit(qgetenv(ENV_DATADIR))); @@ -410,7 +410,7 @@ void MApplication::initLanguage() } //defaults if(lang!="--"&&lang!=""){ - QLocale::setDefault(lang); + QLocale::setDefault(QLocale(lang)); #ifndef Q_OS_WIN setenv("LANG",lang.toLatin1().data(),1); }else{ diff --git a/commonlib/misc/code39.cpp b/commonlib/misc/code39.cpp index d559742..8a237a8 100644 --- a/commonlib/misc/code39.cpp +++ b/commonlib/misc/code39.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: code39 // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2007-2011 @@ -100,7 +100,7 @@ QImage code39(QString 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()).toLatin1(); + QByteArray xpmsz=QString("%1 1 2 1").arg(rstr.size()).toLatin1(); xpm[0]=xpmsz.data(); xpm[1]="0\tg #000000"; xpm[2]="1\tg #FFFFFF"; diff --git a/commonlib/templates/labeldlg.cpp b/commonlib/templates/labeldlg.cpp index b24ffca..932f68e 100644 --- a/commonlib/templates/labeldlg.cpp +++ b/commonlib/templates/labeldlg.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: labeldlg // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2008-2016 @@ -25,6 +25,7 @@ #include #include // #include +#include #include #include #include @@ -37,132 +38,132 @@ #define COLS 20 MLabelDialog::MLabelDialog(QWidget*par,QPrinter* pn,int nl,QSizeF ls) - :QDialog(par) -{ - printer=pn; - numlabels=nl; - labelsize=ls; - maxrows=ROWS; - maxcols=COLS; - - setWindowTitle(tr("Label Printing Setup")); - - //get settings - QSettings set; - set.beginGroup("printer/"+printer->printerName()); - double ox=set.value("offsetx",0.0).toDouble(); - double oy=set.value("offsety",0.0).toDouble(); - double lsx=set.value("sizex",0.0).toDouble(); - double lsy=set.value("sizey",0.0).toDouble(); - QString mtrc=set.value("metric",tr("mm","defaultmetric: mm, in, cm")).toString(); - if(lsx==0.0 || lsy==0.0){ - //convert ticket template size - double dx=printer->logicalDpiX(); - double dy=printer->logicalDpiY(); - if(mtrc=="in"){ - lsx=ls.width()/dx; - lsy=ls.height()/dy; - }else - if(mtrc=="cm"){ - lsx=ls.width()/dx*2.54; - lsy=ls.height()/dy*2.54; - }else{//mm - lsx=ls.width()/dx*25.4; - lsy=ls.height()/dy*25.4; - } - } - - //display - - QVBoxLayout*vl; - QGridLayout*gl; - setLayout(vl=new QVBoxLayout); - vl->addLayout(gl=new QGridLayout,0); - - int ln=0; - gl->addWidget(new QLabel(tr("Label offset:")),ln,0); - gl->addWidget(offx=new QLineEdit(QString::number(ox)),ln,1); - offx->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); - gl->addWidget(new QLabel("x"),ln,2); - gl->addWidget(offy=new QLineEdit(QString::number(oy)),ln,3); - offy->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); - gl->addWidget(new QLabel(tr("Label size:")),++ln,0); - gl->addWidget(sizex=new QLineEdit(QString::number(lsx)),ln,1); - sizex->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); - gl->addWidget(new QLabel("x"),ln,2); - gl->addWidget(sizey=new QLineEdit(QString::number(lsy)),ln,3); - sizey->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); - gl->addWidget(new QLabel(tr("Unit:")),++ln,0); - gl->addWidget(metric=new QComboBox,ln,1,1,3); - metric->addItem(tr("Millimeter"),"mm"); - metric->addItem(tr("Centimeter"),"cm"); - metric->addItem(tr("Inch"),"in"); - gl->addWidget(warning=new QLabel(""),++ln,0,1,4); - QPalette pal=warning->palette(); - pal.setColor(QPalette::WindowText,Qt::red); - warning->setPalette(pal); - gl->setColumnStretch(++ln,10); - - vl->addSpacing(10); - vl->addWidget(new QLabel(tr("Page usage:")),0); - vl->addWidget(page=new QComboBox,0); - for(int i=0;iaddItem(tr("Page %1").arg(i+1),i); - oldpage=0; - - QScrollArea *sa; - QWidget*w=new QWidget; - vl->addWidget(sa=new QScrollArea,10); - w->setLayout(gl=new QGridLayout); - QToolButton*t; - gl->addWidget(t=new QToolButton,0,0); - t->setIcon(QIcon(":/arrowdiag.png")); - connect(t,SIGNAL(clicked()),this,SLOT(toggleAll())); - QSignalMapper *cmap=new QSignalMapper(this); - connect(cmap,SIGNAL(mapped(int)),this,SLOT(toggleColumn(int))); - for(int i=1;i<=COLS;i++){ - gl->addWidget(t=new QToolButton,0,i); - t->setIcon(QIcon(":/arrowdown.png")); - connect(t,SIGNAL(clicked()),cmap,SLOT(map())); - cmap->setMapping(t,i-1); - } - QSignalMapper *rmap=new QSignalMapper(this); - connect(rmap,SIGNAL(mapped(int)),this,SLOT(toggleRow(int))); - for(int i=1;i<=ROWS;i++){ - gl->addWidget(t=new QToolButton,i,0); - t->setIcon(QIcon(":/arrowright.png")); - connect(t,SIGNAL(clicked()),rmap,SLOT(map())); - rmap->setMapping(t,i-1); - for(int j=1;j<=COLS;j++){ - QCheckBox*b; - gl->addWidget(b=new QCheckBox,i,j); - checks.append(b); - connect(b,SIGNAL(clicked()),this,SLOT(savePage())); - } - } - sa->setWidget(w); - connect(page,SIGNAL(currentIndexChanged(int)),this,SLOT(updatePage())); - connect(sizex,SIGNAL(textChanged(const QString&)),this,SLOT(updatePage())); - connect(sizey,SIGNAL(textChanged(const QString&)),this,SLOT(updatePage())); - connect(metric,SIGNAL(currentIndexChanged(int)),this,SLOT(updatePage())); - - vl->addSpacing(15); - QHBoxLayout*hl; - vl->addLayout(hl=new QHBoxLayout); - hl->addStretch(10); - QPushButton*p; - hl->addWidget(p=new QPushButton(tr("Ok")),0); - connect(p,SIGNAL(clicked()),this,SLOT(accept())); - connect(p,SIGNAL(clicked()),this,SLOT(saveSettings())); - p->setDefault(true); - hl->addWidget(p=new QPushButton(tr("Cancel")),0); - connect(p,SIGNAL(clicked()),this,SLOT(reject())); - - //initialize - QListtpl; - for(int i=0;i<(ROWS*COLS);i++)tpl.append(true); - for(int i=0;iprinterName()); + double ox=set.value("offsetx",0.0).toDouble(); + double oy=set.value("offsety",0.0).toDouble(); + double lsx=set.value("sizex",0.0).toDouble(); + double lsy=set.value("sizey",0.0).toDouble(); + QString mtrc=set.value("metric",tr("mm","defaultmetric: mm, in, cm")).toString(); + if(lsx==0.0 || lsy==0.0){ + //convert ticket template size + double dx=printer->logicalDpiX(); + double dy=printer->logicalDpiY(); + if(mtrc=="in"){ + lsx=ls.width()/dx; + lsy=ls.height()/dy; + }else + if(mtrc=="cm"){ + lsx=ls.width()/dx*2.54; + lsy=ls.height()/dy*2.54; + }else{//mm + lsx=ls.width()/dx*25.4; + lsy=ls.height()/dy*25.4; + } + } + + //display + + QVBoxLayout*vl; + QGridLayout*gl; + setLayout(vl=new QVBoxLayout); + vl->addLayout(gl=new QGridLayout,0); + + int ln=0; + gl->addWidget(new QLabel(tr("Label offset:")),ln,0); + gl->addWidget(offx=new QLineEdit(QString::number(ox)),ln,1); + offx->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); + gl->addWidget(new QLabel("x"),ln,2); + gl->addWidget(offy=new QLineEdit(QString::number(oy)),ln,3); + offy->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); + gl->addWidget(new QLabel(tr("Label size:")),++ln,0); + gl->addWidget(sizex=new QLineEdit(QString::number(lsx)),ln,1); + sizex->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); + gl->addWidget(new QLabel("x"),ln,2); + gl->addWidget(sizey=new QLineEdit(QString::number(lsy)),ln,3); + sizey->setValidator(new QDoubleValidator(0.0,1000.0,2,this)); + gl->addWidget(new QLabel(tr("Unit:")),++ln,0); + gl->addWidget(metric=new QComboBox,ln,1,1,3); + metric->addItem(tr("Millimeter"),"mm"); + metric->addItem(tr("Centimeter"),"cm"); + metric->addItem(tr("Inch"),"in"); + gl->addWidget(warning=new QLabel(""),++ln,0,1,4); + QPalette pal=warning->palette(); + pal.setColor(QPalette::WindowText,Qt::red); + warning->setPalette(pal); + gl->setColumnStretch(++ln,10); + + vl->addSpacing(10); + vl->addWidget(new QLabel(tr("Page usage:")),0); + vl->addWidget(page=new QComboBox,0); + for(int i=0;iaddItem(tr("Page %1").arg(i+1),i); + oldpage=0; + + QScrollArea *sa; + QWidget*w=new QWidget; + vl->addWidget(sa=new QScrollArea,10); + w->setLayout(gl=new QGridLayout); + QToolButton*t; + gl->addWidget(t=new QToolButton,0,0); + t->setIcon(QIcon(":/arrowdiag.png")); + connect(t,SIGNAL(clicked()),this,SLOT(toggleAll())); + QSignalMapper *cmap=new QSignalMapper(this); + connect(cmap,SIGNAL(mapped(int)),this,SLOT(toggleColumn(int))); + for(int i=1;i<=COLS;i++){ + gl->addWidget(t=new QToolButton,0,i); + t->setIcon(QIcon(":/arrowdown.png")); + connect(t,SIGNAL(clicked()),cmap,SLOT(map())); + cmap->setMapping(t,i-1); + } + QSignalMapper *rmap=new QSignalMapper(this); + connect(rmap,SIGNAL(mapped(int)),this,SLOT(toggleRow(int))); + for(int i=1;i<=ROWS;i++){ + gl->addWidget(t=new QToolButton,i,0); + t->setIcon(QIcon(":/arrowright.png")); + connect(t,SIGNAL(clicked()),rmap,SLOT(map())); + rmap->setMapping(t,i-1); + for(int j=1;j<=COLS;j++){ + QCheckBox*b; + gl->addWidget(b=new QCheckBox,i,j); + checks.append(b); + connect(b,SIGNAL(clicked()),this,SLOT(savePage())); + } + } + sa->setWidget(w); + connect(page,SIGNAL(currentIndexChanged(int)),this,SLOT(updatePage())); + connect(sizex,SIGNAL(textChanged(const QString&)),this,SLOT(updatePage())); + connect(sizey,SIGNAL(textChanged(const QString&)),this,SLOT(updatePage())); + connect(metric,SIGNAL(currentIndexChanged(int)),this,SLOT(updatePage())); + + vl->addSpacing(15); + QHBoxLayout*hl; + vl->addLayout(hl=new QHBoxLayout); + hl->addStretch(10); + QPushButton*p; + hl->addWidget(p=new QPushButton(tr("Ok")),0); + connect(p,SIGNAL(clicked()),this,SLOT(accept())); + connect(p,SIGNAL(clicked()),this,SLOT(saveSettings())); + p->setDefault(true); + hl->addWidget(p=new QPushButton(tr("Cancel")),0); + connect(p,SIGNAL(clicked()),this,SLOT(reject())); + + //initialize + QListtpl; + for(int i=0;i<(ROWS*COLS);i++)tpl.append(true); + for(int i=0;i=0)return; mt=qRegisterMetaType(); +#if QT_VERSION < 0x060000 qRegisterMetaTypeStreamOperators(); +#endif } MLabelDialog::~MLabelDialog(){} int MLabelDialog::findLabel(int n,int&row,int&col)const { - //search allowed labels - int ctr=-1; - for(int p=0;p=0;r--) - for(int c=0;c=0;r--) + for(int c=0;ctext().toDouble(); - double py=offy->text().toDouble(); - //add rows/cols - px+=col*sizex->text().toDouble(); - py+=row*sizey->text().toDouble(); - //correct to DPI - QString mtrc=metric->itemData(metric->currentIndex()).toString(); - if(mtrc=="in"){ - px*=printer->logicalDpiX(); - py*=printer->logicalDpiY(); - }else - if(mtrc=="cm"){ - px*=printer->logicalDpiX()/2.54; - py*=printer->logicalDpiY()/2.54; - }else{ - px*=printer->logicalDpiX()/25.4; - py*=printer->logicalDpiY()/25.4; - } - //return - return QPointF(px,py); + //find it + int row=0,col=0; + findLabel(n,row,col); + //get offset + double px=offx->text().toDouble(); + double py=offy->text().toDouble(); + //add rows/cols + px+=col*sizex->text().toDouble(); + py+=row*sizey->text().toDouble(); + //correct to DPI + QString mtrc=metric->itemData(metric->currentIndex()).toString(); + if(mtrc=="in"){ + px*=printer->logicalDpiX(); + py*=printer->logicalDpiY(); + }else + if(mtrc=="cm"){ + px*=printer->logicalDpiX()/2.54; + py*=printer->logicalDpiY()/2.54; + }else{ + px*=printer->logicalDpiX()/25.4; + py*=printer->logicalDpiY()/25.4; + } + //return + return QPointF(px,py); } bool MLabelDialog::labelNeedsPageTurn(int n)const { - //find it - int pg,row=0,col=0; - pg=findLabel(n,row,col); - //page 0 needs no turn - if(pg<=0)return false; - //scan that page (all rows below label) - for(int r=maxrows-1;r>row;r--) - for(int c=0;crow;r--) + for(int c=0;csetChecked(checked[oldpage][i]); - } + for(int i=r*COLS;i<(r*COLS+COLS);i++){ + checked[oldpage][i]^=true; + checks[i]->setChecked(checked[oldpage][i]); + } } void MLabelDialog::toggleColumn(int c) { - for(int r=0;rsetChecked(checked[oldpage][i]); - } + for(int r=0;rsetChecked(checked[oldpage][i]); + } } void MLabelDialog::toggleAll() { - for(int i=0;i<(ROWS*COLS);i++){ - checked[oldpage][i]^=true; - checks[i]->setChecked(checked[oldpage][i]); - } + for(int i=0;i<(ROWS*COLS);i++){ + checked[oldpage][i]^=true; + checks[i]->setChecked(checked[oldpage][i]); + } } void MLabelDialog::savePage() { - for(int i=0;i<(ROWS*COLS);i++) - checked[oldpage][i]=checks[i]->isChecked(); + for(int i=0;i<(ROWS*COLS);i++) + checked[oldpage][i]=checks[i]->isChecked(); } void MLabelDialog::updatePage() { - //find how many rows/cols fit on the page - double lx=sizex->text().toDouble(); - double ly=sizey->text().toDouble(); - QRect pr=printer->pageRect(); - QString mtrc=metric->itemData(metric->currentIndex()).toString(); - if(mtrc=="in"){ - lx*=printer->logicalDpiX(); - ly*=printer->logicalDpiY(); - }else - if(mtrc=="cm"){ - lx*=printer->logicalDpiX()/2.54; - ly*=printer->logicalDpiY()/2.54; - }else{ - lx*=printer->logicalDpiX()/25.4; - ly*=printer->logicalDpiY()/25.4; - } - - bool dowarn=false; - if(ly>0.0){ - maxrows=pr.height()/ly; - if(maxrows>ROWS)maxrows=ROWS; - if(maxrows<1){ - maxrows=1; - dowarn=true; - } - }else maxrows=ROWS; - if(lx>0.0){ - maxcols=pr.width()/lx; - if(maxcols>COLS)maxcols=COLS; - if(maxcols<1){ - maxcols=1; - dowarn=true; - } - }else maxcols=COLS; - //update - oldpage=page->itemData(page->currentIndex()).toInt(); - for(int r=0;rsetChecked(b && checked[oldpage][i]); - checks[i]->setEnabled(b); - } - if(dowarn) - warning->setText(tr("Warning: the label may not fit on the page!")); - else - warning->setText(""); + //find how many rows/cols fit on the page + double lx=sizex->text().toDouble(); + double ly=sizey->text().toDouble(); + QRectF pr=printer->pageRect(QPrinter::DevicePixel); + QString mtrc=metric->itemData(metric->currentIndex()).toString(); + if(mtrc=="in"){ + lx*=printer->logicalDpiX(); + ly*=printer->logicalDpiY(); + }else + if(mtrc=="cm"){ + lx*=printer->logicalDpiX()/2.54; + ly*=printer->logicalDpiY()/2.54; + }else{ + lx*=printer->logicalDpiX()/25.4; + ly*=printer->logicalDpiY()/25.4; + } + + bool dowarn=false; + if(ly>0.0){ + maxrows=pr.height()/ly; + if(maxrows>ROWS)maxrows=ROWS; + if(maxrows<1){ + maxrows=1; + dowarn=true; + } + }else maxrows=ROWS; + if(lx>0.0){ + maxcols=pr.width()/lx; + if(maxcols>COLS)maxcols=COLS; + if(maxcols<1){ + maxcols=1; + dowarn=true; + } + }else maxcols=COLS; + //update + oldpage=page->itemData(page->currentIndex()).toInt(); + for(int r=0;rsetChecked(b && checked[oldpage][i]); + checks[i]->setEnabled(b); + } + if(dowarn) + warning->setText(tr("Warning: the label may not fit on the page!")); + else + warning->setText(""); } void MLabelDialog::saveSettings() { - QSettings set; - set.beginGroup("printer/"+printer->printerName()); - set.setValue("offsetx",offx->text().toDouble()); - set.setValue("offsety",offy->text().toDouble()); - set.setValue("sizex",sizex->text().toDouble()); - set.setValue("sizey",sizey->text().toDouble()); - set.setValue("metric",metric->itemData(metric->currentIndex()).toString()); + QSettings set; + set.beginGroup("printer/"+printer->printerName()); + set.setValue("offsetx",offx->text().toDouble()); + set.setValue("offsety",offy->text().toDouble()); + set.setValue("sizex",sizex->text().toDouble()); + set.setValue("sizey",sizey->text().toDouble()); + set.setValue("metric",metric->itemData(metric->currentIndex()).toString()); } @@ -375,262 +378,265 @@ void MLabelDialog::saveSettings() void MLabelConfig::configDialog(QWidget* parent) { - QDialog d(parent); - MLabelConfig ticket(MLabelConfig::Ticket),voucher(MLabelConfig::Voucher); - d.setWindowTitle(tr("Label Configuration")); - QFormLayout*fl; - d.setLayout(fl=new QFormLayout); - fl->addRow(new QLabel(tr("Ticket Labels:"))); - //each one: ask printer mode, ask label-page mode, printer/settings - QComboBox*t_prnmode,*t_pagmode,*t_prnbufmode; - fl->addRow(tr("Print Dialog:"),t_prnmode=new QComboBox); - t_prnmode->addItem(tr("Always ask for printer"),PrintAskAlways); - t_prnmode->addItem(tr("Ask if unknown or not present"),PrintAskIfUnknown); - t_prnmode->addItem(tr("Never ask for printer"),PrintAskNever); - t_prnmode->setCurrentIndex(ticket.printAskMode()); - fl->addRow(tr("Page Dialog:"),t_pagmode=new QComboBox); - t_pagmode->addItem(tr("Always ask for page layout"),PageAskAlways); - t_pagmode->addItem(tr("Ask if more than one label per page"),PageAskIfNeeded); - t_pagmode->addItem(tr("Never ask for page layout"),PageAskNever); - t_pagmode->setCurrentIndex(ticket.pageAskMode()); - QHBoxLayout*hl; - QLabel*t_prn;QMapt_prnset; - QToolButton*p; - QPrinter t_printer; - ticket.configurePrinter(t_printer); - fl->addRow(tr("Printer:"),hl=new QHBoxLayout); - hl->addWidget(t_prn=new QLabel(ticket.printerName()),1); - hl->addWidget(p=new QToolButton); - p->setText("..."); - auto settprn=[&]{ - MLabelPrintDialog pd(&t_printer,&d); + QDialog d(parent); + MLabelConfig ticket(MLabelConfig::Ticket),voucher(MLabelConfig::Voucher); + d.setWindowTitle(tr("Label Configuration")); + QFormLayout*fl; + d.setLayout(fl=new QFormLayout); + fl->addRow(new QLabel(tr("Ticket Labels:"))); + //each one: ask printer mode, ask label-page mode, printer/settings + QComboBox*t_prnmode,*t_pagmode,*t_prnbufmode; + fl->addRow(tr("Print Dialog:"),t_prnmode=new QComboBox); + t_prnmode->addItem(tr("Always ask for printer"),PrintAskAlways); + t_prnmode->addItem(tr("Ask if unknown or not present"),PrintAskIfUnknown); + t_prnmode->addItem(tr("Never ask for printer"),PrintAskNever); + t_prnmode->setCurrentIndex(ticket.printAskMode()); + fl->addRow(tr("Page Dialog:"),t_pagmode=new QComboBox); + t_pagmode->addItem(tr("Always ask for page layout"),PageAskAlways); + t_pagmode->addItem(tr("Ask if more than one label per page"),PageAskIfNeeded); + t_pagmode->addItem(tr("Never ask for page layout"),PageAskNever); + t_pagmode->setCurrentIndex(ticket.pageAskMode()); + QHBoxLayout*hl; + QLabel*t_prn;QMapt_prnset; + QToolButton*p; + QPrinter t_printer; + ticket.configurePrinter(t_printer); + fl->addRow(tr("Printer:"),hl=new QHBoxLayout); + hl->addWidget(t_prn=new QLabel(ticket.printerName()),1); + hl->addWidget(p=new QToolButton); + p->setText("..."); + auto settprn=[&]{ + MLabelPrintDialog pd(&t_printer,&d); pd.setWindowTitle(tr("Chose Printer for Tickets")); pd.setButtonLabel(tr("Set Printer")); // pd.setOptions(QAbstractPrintDialog::PrintShowPageSize); - if(pd.exec()!=QDialog::Accepted)return; - t_prn->setText(t_printer.printerName()); - }; - d.connect(p,&QToolButton::clicked,settprn); - fl->addRow(tr("Print Mode:"),t_prnbufmode=new QComboBox); - t_prnbufmode->addItem(tr("Direct Print")); - t_prnbufmode->addItem(tr("Use Buffer Pixmap")); - t_prnbufmode->setCurrentIndex((int)ticket.printMode()); - QFrame*frm; - fl->addRow(frm=new QFrame); - frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); - //Vouchers... - fl->addRow(new QLabel(tr("Voucher Labels:"))); - //each one: ask printer mode, ask label-page mode, printer/settings - QComboBox*v_prnmode,*v_pagmode,*v_prnbufmode; - fl->addRow(tr("Print Dialog:"),v_prnmode=new QComboBox); - v_prnmode->addItem(tr("Always ask for printer"),PrintAskAlways); - v_prnmode->addItem(tr("Ask if unknown or not present"),PrintAskIfUnknown); - v_prnmode->addItem(tr("Never ask for printer"),PrintAskNever); - v_prnmode->setCurrentIndex(voucher.printAskMode()); - fl->addRow(tr("Page Dialog:"),v_pagmode=new QComboBox); - v_pagmode->addItem(tr("Always ask for page layout"),PageAskAlways); - v_pagmode->addItem(tr("Ask if more than one label per page"),PageAskIfNeeded); - v_pagmode->addItem(tr("Never ask for page layout"),PageAskNever); - v_pagmode->setCurrentIndex(voucher.pageAskMode()); - QLabel*v_prn;QMapv_prnset; - QPrinter v_printer; - voucher.configurePrinter(v_printer); - fl->addRow(tr("Printer:"),hl=new QHBoxLayout); - hl->addWidget(v_prn=new QLabel(voucher.printerName()),1); - hl->addWidget(p=new QToolButton); - p->setText("..."); - auto setvprn=[&]{ - MLabelPrintDialog pd(&v_printer,&d); + if(pd.exec()!=QDialog::Accepted)return; + t_prn->setText(t_printer.printerName()); + }; + d.connect(p,&QToolButton::clicked,settprn); + fl->addRow(tr("Print Mode:"),t_prnbufmode=new QComboBox); + t_prnbufmode->addItem(tr("Direct Print")); + t_prnbufmode->addItem(tr("Use Buffer Pixmap")); + t_prnbufmode->setCurrentIndex((int)ticket.printMode()); + QFrame*frm; + fl->addRow(frm=new QFrame); + frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); + //Vouchers... + fl->addRow(new QLabel(tr("Voucher Labels:"))); + //each one: ask printer mode, ask label-page mode, printer/settings + QComboBox*v_prnmode,*v_pagmode,*v_prnbufmode; + fl->addRow(tr("Print Dialog:"),v_prnmode=new QComboBox); + v_prnmode->addItem(tr("Always ask for printer"),PrintAskAlways); + v_prnmode->addItem(tr("Ask if unknown or not present"),PrintAskIfUnknown); + v_prnmode->addItem(tr("Never ask for printer"),PrintAskNever); + v_prnmode->setCurrentIndex(voucher.printAskMode()); + fl->addRow(tr("Page Dialog:"),v_pagmode=new QComboBox); + v_pagmode->addItem(tr("Always ask for page layout"),PageAskAlways); + v_pagmode->addItem(tr("Ask if more than one label per page"),PageAskIfNeeded); + v_pagmode->addItem(tr("Never ask for page layout"),PageAskNever); + v_pagmode->setCurrentIndex(voucher.pageAskMode()); + QLabel*v_prn;QMapv_prnset; + QPrinter v_printer; + voucher.configurePrinter(v_printer); + fl->addRow(tr("Printer:"),hl=new QHBoxLayout); + hl->addWidget(v_prn=new QLabel(voucher.printerName()),1); + hl->addWidget(p=new QToolButton); + p->setText("..."); + auto setvprn=[&]{ + MLabelPrintDialog pd(&v_printer,&d); pd.setWindowTitle(tr("Chose Printer for Vouchers")); pd.setButtonLabel(tr("Set Printer")); // pd.setOptions(QAbstractPrintDialog::PrintShowPageSize); - if(pd.exec()!=QDialog::Accepted)return; - v_prn->setText(v_printer.printerName()); - }; - d.connect(p,&QToolButton::clicked,setvprn); - fl->addRow(tr("Print Mode:"),v_prnbufmode=new QComboBox); - v_prnbufmode->addItem(tr("Direct Print")); - v_prnbufmode->addItem(tr("Use Buffer Pixmap")); - v_prnbufmode->setCurrentIndex((int)voucher.printMode()); - //button... - fl->addRow(new QLabel(" ")); - fl->addRow(hl=new QHBoxLayout); - hl->addStretch(1); - QPushButton*b; - hl->addWidget(b=new QPushButton(tr("Ok"))); - d.connect(b,SIGNAL(clicked()),&d,SLOT(accept())); - hl->addWidget(b=new QPushButton(tr("Cancel"))); - d.connect(b,SIGNAL(clicked()),&d,SLOT(reject())); - //show dialog - if(d.exec()!=QDialog::Accepted)return; - //save settings - ticket.storePrinter(t_printer); - ticket.storeAskModes( - (MLabelConfig::PrintAskMode)t_prnmode->currentIndex(), - (MLabelConfig::PageAskMode)t_pagmode->currentIndex() - ); - ticket.storePrintMode((MLabelConfig::PrintMode)t_prnbufmode->currentIndex()); - voucher.storePrinter(v_printer); - voucher.storeAskModes( - (MLabelConfig::PrintAskMode)v_prnmode->currentIndex(), - (MLabelConfig::PageAskMode)v_pagmode->currentIndex() - ); - voucher.storePrintMode((MLabelConfig::PrintMode)v_prnbufmode->currentIndex()); + if(pd.exec()!=QDialog::Accepted)return; + v_prn->setText(v_printer.printerName()); + }; + d.connect(p,&QToolButton::clicked,setvprn); + fl->addRow(tr("Print Mode:"),v_prnbufmode=new QComboBox); + v_prnbufmode->addItem(tr("Direct Print")); + v_prnbufmode->addItem(tr("Use Buffer Pixmap")); + v_prnbufmode->setCurrentIndex((int)voucher.printMode()); + //button... + fl->addRow(new QLabel(" ")); + fl->addRow(hl=new QHBoxLayout); + hl->addStretch(1); + QPushButton*b; + hl->addWidget(b=new QPushButton(tr("Ok"))); + d.connect(b,SIGNAL(clicked()),&d,SLOT(accept())); + hl->addWidget(b=new QPushButton(tr("Cancel"))); + d.connect(b,SIGNAL(clicked()),&d,SLOT(reject())); + //show dialog + if(d.exec()!=QDialog::Accepted)return; + //save settings + ticket.storePrinter(t_printer); + ticket.storeAskModes( + (MLabelConfig::PrintAskMode)t_prnmode->currentIndex(), + (MLabelConfig::PageAskMode)t_pagmode->currentIndex() + ); + ticket.storePrintMode((MLabelConfig::PrintMode)t_prnbufmode->currentIndex()); + voucher.storePrinter(v_printer); + voucher.storeAskModes( + (MLabelConfig::PrintAskMode)v_prnmode->currentIndex(), + (MLabelConfig::PageAskMode)v_pagmode->currentIndex() + ); + voucher.storePrintMode((MLabelConfig::PrintMode)v_prnbufmode->currentIndex()); } QString MLabelConfig::tr(const char* s, const char* c) { - return QCoreApplication::translate("MLabelConfig",s,c); + return QCoreApplication::translate("MLabelConfig",s,c); } QString MLabelConfig::printerName() const { - QString key=m_type==Ticket?"ticket":"voucher"; - QSettings set; - set.beginGroup(req->settingsGroup()+"/"+key); - if(!set.contains("name"))return QString(); - return set.value("name").toString(); + QString key=m_type==Ticket?"ticket":"voucher"; + QSettings set; + set.beginGroup(req->settingsGroup()+"/"+key); + if(!set.contains("name"))return QString(); + return set.value("name").toString(); } bool MLabelConfig::selectPrinter(QPrinter& printer, bool force) { - bool gotit=configurePrinter(printer); - if(!force) - switch(printAskMode()){ - case PrintAskAlways:force=true;break; - case PrintAskIfUnknown:if(!gotit)force=true;break; - case PrintAskNever:/*do not override the force*/ break; - } - if(force){ - MLabelPrintDialog pd(&printer); - return pd.exec()==QDialog::Accepted; - }else - return gotit; + bool gotit=configurePrinter(printer); + if(!force) + switch(printAskMode()){ + case PrintAskAlways:force=true;break; + case PrintAskIfUnknown:if(!gotit)force=true;break; + case PrintAskNever:/*do not override the force*/ break; + } + if(force){ + MLabelPrintDialog pd(&printer); + return pd.exec()==QDialog::Accepted; + }else + return gotit; } QString MLabelConfig::cgroup() const { - const QString key=m_type==Ticket?"ticket":"voucher"; - return req->settingsGroup()+"/"+key; + const QString key=m_type==Ticket?"ticket":"voucher"; + return req->settingsGroup()+"/"+key; } static inline void dumpPrn(QPrinter&p,QString s) { qDebug()<<"printer"<() - << Paper_s(tr("Custom Size","paper type"),QPrinter::Custom,0,0) - << Paper_s(tr("A0","paper type"),QPrinter::A0,841,1189) - << Paper_s(tr("A1","paper type"),QPrinter::A1,594,841) - << Paper_s(tr("A2","paper type"),QPrinter::A2,420,594) - << Paper_s(tr("A3","paper type"),QPrinter::A3,297,420) - << Paper_s(tr("A4","paper type"),QPrinter::A4,210,297) - << Paper_s(tr("A5","paper type"),QPrinter::A5,148,210) - << Paper_s(tr("A6","paper type"),QPrinter::A6,105,148) - << Paper_s(tr("A7","paper type"),QPrinter::A7,74,105) - << Paper_s(tr("A8","paper type"),QPrinter::A8,52,74) - << Paper_s(tr("A9","paper type"),QPrinter::A9,37,52) - << Paper_s(tr("B0","paper type"),QPrinter::B0,1000,1414) - << Paper_s(tr("B1","paper type"),QPrinter::B1,707,1000) - << Paper_s(tr("B2","paper type"),QPrinter::B2,500,707) - << Paper_s(tr("B3","paper type"),QPrinter::B3,353,500) - << Paper_s(tr("B4","paper type"),QPrinter::B4,250,353) - << Paper_s(tr("B5","paper type"),QPrinter::B5,176,250) - << Paper_s(tr("B6","paper type"),QPrinter::B6,125,176) - << Paper_s(tr("B7","paper type"),QPrinter::B7,88,125) - << Paper_s(tr("B8","paper type"),QPrinter::B8,62,88) - << Paper_s(tr("B9","paper type"),QPrinter::B9,33,62) - << Paper_s(tr("B10","paper type"),QPrinter::B10,31,44) - << Paper_s(tr("C5E","paper type"),QPrinter::C5E,163,229) - << Paper_s(tr("U.S. Common 10 Envelope","paper type"),QPrinter::Comm10E,105,241) - << Paper_s(tr("DLE","paper type"),QPrinter::DLE,110,220) - << Paper_s(tr("Executive","paper type"),QPrinter::Executive,190.5,254) - << Paper_s(tr("Folio","paper type"),QPrinter::Folio,210,330) - << Paper_s(tr("Ledger","paper type"),QPrinter::Ledger,431.8,279.4) - << Paper_s(tr("Legal","paper type"),QPrinter::Legal,215.9,355.6) - << Paper_s(tr("Letter","paper type"),QPrinter::Letter,215.9,279.4) - << Paper_s(tr("Tabloid","paper type"),QPrinter::Tabloid,279.4,431.8) + << Paper_s(tr("Custom Size","paper type"),QPageSize::Custom,0,0) + << Paper_s(tr("A0","paper type"),QPageSize::A0,841,1189) + << Paper_s(tr("A1","paper type"),QPageSize::A1,594,841) + << Paper_s(tr("A2","paper type"),QPageSize::A2,420,594) + << Paper_s(tr("A3","paper type"),QPageSize::A3,297,420) + << Paper_s(tr("A4","paper type"),QPageSize::A4,210,297) + << Paper_s(tr("A5","paper type"),QPageSize::A5,148,210) + << Paper_s(tr("A6","paper type"),QPageSize::A6,105,148) + << Paper_s(tr("A7","paper type"),QPageSize::A7,74,105) + << Paper_s(tr("A8","paper type"),QPageSize::A8,52,74) + << Paper_s(tr("A9","paper type"),QPageSize::A9,37,52) + << Paper_s(tr("B0","paper type"),QPageSize::B0,1000,1414) + << Paper_s(tr("B1","paper type"),QPageSize::B1,707,1000) + << Paper_s(tr("B2","paper type"),QPageSize::B2,500,707) + << Paper_s(tr("B3","paper type"),QPageSize::B3,353,500) + << Paper_s(tr("B4","paper type"),QPageSize::B4,250,353) + << Paper_s(tr("B5","paper type"),QPageSize::B5,176,250) + << Paper_s(tr("B6","paper type"),QPageSize::B6,125,176) + << Paper_s(tr("B7","paper type"),QPageSize::B7,88,125) + << Paper_s(tr("B8","paper type"),QPageSize::B8,62,88) + << Paper_s(tr("B9","paper type"),QPageSize::B9,33,62) + << Paper_s(tr("B10","paper type"),QPageSize::B10,31,44) + << Paper_s(tr("C5E","paper type"),QPageSize::C5E,163,229) + << Paper_s(tr("U.S. Common 10 Envelope","paper type"),QPageSize::Comm10E,105,241) + << Paper_s(tr("DLE","paper type"),QPageSize::DLE,110,220) + << Paper_s(tr("Executive","paper type"),QPageSize::Executive,190.5,254) + << Paper_s(tr("Folio","paper type"),QPageSize::Folio,210,330) + << Paper_s(tr("Ledger","paper type"),QPageSize::Ledger,431.8,279.4) + << Paper_s(tr("Legal","paper type"),QPageSize::Legal,215.9,355.6) + << Paper_s(tr("Letter","paper type"),QPageSize::Letter,215.9,279.4) + << Paper_s(tr("Tabloid","paper type"),QPageSize::Tabloid,279.4,431.8) ; } - + MLabelPrintDialog::MLabelPrintDialog(QPrinter* prn, QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f) @@ -701,8 +707,8 @@ MLabelPrintDialog::MLabelPrintDialog(QPrinter* prn, QWidget* parent, Qt::WindowF QFormLayout*fl; setLayout(fl=new QFormLayout); fl->addRow(tr("Printer:"),mprnselect=new QComboBox); - mprnselect->setMinimumContentsLength(10); - mprnselect->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon); + mprnselect->setMinimumContentsLength(10); + mprnselect->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon); int cur=-1,def=-1; for(const QPrinterInfo&info:QPrinterInfo::availablePrinters()){ if(info.printerName()==prn->printerName())cur=mprnselect->count(); @@ -740,10 +746,10 @@ MLabelPrintDialog::MLabelPrintDialog(QPrinter* prn, QWidget* parent, Qt::WindowF QGridLayout*gl; fl->addRow(tr("Margins:"),gl=new QGridLayout); //qreal ml,mr,mt,mb; - QMarginsF marg=mprinter->pageLayout().margins(QPageLayout::Millimeter); + QMarginsF marg=mprinter->pageLayout().margins(QPageLayout::Millimeter); //mprinter->getPageMargins(&ml,&mt,&mr,&mb,QPrinter::Millimeter); - gl->addWidget(mfullpage=new QCheckBox(tr("Use Full Page")),0,0,1,3); - mfullpage->setChecked(mprinter->fullPage()); + gl->addWidget(mfullpage=new QCheckBox(tr("Use Full Page")),0,0,1,3); + mfullpage->setChecked(mprinter->fullPage()); gl->addWidget(mmargtop=new QDoubleSpinBox,1,1); mmargtop->setValue(marg.top()/moldunit); gl->addWidget(mmargleft=new QDoubleSpinBox,2,0); @@ -761,10 +767,10 @@ MLabelPrintDialog::MLabelPrintDialog(QPrinter* prn, QWidget* parent, Qt::WindowF QPushButton *cc; hl->addWidget(cc=new QPushButton(tr("Cancel"))); connect(cc,SIGNAL(clicked(bool)),this,SLOT(reject())); - + //make sure it is selected printerChanged(mprnselect->currentIndex()); - + //reset selected paper type and size from printer paperChanged(mpaper->currentIndex()); //reset margins from printer @@ -864,10 +870,10 @@ void MLabelPrintDialog::okBtnPressed() mprinter->setPaperSize(QPrinter::PaperSize(mpaper->itemData(mpaper->currentIndex()).toInt())); mprinter->setPageSizeMM(QSizeF(msizex->value()*moldunit,msizey->value()*moldunit)); //mprinter->setPageMargins(mmargleft->value()*moldunit, mmargtop->value()*moldunit, mmargright->value()*moldunit, mmargbottom->value()*moldunit, QPrinter::Millimeter); - mprinter->setFullPage(mfullpage->isChecked()); + mprinter->setFullPage(mfullpage->isChecked()); mprinter->setPageMargins(QMarginsF(mmargleft->value()*moldunit, mmargtop->value()*moldunit, mmargright->value()*moldunit, mmargbottom->value()*moldunit), QPageLayout::Millimeter); mprinter->setResolution(mresolution->itemData(mresolution->currentIndex()).toInt()); - + //close the dialog accept(); } diff --git a/commonlib/templates/labeldlg.h b/commonlib/templates/labeldlg.h index 6870b0a..e79febd 100644 --- a/commonlib/templates/labeldlg.h +++ b/commonlib/templates/labeldlg.h @@ -1,7 +1,7 @@ // // C++ Interface: labeldlg // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2008-2016 @@ -33,7 +33,7 @@ class MAGICSMOKE_COMMON_EXPORT MLabelConfig public: ///shows the configuration dialog static void configDialog(QWidget*parent=0); - + ///the type of label whose configuration is being queried enum LabelType { ///invalid config object @@ -51,18 +51,18 @@ class MAGICSMOKE_COMMON_EXPORT MLabelConfig MLabelConfig(const MLabelConfig&lc):m_type(lc.m_type){initMeta();} ///copies the config object MLabelConfig& operator=(const MLabelConfig&lc){m_type=lc.m_type;return *this;} - + ///returns the type represented by this config object LabelType labelType()const{return m_type;} - + ///returns the configured printer name (even if not available on the local system) QString printerName()const; - + ///configures the QPrinter object to the printer set for this label type; ///use selectPrinter if you want to fall back to a selection dialog /// \returns true if the printer was successfully configured bool configurePrinter(QPrinter&)const; - + ///configures the printer for this particular label type; ///whether the dialog is shown depends on settings and printer availability; ///if the dialog is shown the function remembers the new printer settings @@ -70,7 +70,7 @@ class MAGICSMOKE_COMMON_EXPORT MLabelConfig /// \param force if true: force showing the printer dialog /// \returns true if the selection was successful bool selectPrinter(QPrinter&printer,bool force=false); - + ///whether to ask for a printer when printing labels enum PrintAskMode{ //do not change the order of these entries! @@ -93,10 +93,10 @@ class MAGICSMOKE_COMMON_EXPORT MLabelConfig ///never ask, just assume the whole page is available PageAskNever=2, }; - + ///returns the policy for asking for a printer PrintAskMode printAskMode()const; - + ///returns the policy for asking for page layout PageAskMode pageAskMode()const; @@ -112,11 +112,11 @@ class MAGICSMOKE_COMMON_EXPORT MLabelConfig ///returns how to send data to the printer PrintMode printMode()const; - + private: LabelType m_type; static QString tr(const char*,const char*c=0); - + /// \internal helper to store printer settings for next time void storePrinter(QPrinter&); /// \internal helper to store ask modes @@ -125,10 +125,10 @@ class MAGICSMOKE_COMMON_EXPORT MLabelConfig void storePrintMode(PrintMode); /// \internal return the config group QString cgroup()const; - + /// \internal initialize meta type info void initMeta(); - + friend QDataStream&operator<<(QDataStream&,const MLabelConfig&); friend QDataStream&operator>>(QDataStream&,MLabelConfig&); }; @@ -146,14 +146,14 @@ class MAGICSMOKE_COMMON_EXPORT MLabelDialog:public QDialog MLabelDialog(QWidget*parent,QPrinter*printer,int numlabels,QSizeF labelsize); /**deletes the label dialog and stores its current settings*/ ~MLabelDialog(); - + /**returns the offset of label number n; relative to the coordinate system of the given paint device; starts at the bottom left of the page*/ QPointF labelOffset(int n)const; /**returns whether this label is on a new page*/ bool labelNeedsPageTurn(int n)const; ///returns whether there is only one label per page bool oneLabelPerPage()const; - + ///configures the printer for this particular label type ///whether the dialog is shown depends on settings and printer availability /// \param type type of label @@ -162,14 +162,14 @@ class MAGICSMOKE_COMMON_EXPORT MLabelDialog:public QDialog /// \returns true if the selection was successful static inline bool selectPrinter(MLabelConfig::LabelType type, QPrinter&printer, bool force=false) {return MLabelConfig(type).selectPrinter(printer,force);} - + public slots: ///shows the dialog if necessary - this depends on the local configuration for ///this label type ///if not shown it returns true (presuming the user would have wanted to print) ///if shown it returns true if the user clicked "Ok" and false otherwise bool conditionalExec(MLabelConfig::LabelType); - + private slots: /**internal: toggle Row button clicked*/ void toggleRow(int); @@ -177,14 +177,14 @@ class MAGICSMOKE_COMMON_EXPORT MLabelDialog:public QDialog void toggleColumn(int); /**internal: toggle all button clicked*/ void toggleAll(); - + /**internal: display correct page*/ void updatePage(); /**helper: save current/old page*/ void savePage(); /**internal: save settings for next time*/ void saveSettings(); - + private: QLineEdit *offx,*offy,*sizex,*sizey; QLabel *warning; @@ -194,7 +194,7 @@ class MAGICSMOKE_COMMON_EXPORT MLabelDialog:public QDialog QList >checked; QPrinter* printer; int numlabels,oldpage,maxrows,maxcols; - + /**internal helper: find coordinates of label n; returns page id; returns -1 on failure*/ int findLabel(int n,int&row,int&col)const; }; @@ -205,14 +205,14 @@ class MAGICSMOKE_COMMON_EXPORT MLabelPrintDialog:public QDialog { Q_OBJECT public: - explicit MLabelPrintDialog(QPrinter*,QWidget* parent = 0, Qt::WindowFlags f = 0); + explicit MLabelPrintDialog(QPrinter*,QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); public slots: void setButtonLabel(const QString&); private slots: void printerChanged(int); void paperChanged(int); void unitChanged(int); - + void okBtnPressed(); private: QPrinter*mprinter; @@ -223,7 +223,7 @@ class MAGICSMOKE_COMMON_EXPORT MLabelPrintDialog:public QDialog QPushButton*mokbtn; QCheckBox*mfullpage; double moldunit=1.; - + //internal: initialize paper types void initPaper(); }; diff --git a/commonlib/templates/odtrender.cpp b/commonlib/templates/odtrender.cpp index a92d485..378e92b 100644 --- a/commonlib/templates/odtrender.cpp +++ b/commonlib/templates/odtrender.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: odtrender // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2008-2011 @@ -37,7 +37,7 @@ class MOdfEngine:public MElamEngine MOdfEngine(MOdtRenderer* pa):parent(pa) { CharacterClassSettings cs=characterClasses(); - cs.setAssignmentChars(0,'='); + cs.setAssignmentChars('\0','='); cs.setOperatorClass(cs.operatorClass().remove(':')); QPairnc=cs.nameClass(); nc.second+=':'; @@ -64,32 +64,32 @@ class MOdtRendererPrivate { protected: friend class MOdtRenderer; - + //methods that the parent uses MOdtRendererPrivate(QString file,MOdtRenderer*p); ~MOdtRendererPrivate(); - + bool renderToFile(QFile&); - + //data the parent uses QString extension; MOdtRenderer::FileFormat fileformat; - + private: //methods that the parent does not call - + ///overall rendering: copies the templates content, calls render() void render(QIODevice*); - + ///content.xml rendering QList render(QDomNode node); - + ///scan string and replace variable values QString renderString(QString); - + ///gets a scalar variable QString getVariable(QString varname); - + //data the parent does not access //parent MOdtRenderer*parent; @@ -98,7 +98,7 @@ class MOdtRendererPrivate QFile tfile; //xml representation of the content.xml file in the template QDomDocument cdoc; - + //local variables and calculation engine Engine *calc; }; diff --git a/commonlib/widgets/centbox.h b/commonlib/widgets/centbox.h index 80e9c23..64831fd 100644 --- a/commonlib/widgets/centbox.h +++ b/commonlib/widgets/centbox.h @@ -1,7 +1,7 @@ // // C++ Interface: centbox // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2008-2011 @@ -15,7 +15,7 @@ #include #include -#include +#include #include "commonexport.h" @@ -24,15 +24,15 @@ class MAGICSMOKE_COMMON_EXPORT MCentSpinBox:public QAbstractSpinBox Q_OBJECT public: MCentSpinBox(QWidget*parent=0,int value=0,int maxValue=2147483647); - + virtual int value()const; virtual void setValue(int); - + virtual void setRange(int,int); - + virtual int minimumValue()const; virtual int maximumValue()const; - + void stepBy(int); protected: virtual QValidator::State validate(QString &input, int &pos) const; @@ -43,7 +43,7 @@ class MAGICSMOKE_COMMON_EXPORT MCentSpinBox:public QAbstractSpinBox void fixup(); private: int mval,mmax,mmin; - QRegExpValidator mvalid; + QRegularExpressionValidator mvalid; }; class MAGICSMOKE_COMMON_EXPORT MCentDialog:public QDialog @@ -51,9 +51,9 @@ class MAGICSMOKE_COMMON_EXPORT MCentDialog:public QDialog Q_OBJECT public: MCentDialog(QWidget*parent=0,QString title=QString(),QString label=QString(),int value=0,int maxValue=2147483647); - + virtual int value()const; - + static int getCents(QWidget*parent=0,QString title=QString(),QString label=QString(),int value=0,int maxValue=2147483647,bool *ok=0); private: MCentSpinBox*box; diff --git a/commonlib/widgets/seatplanview.cpp b/commonlib/widgets/seatplanview.cpp index 6b1b301..3150159 100644 --- a/commonlib/widgets/seatplanview.cpp +++ b/commonlib/widgets/seatplanview.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: seatplan viewer // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2017 @@ -53,7 +53,7 @@ static inline QVector getColors(const MOSeatPlan&plan,const MOSeatPlanGr void MSeatPlanView::resetPlan(const MOSeatPlan&p) { mplan=p; - + //parse plan for seats mrows.clear(); const QRect mr=QRect(QPoint(0,0),mplan.qSize()); @@ -112,7 +112,7 @@ void MSeatPlanView::resetPlan(const MOSeatPlan&p) qDebug()<<"WARNING: row"< rows -> seats p.setPen(QColor(Qt::blue)); p.setBrush(QColor(Qt::yellow)); @@ -305,3 +305,8 @@ QList MSeatPlanView::selection()const result<, (C) 2008-2011 @@ -63,9 +63,9 @@ QByteArray xmlize(QByteArray str,QString newline) if(c=='<')out+="<";else if(c=='>')out+=">";else if(c=='&')out+="&";else - if(c=='\n')out+=newline;else + if(c=='\n')out+=newline.toUtf8();else if(QChar(c).isSpace()||(c>=32 && static_cast(c)<=0x7f))out+=c; - else out+="&#"+QString::number((unsigned char)c)+";"; + else out+="&#"+QByteArray::number((unsigned char)c)+";"; } return out; } @@ -84,7 +84,7 @@ qint64 str2cent(QString s,bool localize) return mf.scanMoney(s); } -QRegExp priceRegExp(bool localize) +QRegularExpression priceRegExp(bool localize) { MLocalFormat mf; if(!localize)mf.setNonLocalized(); @@ -129,7 +129,7 @@ class MLocalFormat::Private:public SharedDPtr }; DEFINE_SHARED_DPTR(MLocalFormat); -//static +//static MLocalFormat MLocalFormat::defaultformat((int)1); MLocalFormat::MLocalFormat(int) @@ -321,10 +321,10 @@ void MLocalFormat::setNumberFormat(QChar dec,QChar thou,int dig) if(dec.isNull())d->m_decimal=QCoreApplication::translate("MLocalFormat",".","decimal dot")[0]; else d->m_decimal=dec; - + if(thou.isNull())d->m_thousand=QCoreApplication::translate("MLocalFormat",",","thousand division character")[0]; else d->m_thousand=thou; - + if(dig<0)d->m_thousanddigits=QCoreApplication::translate("MLocalFormat","0","digits between thousand division chars, <=0 means none").toInt(); else d->m_thousanddigits=dig; } @@ -477,7 +477,7 @@ QString MLocalFormat::formatDateTime(const TimeStamp& ts, QString format) const // % sign case '%':out+="%";break; //mistakes - default:out+="%"+format[i];break; + default:out+=QString("%")+format[i];break; } inp=false; }else{ @@ -685,13 +685,13 @@ double MLocalFormat::scanFloat(QString num)const return r; } -QRegExp MLocalFormat::moneyRegExp(bool allownegative,bool allowcurrency)const +QRegularExpression MLocalFormat::moneyRegExp(bool allownegative,bool allowcurrency)const { //main unit - QString r="[\\d"+QRegExp::escape(d->m_thousand)+"]+"; + QString r="[\\d"+QRegularExpression::escape(d->m_thousand)+"]+"; //fractions if(d->m_moneydecimals>0){ - r+=QRegExp::escape(d->m_decimal); + r+=QRegularExpression::escape(d->m_decimal); r+="\\d{"+QString::number(d->m_moneydecimals)+"}"; } //negative @@ -700,18 +700,18 @@ QRegExp MLocalFormat::moneyRegExp(bool allownegative,bool allowcurrency)const QString f="[-"; if(d->m_moneyneg.size()>0) if(d->m_moneyneg[0]!='\n' && d->m_moneyneg[0]!='-') - f+=QRegExp::escape(d->m_moneyneg[0]); + f+=QRegularExpression::escape(d->m_moneyneg[0]); f+="]?"; r=f+r; //back if(d->m_moneyneg.size()>1) - r+=QRegExp::escape(d->m_moneyneg[1])+"?"; + r+=QRegularExpression::escape(d->m_moneyneg[1])+"?"; } //currency if(allowcurrency && d->m_currency!="") - r+="("+QRegExp::escape(d->m_currency)+")?"; + r+="("+QRegularExpression::escape(d->m_currency)+")?"; //return - return QRegExp(r); + return QRegularExpression(r); } void MLocalFormat::setTimeZone(QString olsonname) diff --git a/iface/misc/misc.h b/iface/misc/misc.h index ef0d06d..b4f453d 100644 --- a/iface/misc/misc.h +++ b/iface/misc/misc.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include class TimeStamp; #include @@ -50,7 +50,7 @@ QString MSIFACE_EXPORT unix2time(qint64,bool localize=true); QString MSIFACE_EXPORT unix2dateTime(qint64,bool localize=true); /**return a (localized) regular expression that validates prices*/ -QRegExp MSIFACE_EXPORT priceRegExp(bool localize=true); +QRegularExpression MSIFACE_EXPORT priceRegExp(bool localize=true); ///returns the current directory (the one last used in a file dialog) QString MSIFACE_EXPORT currentDir(); @@ -111,23 +111,23 @@ class MSIFACE_EXPORT MLocalFormat MLocalFormat(const MOServerFormat&); /**deletes the formatter object*/ virtual ~MLocalFormat(); - + /**sets a new default format*/ static void setDefaultFormat(const MLocalFormat&); - + /**copies a formatter object*/ virtual MLocalFormat& operator=(const MLocalFormat&)=default; - + /**overrides the full names of week days, an empty list resets to the local translation, otherwise the list must be exactly seven entries long and starts with Sunday*/ virtual void setWeekDays(const QStringList&l=QStringList()); /**overrides the short week day names, an empty list resets to the local translation, otherwise the list must be exactly seven entries long and starts with Sunday (Sun)*/ virtual void setShortWeekDays(const QStringList&l=QStringList()); - + /**overrides the full names of months, an empty list resets to the local translation, otherwise the list must be exactly seven entries long and starts with January*/ virtual void setMonths(const QStringList&l=QStringList()); /**overrides the short names of months, an empty list resets to the local translation, otherwise the list must be exactly seven entries long and starts with January (Jan)*/ virtual void setShortMonths(const QStringList&l=QStringList()); - + /**overrides the formatting of money - the settings of numbers are re-used \param digitsCents defines how many digits are used for sub-amounts (cents), if zero no cents are used, normal are the values 0, 2 and 3; the default is 2 \param currency defines the symbol of the currency used, the default is an empty string @@ -141,29 +141,29 @@ class MSIFACE_EXPORT MLocalFormat \param positivePos defines where the positive sign is printed */ virtual void setMoneySign(QString negative="-",QString positive=QString(), MOServerFormat::MoneyPos negativePos=MOServerFormat::SignBeforeNum, MOServerFormat::MoneyPos positivePos=MOServerFormat::NoSign); - + /**overrides the formatting of numbers and money; \param decimal defines the character used to separate decimals from the main body, if QChar() is used it returns to the translation default (a dot "." in default localization) \param thousandDiv defines the character used to separate blocks of digits, if QChar() is used it returns to the translation default (comma "," in default) \param digitsDiv defines the amount of digits in a block, eg. the value 3 will format 1000 as 1,000 (none per default)*/ virtual void setNumberFormat(QChar decimal=QChar(),QChar thousandDiv=QChar(),int digitsDiv=-1); - + /**overrides the formatting of the AM/PM part of time display, resets to the localization if none given*/ virtual void setAP(QString am="--",QString pm="--"); - + /**overrides the local time zone \param olsonname the name of the local timezone in Olson notation, eg. "Europe/Berlin"*/ virtual void setTimeZone(QString olsonname); - + /**overrides the default formatting of date and time, if empty the translation default is used*/ virtual void setDateTimeFormat(QString dateformat=QString(),QString timeformat=QString(),QString datetimeformat=QString()); - + /**returns the currently set time zone of this formatter*/ virtual QString timeZone()const; - + /**overrides the formatting to be non-localized, numbers use decimal dot and no thousand separator, no currency symbol and "-" as negative sign; otherwise things stay the same; this is a helper for the shortcut methods like cent2str*/ virtual void setNonLocalized(); - + /**formats a date according to the given format, if none is given, the translation default is used \param date a QDate used as input, it is assumed to be local \param format a format string */ @@ -176,7 +176,7 @@ class MSIFACE_EXPORT MLocalFormat \param date a timestamp, it is converted to the local time of this local format object \param format a format string */ virtual QString formatDate(const TimeStamp& date,QString format=QString())const; - + /**formats a time according to the given format, if none is given, the translation default is used \param time a QTime used as input, it is assumed to be local \param format a format string */ @@ -189,7 +189,7 @@ class MSIFACE_EXPORT MLocalFormat \param time a timestamp, it is converted to the local time of this local format object \param format a format string */ virtual QString formatTime(const TimeStamp& time,QString format=QString())const; - + /**formats a date and time according to the given format, if none is given, the translation default is used \param time a QDateTime used as input, it is assumed to be local \param format a format string as specified by QDateTime::toString */ @@ -202,29 +202,29 @@ class MSIFACE_EXPORT MLocalFormat \param time a TimeStamp used as input, it is converted to the local time of this local format object \param format a format string as specified by QDateTime::toString */ virtual QString formatDateTime(const TimeStamp&time,QString format=QString())const; - - + + /**formats an integer number*/ virtual QString formatNumber(qint64)const; /**formats an integer number*/ virtual QString formatNumber(int n)const{return formatNumber(qint64(n));} /**formats an integer number*/ virtual QString formatNumber(uint n)const{return formatNumber(qint64(n));} - + /**formats a floating point number, this version does not use exponential display, but adheres to the settings of local decimal dot and thousands block division \param num the number to be formatted \param decimals the maximum number of digits after the decimal dot*/ virtual QString formatNumber(double num,uint decimals=4)const; - + enum MoneyFlag { PlainMoneyFormat=0, UseThousand=1, ShowCurrencySymbol=2, - + DefaultFormat=UseThousand|ShowCurrencySymbol }; Q_DECLARE_FLAGS(MoneyFlags,MoneyFlag); - + /**formats a money value \param num the amount in cents \param flags determines how the string will be formatted */ @@ -233,62 +233,62 @@ class MSIFACE_EXPORT MLocalFormat \param num the amount in cents \param usethousand if true the thousand block division is inserted */ virtual QString formatMoney(qint64 num,bool usethousand)const; - + /**scans an integer number and returns the value, non-numerical chars are ignored*/ virtual qint64 scanInt(QString)const; - + /**scans a money value and returns it in cents, non-numerical chars are ignored*/ virtual qint64 scanMoney(QString)const; - + /**scans a floating point number and returns it, non-numerical chars are ignored*/ virtual double scanFloat(QString)const; - + /**returns the names used for week days*/ QStringList weekDayNames()const; /**returns the abbreviations used for week days*/ QStringList shortWeekDayNames()const; - + /**returns the names used for months*/ QStringList monthNames()const; /**returns the names used for months*/ QStringList shortMonthNames()const; - + /**returns the currency symbol*/ QString currency()const; - + /**returns the decimal dot symbol*/ QChar decimalDot()const; - + /**returns the thousand separator if used, otherwise an empty string*/ QString thousandSeparator()const; - + /**returns the amount of digits between thousand separators*/ int thousandDigits()const; - + /**returns the amount of decimals in a money value*/ int moneyDecimals()const; - + /**returns the text for AM in 12-hour clock format*/ QString amText()const; /**returns the text for PM in 12-hour clock format*/ QString pmText()const; - + /**returns the negative sign for money values*/ QString moneyNegativeSign()const; /**returns the positive sign for money values*/ QString moneyPositiveSign()const; - + /**returns a regular expression matching money values \param allownegative if given the resulting RegExp allows to use negative values \param allowcurrency if given the resulting RegExp allows to use the currency symbol */ - QRegExp moneyRegExp(bool allownegative=false,bool allowcurrency=false)const; - + QRegularExpression moneyRegExp(bool allownegative=false,bool allowcurrency=false)const; + /**returns the default format for dates*/ QString dateFormat()const; - + /**returns the default format for times*/ QString timeFormat()const; - + /**returns the default format for date/time*/ QString dateTimeFormat()const; protected: diff --git a/iface/msinterface.cpp b/iface/msinterface.cpp index d3da893..f7a0e7e 100644 --- a/iface/msinterface.cpp +++ b/iface/msinterface.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: msinterface // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2009-2011 @@ -46,7 +46,7 @@ static QString dataDir; QString MSInterface::resolveDir(const QString &dirspec) { //resolve pattern - const QStringList dirspecl=dirspec.split('/',QString::KeepEmptyParts); + const QStringList dirspecl=dirspec.split('/',Qt::KeepEmptyParts); bool notfirst=false; QString rdir; for(QString dcom:dirspecl){ @@ -112,7 +112,7 @@ bool MSInterface::login(QString username,QString passwd) } if(lg.stage()!=lg.Success)return false; //schedule re-login before session times out - int msecs=QDateTime::currentDateTime().msecsTo(QDateTime::fromTime_t(lg.getvalidtill())); + int msecs=QDateTime::currentDateTime().msecsTo(QDateTime::fromSecsSinceEpoch(lg.getvalidtill())); msecs-=120000;//do it 2 min before session runs out if(msecs>100000)//but only if it does not become annoying... QTimer::singleShot(msecs,this,SIGNAL(needRelogin())); diff --git a/iface/templates/templates.cpp b/iface/templates/templates.cpp index aa6222c..bb487bd 100644 --- a/iface/templates/templates.cpp +++ b/iface/templates/templates.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: templates // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2008-2011 @@ -129,9 +129,9 @@ void MTemplateStore::updateTemplates(bool force) //make sure directory exists QDir(req->dataDir()).mkpath("templates"); //do we need an update yet? - QDateTime last=QDateTime::fromTime_t(set.value("lastupdate",0).toInt()+300); + QDateTime last=QDateTime::fromSecsSinceEpoch(set.value("lastupdate",0).toInt()+300); if(last>=QDateTime::currentDateTime() && !force)return; - + //get local info QStringList files=set.childGroups(); QMap fmap; @@ -142,25 +142,25 @@ void MTemplateStore::updateTemplates(bool force) t.setflags(set.value(files[i]+"/flags").toString()); fmap.insert(files[i],t); } - + //display progress dialog MProgressWrapper *progress=MProgressWrapper::create(QCoreApplication::translate("MTemplateStore","Retrieving templates from server.")); progress->setRange(0,1); progress->setValue(0); QObject progparent;progress->setParent(&progparent); - + //get remote info, assume it is still valid if unable to retrieve it MTGetTemplateList gtl=req->queryGetTemplateList(); if(gtl.hasError())return; //remember update time - set.setValue("lastupdate",QDateTime::currentDateTime().toTime_t()); + set.setValue("lastupdate",QDateTime::currentDateTime().toSecsSinceEpoch()); //scan and create new list QListnf=gtl.gettemplates(); QMapnfmap; for(int i=0;isetRange(0,nfiles.size()); @@ -187,14 +187,14 @@ void MTemplateStore::updateTemplates(bool force) } } files=fmap.keys(); - + //clean up directory QDir dir(dname); QStringList dfiles=dir.entryList(QDir::Files); for(int i=0;i, (C) 2007-2011 @@ -37,7 +37,7 @@ MOEvent::MOEvent(qint64 i) operator=(ge.getevent().value()); } -QRegExp MOEvent::priceRegExp()const +QRegularExpression MOEvent::priceRegExp()const { return ::priceRegExp(); } @@ -80,6 +80,6 @@ QList< MOEventPrice > MOEvent::priceFiltered() const ret<, (C) 2007-2011 @@ -15,6 +15,7 @@ #include #include +#include #ifndef MSIFACE_EXPORT #define MSIFACE_EXPORT Q_DECL_IMPORT @@ -31,31 +32,31 @@ class MSIFACE_EXPORT MOEvent:public MOEventAbstract Q_PROPERTY(QString startDateString READ startDateString) Q_PROPERTY(QString endTimeString READ endTimeString) Q_PROPERTY(QString priceString READ priceString) - Q_PROPERTY(QRegExp priceRegExp READ priceRegExp) + Q_PROPERTY(QRegularExpression priceRegExp READ priceRegExp) Q_PROPERTY(bool isValid READ isValid) Q_PROPERTY(QList priceFiltered READ priceFiltered) public: /**get event directly from server*/ MOEvent(qint64); - + /**alias for id()*/ inline Nullable eventid()const{return id();} - + /**returns the start time of the event as localized string*/ QString startTimeString()const; /**returns the start date as localized string*/ QString startDateString()const; /**returns the end time of the event as localized string*/ QString endTimeString()const; - + /**returns the price as a localized string*/ QString priceString()const; /**returns the local regular expression for prices*/ - QRegExp priceRegExp()const; - + QRegularExpression priceRegExp()const; + /**returns whether the event is valid. an event can be invalid if it is uninitialized (negative ID) or the server request failed*/ bool isValid()const{return !eventid().isNull() && eventid().value()>0;} - + ///returns only the prices that this user can order for QList priceFiltered()const; }; diff --git a/iface/wext/seatplanobj.cpp b/iface/wext/seatplanobj.cpp index b318a94..5e3b66f 100644 --- a/iface/wext/seatplanobj.cpp +++ b/iface/wext/seatplanobj.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: MOOrder // -// Description: +// Description: // // // Author: Konrad Rosenbaum , (C) 2009-2011 @@ -41,7 +41,7 @@ static bool mocv= static inline QList getcategories(const MOEventSaleInfo&ei,QString spec) { - const QStringList specl=spec.split(' ',QString::SkipEmptyParts); + const QStringList specl=spec.split(' ',Qt::SkipEmptyParts); QListprc; QListids; QStringList abbrs; @@ -91,7 +91,7 @@ static inline QRect str2rect(QString s) { QListil; - for(QString c:s.split(' ',QString::SkipEmptyParts)) + for(QString c:s.split(' ',Qt::SkipEmptyParts)) il<, (C) 2007-2011 @@ -53,12 +53,12 @@ MCartTab::MCartTab(QString pk) { profilekey=pk; deliveryaddrid=invoiceaddrid=-1; - + QVBoxLayout*vl;QHBoxLayout*hl; QPushButton*p; QLabel*lab; QFrame*frm; - + //Shopping Cart Tab setLayout(vl=new QVBoxLayout); vl->addLayout(hl=new QHBoxLayout); @@ -104,7 +104,7 @@ MCartTab::MCartTab(QString pk) connect(vouchers,SIGNAL(linkActivated(const QString&)),this,SLOT(changeVoucher(QString))); fl->addRow(tr("Remaining Sum:"),priceremain=new QLabel("0.0")); //hl2->addStretch(1); - + hl->addWidget(frm=new QFrame,0); frm->setFrameShape(QFrame::VLine); hl->addLayout(vl2=new QVBoxLayout,1); @@ -152,7 +152,7 @@ MCartTab::MCartTab(QString pk) connect(p,SIGNAL(clicked()),this,SLOT(cartReserve())); hl->addWidget(p=new QPushButton(tr("Clear"))); connect(p,SIGNAL(clicked()),this,SLOT(initCart())); - + //fill tables if(!req->hasRight(req->RCreateOrder)&&!req->hasRight(req->RCreateReservation)){ setEnabled(false); @@ -429,7 +429,7 @@ void MCartTab::cartAddVoucher() QHBoxLayout*hl; QGridLayout*gl; QStandardItemModel mdl; - QRegExpValidator regv(priceRegExp(),this); + QRegularExpressionValidator regv(priceRegExp(),this); QListprc=MTGetValidVoucherPrices::query().getprices(); mdl.insertRows(0,prc.size()); mdl.insertColumns(0,1); @@ -1020,7 +1020,7 @@ QWidget *MCartTableDelegate::createEditor(QWidget *parent, { //base class if(index.column()!=0)return 0; - + QSpinBox *editor = new QSpinBox(parent); editor->setRange(1,1000); editor->installEventFilter(const_cast(this)); diff --git a/taurus b/taurus index 12f3c87..6de1146 160000 --- a/taurus +++ b/taurus @@ -1 +1 @@ -Subproject commit 12f3c8701cfc7a78be3f2ee2df46e7a11df3c00e +Subproject commit 6de114674cc91776552ebf2e38b09e82628409cf -- 1.7.2.5