master #61

Merged
andrey merged 3 commits from master into release 2020-08-13 14:44:38 +03:00
7 changed files with 44 additions and 18 deletions

2
pip

Submodule pip updated: 294831df17...31a347250f

View File

@@ -106,7 +106,7 @@ const QAD::IODevice PI2QADIODevice(const PIVariantTypes::IODevice & v) {
const QAD::File PI2QADFile(const PIVariantTypes::File & v) {
return QAD::File(PI2QString(v.file), PI2QString(v.filter), v.is_abs);
return QAD::File(PI2QString(v.file), PI2QString(v.filter), v.is_abs, v.is_save);
}
@@ -116,7 +116,7 @@ const QAD::Dir PI2QADDir(const PIVariantTypes::Dir & v) {
const PIVariantTypes::File QAD2PIFile(const QAD::File & v) {
return PIVariantTypes::File(Q2PIString(v.file), Q2PIString(v.filter), v.is_abs);
return PIVariantTypes::File(Q2PIString(v.file), Q2PIString(v.filter), v.is_abs, v.is_save);
}

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(qad)
set(_QAD_MAJOR 1)
set(_QAD_MINOR 5)
set(_QAD_MINOR 6)
set(_QAD_REVISION 0)
set(_QAD_SUFFIX )
set(_QAD_COMPANY SHS)

View File

@@ -721,10 +721,18 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
//if (mark_in) {p->setPen(pa); p->setBrush(ba);}
//if (mark_out) {p->setPen(pr); p->setBrush(br);}
if (im_bus.isNull()) {
QPen _pen(p->pen());
for (int i = 0; i < segments.size(); ++i) {
_pen.setWidthF(pen_width);
p->setPen(_pen);
p->drawLine(pol[segments[i].first], pol[segments[i].second]);
if (pointSegmentsCount(segments[i].first) > 2) p->drawEllipse(pol[segments[i].first], pen_width*0.7, pen_width*0.7);
if (pointSegmentsCount(segments[i].first) > 2) {
_pen.setWidthF(pen_width + 3.);
p->setPen(_pen);
p->drawPoint(pol[segments[i].first]);
}
}
p->setPen(_pen);
} else {
QBrush br;
br.setTextureImage(im_bus);

View File

@@ -45,7 +45,6 @@ namespace QAD {
struct QAD_EXPORT Enum {
Enum(const QString & n = QString()): enum_name(n) {}
Enum(const QMetaEnum & meta, int selected = 0);
QString toString() const {return selected;} // obsolete, use selectedName()
int selectedValue() const;
QString selectedName() const {return selected;}
bool selectValue(int v);
@@ -64,15 +63,18 @@ namespace QAD {
};
struct QAD_EXPORT File {
File(const QString & p = QString(), const QString & f = QString(), bool abs = false): file(p), filter(f), is_abs(abs) {}
File(const QString & p = QString(), const QString & f = QString(), bool abs = false, bool save_mode = false):
file(p), filter(f), is_abs(abs), is_save(save_mode) {}
QString toString() const {return file;}
QString file;
QString filter;
bool is_abs;
bool is_save;
};
struct QAD_EXPORT Dir {
Dir(const QString & d = QString(), bool abs = false): dir(d), is_abs(abs) {}
Dir(const QString & d = QString(), bool abs = false):
dir(d), is_abs(abs) {}
QString toString() const {return dir;}
QString dir;
bool is_abs;
@@ -113,8 +115,8 @@ inline QDataStream & operator >>(QDataStream & s, QAD::Enum & v) {s >> v.enum_na
inline QDebug operator <<(QDebug s, const QAD::Enum & v) {s.nospace() << v.selected; return s.space();}
Q_DECLARE_METATYPE(QAD::File)
inline QDataStream & operator <<(QDataStream & s, const QAD::File & v) {s << v.file << v.filter << v.is_abs; return s;}
inline QDataStream & operator >>(QDataStream & s, QAD::File & v) {s >> v.file >> v.filter >> v.is_abs; return s;}
inline QDataStream & operator <<(QDataStream & s, const QAD::File & v) {s << v.file << v.filter << uchar((v.is_abs ? 1 : 0) + (v.is_save ? 2 : 0)); return s;}
inline QDataStream & operator >>(QDataStream & s, QAD::File & v) {uchar f(0); s >> v.file >> v.filter >> f; v.is_abs = ((f & 1) == 1); v.is_save = ((f & 2) == 2); return s;}
inline QDebug operator <<(QDebug s, const QAD::File & v) {s.nospace() << v.file; return s.space();}
Q_DECLARE_METATYPE(QAD::Dir)

View File

@@ -101,7 +101,7 @@ void StringListEdit::editItem() {
PathEdit::PathEdit(QWidget * parent): QWidget(parent), lay(QBoxLayout::LeftToRight, this) {
is_dir = is_abs = false;
is_dir = is_abs = is_save = false;
filter = tr("All files(*)");
line = new CLineEdit(this);
//line->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -134,10 +134,24 @@ void PathEdit::resizeEvent(QResizeEvent *) {
}
void PathEdit::setValue(const QString & v) {
line->setText(v);
if (!is_dir && is_save)
butt_select->setIcon(QIcon(":/icons/document-save.png"));
else
butt_select->setIcon(QIcon(":/icons/document-open.png"));
}
void PathEdit::select() {
QString ret;
if (is_dir) ret = QFileDialog::getExistingDirectory(this, tr("Select directory"), value());
else ret = QFileDialog::getSaveFileName(this, tr("Select file"), value(), filter);
else {
if (is_save)
ret = QFileDialog::getSaveFileName(this, tr("Select file"), value(), filter);
else
ret = QFileDialog::getOpenFileName(this, tr("Select file"), value(), filter);
}
if (ret.isEmpty()) return;
if (!is_abs)
ret = QDir::current().relativeFilePath(ret);
@@ -465,16 +479,18 @@ void QVariantEdit::_setEnum(const QAD::Enum & v) {
void QVariantEdit::_setFile(const QAD::File & v) {
_path->is_dir = false;
_path->filter = v.filter;
_path->is_abs = v.is_abs;
_path->is_save = v.is_save;
_path->setValue(v.file);
_path->filter = v.filter;
_path->is_abs = v.is_abs;
}
void QVariantEdit::_setDir(const QAD::Dir & v) {
_path->is_dir = true;
_path->setValue(v.dir);
_path->is_abs = v.is_abs;
_path->setValue(v.dir);
}

View File

@@ -75,9 +75,9 @@ public:
QString value() const {return line->text();}
bool is_dir, is_abs;
bool is_dir, is_abs, is_save;
QString filter;
private:
virtual void changeEvent(QEvent * e);
virtual void resizeEvent(QResizeEvent * );
@@ -87,7 +87,7 @@ private:
QPushButton * butt_select;
public slots:
void setValue(const QString & v) {line->setText(v);}
void setValue(const QString & v);
private slots:
void select();