Make RegularExpressions const and parse legacy format
This commit is contained in:
parent
84edddce80
commit
9a004f8671
@ -85,20 +85,39 @@ Geometry::Format Geometry::set(QString str)
|
|||||||
}
|
}
|
||||||
return Geometry::CornerDimensions;
|
return Geometry::CornerDimensions;
|
||||||
}
|
}
|
||||||
else if((match = centerDimensionSimple.match(str)).hasMatch()){
|
else if((match = cornerDimensionAlternate.match(str)).hasMatch()){
|
||||||
qDebug()<<"format is CenterDimensions with center =0,0";
|
qDebug() << "format is <width>x<height>[<+|-xoffset><+|-yoffset>]";
|
||||||
center[0] = 0;
|
if(match.lastCapturedIndex() ==2){
|
||||||
center[1] = 0;
|
qDebug() << "format is CenterDimensions with center =0,0";
|
||||||
dimension[0] = match.captured(1).toInt();
|
center[0] = 0;
|
||||||
dimension[1] = match.captured(2).toInt();
|
center[1] = 0;
|
||||||
computeCorner0();
|
dimension[0] = match.captured(1).toInt();
|
||||||
computeCorner1();
|
dimension[1] = match.captured(2).toInt();
|
||||||
if (adjustCorners()) {
|
computeCorner0();
|
||||||
// Order is important here!
|
computeCorner1();
|
||||||
computeDimensions();
|
if (adjustCorners()) {
|
||||||
computeCenter();
|
// Order is important here!
|
||||||
|
computeDimensions();
|
||||||
|
computeCenter();
|
||||||
|
}
|
||||||
|
return Geometry::CenterDimensions;
|
||||||
}
|
}
|
||||||
return Geometry::CenterDimensions;
|
else if(match.lastCapturedIndex() ==4){
|
||||||
|
qDebug() << "format is CornerDimensions";
|
||||||
|
corner[0][0] = match.captured(3).toInt();
|
||||||
|
corner[0][1] = match.captured(4).toInt();
|
||||||
|
dimension[0] = match.captured(1).toInt();
|
||||||
|
dimension[1] = match.captured(2).toInt();
|
||||||
|
computeCenter();
|
||||||
|
computeCorner1();
|
||||||
|
if (adjustCorners()) {
|
||||||
|
// Order is important here!
|
||||||
|
computeDimensions();
|
||||||
|
computeCenter();
|
||||||
|
}
|
||||||
|
return Geometry::CornerDimensions;
|
||||||
|
}
|
||||||
|
else return Geometry::FormatCustom;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug()<<"Warning: Could not parse format of string: "<<str;
|
qDebug()<<"Warning: Could not parse format of string: "<<str;
|
||||||
|
@ -49,10 +49,10 @@ public:
|
|||||||
void setCorners(int c0x, int c0y, int c1x, int c1y);
|
void setCorners(int c0x, int c0y, int c1x, int c1y);
|
||||||
QString getString(Geometry::Format format = Geometry::FormatNone);
|
QString getString(Geometry::Format format = Geometry::FormatNone);
|
||||||
private:
|
private:
|
||||||
QRegularExpression corners = QRegularExpression("(-?\\d*),(-?\\d*):(-?\\d*),(-?\\d*)");
|
const QRegularExpression corners = QRegularExpression("(-?\\d*),(-?\\d*):(-?\\d*),(-?\\d*)");
|
||||||
QRegularExpression centerDimension = QRegularExpression("(-?\\d*),(-?\\d*):(-?\\d*)x(-?\\d*)");
|
const QRegularExpression centerDimension = QRegularExpression("(-?\\d*),(-?\\d*):(-?\\d*)x(-?\\d*)");
|
||||||
QRegularExpression cornerDimension = QRegularExpression("(-?\\d*)[,x](-?\\d*)[+-](-?\\d*)[+-](-?\\d*)");
|
const QRegularExpression cornerDimension = QRegularExpression("(-?\\d*)[,:](-?\\d*)[+-](-?\\d*)[+-](-?\\d*)");
|
||||||
QRegularExpression centerDimensionSimple = QRegularExpression("(\\d*)x(\\d*)");
|
const QRegularExpression cornerDimensionAlternate = QRegularExpression("(\\d*)x(\\d*)[+]?(-?\\d+)?[+]?(-?\\d+)?");
|
||||||
bool adjustCorners(void);
|
bool adjustCorners(void);
|
||||||
void computeCorner0(void);
|
void computeCorner0(void);
|
||||||
void computeCorner1(void);
|
void computeCorner1(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user