version 2.0.0_alpha
Important! All QtWraps macros renamed! Qt 6 support Graphic export feature qad_types cross-Qt small changes
This commit is contained in:
@@ -94,7 +94,13 @@ bool EMainWindow::eventFilter(QObject * o, QEvent * e) {
|
||||
if (tdocks.contains((QDockWidget*)o))
|
||||
popup = popup || ((QDockWidget*)o)->titleBarWidget()->geometry().contains(((QMouseEvent*)e)->pos());
|
||||
if (popup) {
|
||||
createPopupMenu()->popup(((QMouseEvent*)e)->globalPos());
|
||||
createPopupMenu()->popup(
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
((QMouseEvent*)e)->globalPos()
|
||||
#else
|
||||
((QMouseEvent*)e)->globalPosition().toPoint()
|
||||
#endif
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
#include <QDesktopWidget>
|
||||
#include <QInputDialog>
|
||||
#include <QClipboard>
|
||||
#include <QRadioButton>
|
||||
@@ -138,7 +137,8 @@ public slots:
|
||||
void newFile();
|
||||
void openFile();
|
||||
void openFiles();
|
||||
bool saveFile(bool ask = false);
|
||||
bool saveFile(bool ask);
|
||||
bool saveFile() {return saveFile(false);}
|
||||
bool saveAsFile();
|
||||
void clearRecent();
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ public slots:
|
||||
void setDuplicatesEnabled(bool yes) {duplicates_ = yes;}
|
||||
void setLimit(int l);
|
||||
void setHistoryColor(const QColor & c);
|
||||
void clear(bool silent = false);
|
||||
void clear(bool silent);
|
||||
void clear() {clear(false);}
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ void AlignedTextItem::setFont(const QFont & f) {
|
||||
|
||||
QFont AlignedTextItem::sceneFont(const QFont & f) {
|
||||
QFont ret = f;
|
||||
double scl = 16. / QApplication::fontMetrics().size(0, "0").height();
|
||||
double scl = 16. / fontHeight();
|
||||
ret.setPointSizeF(ret.pointSizeF() * scl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -609,9 +609,9 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
if (endpoints().contains(selPoint))
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
|
||||
}
|
||||
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::MidButton)) btncnt++;
|
||||
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||
if (btncnt > 0) mm_mods = e->modifiers();
|
||||
if (btncnt >= 2 && e->button() == Qt::RightButton) {
|
||||
//qDebug() << "bus revert";
|
||||
@@ -722,9 +722,9 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
||||
mm_mods = Qt::KeyboardModifiers();
|
||||
int btncnt = 0;
|
||||
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::MidButton)) btncnt++;
|
||||
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||
if (btncnt == 0) mm_cancel = false;
|
||||
if (new_segment) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchAccept", Q_ARG(BlockBusItem * , this));
|
||||
|
||||
@@ -168,9 +168,10 @@ void BlockItem::clearPins() {
|
||||
void BlockItem::clearDecors() {
|
||||
bool pbs = false;
|
||||
if (scene()) pbs = scene()->blockSignals(true);
|
||||
if (scene())
|
||||
if (scene()) {
|
||||
foreach (QGraphicsItem * i, decors_)
|
||||
scene()->sendEvent(i, new QGraphicsSceneEvent(QEvent::Close));
|
||||
}
|
||||
qDeleteAll(decors_);
|
||||
decors_.clear();
|
||||
if (scene()) {
|
||||
|
||||
@@ -14,14 +14,6 @@
|
||||
const QString _BlockView_Mime_ = "_BlockView_copypaste_";
|
||||
|
||||
|
||||
template <typename T> QSet<T> QList2QSet(const QList<T> & l) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
return QSet<T>(l.begin(), l.end());
|
||||
#else
|
||||
return QSet<T>::fromList(l);
|
||||
#endif
|
||||
}
|
||||
|
||||
BlockView::BlockView(QWidget * parent): QGraphicsView(parent), tmp_bus(true) {
|
||||
_init();
|
||||
}
|
||||
@@ -218,7 +210,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
if (me->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::MidButton )) btncnt++;
|
||||
if (me->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||
mm_cancel = btncnt >= 2;
|
||||
match_bus = bus_from = 0;
|
||||
hpin = 0;
|
||||
@@ -266,7 +258,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
mm_drag = moved = false;
|
||||
screen_point = me->screenPos();
|
||||
scene_point = me->scenePos();
|
||||
if ((me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
|
||||
if ((me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
|
||||
thumbShow();
|
||||
restartTimer(timer_thumb, thumb_hide_delay);
|
||||
return true;
|
||||
@@ -525,10 +517,10 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::MidButton)) btncnt++;
|
||||
if (me->buttons().testFlag(QT_MID_BUTTON)) btncnt++;
|
||||
cur_bus = 0;
|
||||
mm_cancel = btncnt > 0;
|
||||
if (mm_cancel || (me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
|
||||
if (mm_cancel || (me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
|
||||
mm_ci = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -665,19 +657,19 @@ void BlockView::timerEvent(QTimerEvent * e) {
|
||||
void BlockView::wheelEvent(QWheelEvent * e) {
|
||||
if (!navigation) return;
|
||||
if (wheel_zoom || e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
double scl = 1. - e->angleDelta().y() / 500.;
|
||||
#else
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
double scl = 1. - e->delta() / 500.;
|
||||
#else
|
||||
double scl = 1. - e->angleDelta().y() / 500.;
|
||||
#endif
|
||||
if (!is_nav_anim || (nav_anim.state() != QPropertyAnimation::Running))
|
||||
nav_target = _nav();
|
||||
QRectF r = nav_target;
|
||||
double vw = viewport()->width(), vh = viewport()->height();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
double cx = double(e->position().x()) / vw, cy = double(e->position().y()) / vh;
|
||||
#else
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
double cx = double(e->pos().x()) / vw, cy = double(e->pos().y()) / vh;
|
||||
#else
|
||||
double cx = double(e->position().x()) / vw, cy = double(e->position().y()) / vh;
|
||||
#endif
|
||||
double pw = r.width(), ph = r.height();
|
||||
r.setWidth(r.width() * scl);
|
||||
@@ -692,7 +684,7 @@ void BlockView::wheelEvent(QWheelEvent * e) {
|
||||
|
||||
void BlockView::mousePressEvent(QMouseEvent * event) {
|
||||
press_point = event->pos();
|
||||
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
|
||||
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
|
||||
setCursor(Qt::ClosedHandCursor);
|
||||
//sel_rect.hide();
|
||||
if (sel_rect.scene())
|
||||
@@ -723,7 +715,7 @@ void BlockView::scrolled() {
|
||||
void BlockView::mouseMoveEvent(QMouseEvent * event) {
|
||||
if (!event) return;
|
||||
if (navigation) {
|
||||
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
|
||||
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
|
||||
QPoint dp = (press_point - event->pos());
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + dp.x());
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value() + dp.y());
|
||||
@@ -740,7 +732,7 @@ void BlockView::mouseMoveEvent(QMouseEvent * event) {
|
||||
|
||||
|
||||
void BlockView::mouseDoubleClickEvent(QMouseEvent * event) {
|
||||
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
|
||||
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
|
||||
fitInView();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,8 @@ protected slots:
|
||||
void startBusPointMove(int bus_type);
|
||||
void endBusPointMove();
|
||||
void pinHoverInOut(BlockItemPin * pin);
|
||||
void checkPaste(bool queued = false);
|
||||
void checkPaste(bool queued);
|
||||
void checkPaste() {checkPaste(false);}
|
||||
|
||||
public slots:
|
||||
void setGridPen(const QPen & pen) {grid_pen = pen; _updateBack();}
|
||||
|
||||
@@ -119,7 +119,7 @@ void _DTSizeItem::doubleClick() {
|
||||
|
||||
|
||||
void _DTSizeItem::resizeHandles() {
|
||||
double sz = QApplication::fontMetrics().size(0, "0").height() / 3.;
|
||||
double sz = fontHeight() / 3.;
|
||||
QRectF r(-sz, -sz, sz*2, sz*2);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
rects[i].setRect(r);
|
||||
@@ -235,7 +235,7 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
|
||||
ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize());
|
||||
ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize());
|
||||
widget_props->setEnabled(false);
|
||||
int fh = qMax<int>(QApplication::fontMetrics().size(0, "0").height(), 22);
|
||||
int fh = qMax<int>(fontHeight(), 22);
|
||||
int thick = lineThickness();
|
||||
QSize sz(fh * 2.5, fh);
|
||||
ui->comboLineStyle->setIconSize(sz);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "markdown.h"
|
||||
#include <QIODevice>
|
||||
#include <QDebug>
|
||||
#ifndef NO_MARKDOWN
|
||||
extern "C" {
|
||||
|
||||
@@ -1 +1 @@
|
||||
qad_library(graphic "Gui;Widgets;OpenGL" "qad_widgets;${OPENGL_LIBRARIES}")
|
||||
qad_library(graphic "Gui;Widgets;OpenGL;OpenGLWidgets" "qad_widgets;${OPENGL_LIBRARIES}")
|
||||
|
||||
@@ -212,10 +212,20 @@ bool Graphic::eventFilter(QObject * o, QEvent * e) {
|
||||
break;
|
||||
case QEvent::TouchUpdate: {
|
||||
if (!navigation || !gestures) break;
|
||||
QList<QTouchEvent::TouchPoint> tpl = ((QTouchEvent*)e)->touchPoints();
|
||||
QList<QTouchEvent::TouchPoint> tpl =
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
((QTouchEvent*)e)->touchPoints();
|
||||
#else
|
||||
((QTouchEvent*)e)->points();
|
||||
#endif
|
||||
if (tpl.size() == 2) {
|
||||
need_mouse_pan = false;
|
||||
QPointF dp = tpl[0].scenePos() - tpl[1].scenePos();
|
||||
QPointF dp =
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
tpl[0].scenePos() - tpl[1].scenePos();
|
||||
#else
|
||||
tpl[0].scenePosition() - tpl[1].scenePosition();
|
||||
#endif
|
||||
gesture_angle = rad2deg_qpie * qAtan2(qAbs(dp.y()), qAbs(dp.x()));
|
||||
}
|
||||
} break;
|
||||
@@ -432,7 +442,7 @@ void Graphic::canvasMousePressEvent(QMouseEvent * e) {
|
||||
startpos = prevpos;
|
||||
startpos_r = canvas2real(startpos);
|
||||
if (cancel || gestures) return;
|
||||
if (e->button() == Qt::MidButton) curaction = gaMove;
|
||||
if (e->button() == QT_MID_BUTTON) curaction = gaMove;
|
||||
if (e->button() == Qt::RightButton) {
|
||||
if (bufferActive) {
|
||||
curpos = startpos;
|
||||
@@ -700,6 +710,7 @@ void Graphic::setButtons(Graphic::Buttons b) {
|
||||
ui->graphic_buttonClear->setVisible(b.testFlag(Clear));
|
||||
ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure));
|
||||
ui->graphic_buttonSave->setVisible(b.testFlag(Save));
|
||||
ui->graphic_buttonExport->setVisible(b.testFlag(Export));
|
||||
ui->graphic_buttonClose->setVisible(b.testFlag(Close));
|
||||
ui->graphic_checkPause->setVisible(b.testFlag(Pause));
|
||||
if (ui->graphic_buttonAutofit ->isVisible() || ui->graphic_checkGrid ->isVisible() || ui->graphic_checkGuides->isVisible() ||
|
||||
@@ -793,10 +804,8 @@ void Graphic::setDefaultRect(const QRectF & rect) {
|
||||
}
|
||||
|
||||
|
||||
void Graphic::saveImage() {
|
||||
QString str = QFileDialog::getSaveFileName(this, tr("Save Image"), ppath, "PNG(*.png);;JPEG(*.jpg *.jpeg);;BMP(*.bmp);;TIFF(*.tiff *.tif);;PPM(*.ppm)");
|
||||
if (str == "") return;
|
||||
ppath = str;
|
||||
void Graphic::saveImage(QString filename) {
|
||||
ppath = filename;
|
||||
QPixmap im(canvas->size());
|
||||
canvas->render(&im);
|
||||
im.save(ppath);
|
||||
@@ -804,6 +813,50 @@ void Graphic::saveImage() {
|
||||
}
|
||||
|
||||
|
||||
void Graphic::exportGraphics(QString filename) {
|
||||
ppath = filename;
|
||||
QFile f(filename);
|
||||
if (!f.open(QIODevice::ReadWrite)) {
|
||||
QMessageBox::critical(this, tr("Export graphics"), tr("Can`t open file \"%1\"!").arg(filename));
|
||||
return;
|
||||
}
|
||||
f.resize(0);
|
||||
QTextStream ts(&f);
|
||||
ts << "#";
|
||||
for (int i = 0; i < graphics.size(); ++i) {
|
||||
GraphicType & g(graphics[i]);
|
||||
if (!g.visible) continue;
|
||||
ts << ";" << (g.name + "_X") << ";" << (g.name + "_Y");
|
||||
}
|
||||
ts << "\n";
|
||||
bool has_data = true;
|
||||
int ind = 0;
|
||||
QString line;
|
||||
while (has_data) {
|
||||
has_data = false;
|
||||
line.clear();
|
||||
line += QString::number(ind + 1);
|
||||
for (int i = 0; i < graphics.size(); ++i) {
|
||||
GraphicType & g(graphics[i]);
|
||||
if (!g.visible) continue;
|
||||
if (ind >= g.polyline.size()) {
|
||||
line += ";;";
|
||||
continue;
|
||||
}
|
||||
has_data = true;
|
||||
line += ";";
|
||||
line += QString::number(g.polyline[ind].x(), 'g', 9);
|
||||
line += ";";
|
||||
line += QString::number(g.polyline[ind].y(), 'g', 9);
|
||||
}
|
||||
++ind;
|
||||
line += "\n";
|
||||
if (has_data)
|
||||
ts << line;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setOpenGL(bool on) {
|
||||
#ifdef HAS_GL
|
||||
isOGL = on;
|
||||
@@ -1546,6 +1599,20 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_graphic_buttonSave_clicked() {
|
||||
QString f = QFileDialog::getSaveFileName(this, tr("Save Image"), ppath, "PNG(*.png);;JPEG(*.jpg *.jpeg);;BMP(*.bmp);;TIFF(*.tiff *.tif);;PPM(*.ppm)");
|
||||
if (f.isEmpty()) return;
|
||||
saveImage(f);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_graphic_buttonExport_clicked() {
|
||||
QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)");
|
||||
if (f.isEmpty()) return;
|
||||
exportGraphics(f);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_graphic_checkGuides_toggled(bool checked) {
|
||||
guides = checked;
|
||||
setGuidesCursor();
|
||||
|
||||
@@ -124,19 +124,20 @@ public:
|
||||
|
||||
typedef QVector<QVector<QPointF> > GraphicsData;
|
||||
enum GraphicAction {gaNone, gaZoomInRect, gaZoomRangeX, gaZoomRangeY, gaMove};
|
||||
enum Button {NoButtons = 0x0,
|
||||
AllButtons = 0xFFFFFFFF,
|
||||
Autofit = 0x01,
|
||||
Grid = 0x02,
|
||||
CursorAxis = 0x04,
|
||||
Fullscreen = 0x20,
|
||||
enum Button {NoButtons = 0x0,
|
||||
AllButtons = 0xFFFFFFFF,
|
||||
Autofit = 0x01,
|
||||
Grid = 0x02,
|
||||
CursorAxis = 0x04,
|
||||
Fullscreen = 0x20,
|
||||
BorderInputs = 0x40,
|
||||
Legend = 0x80,
|
||||
Configure = 0x100,
|
||||
Save = 0x200,
|
||||
Clear = 0x800,
|
||||
Close = 0x1000,
|
||||
Pause = 0x2000,
|
||||
Legend = 0x80,
|
||||
Configure = 0x100,
|
||||
Save = 0x200,
|
||||
Export = 0x400,
|
||||
Clear = 0x800,
|
||||
Close = 0x1000,
|
||||
Pause = 0x2000,
|
||||
StandartButtons = 0x2FFF
|
||||
};
|
||||
enum Alignment {Left, Right};
|
||||
@@ -314,9 +315,11 @@ public slots:
|
||||
void setVisualRect(const QRectF & rect);
|
||||
void setDefaultRect(const QRectF & rect);
|
||||
void autofit() {on_graphic_buttonAutofit_clicked();}
|
||||
void saveImage();
|
||||
void saveImage(QString filename);
|
||||
void exportGraphics(QString filename);
|
||||
void clear();
|
||||
void update(bool force = false);
|
||||
void update(bool force);
|
||||
void update() {update(false);}
|
||||
void updateGraphics() {findGraphicsRect(); update();}
|
||||
void setCurrentGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curGraphic = arg;}
|
||||
void setTraceGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curTrace = arg;}
|
||||
@@ -421,7 +424,8 @@ protected slots:
|
||||
void on_graphic_buttonAutofit_clicked();
|
||||
void on_graphic_buttonConfigure_clicked();
|
||||
void on_graphic_buttonFullscreen_clicked() {fullscreen();}
|
||||
void on_graphic_buttonSave_clicked() {saveImage();}
|
||||
void on_graphic_buttonSave_clicked();
|
||||
void on_graphic_buttonExport_clicked();
|
||||
void on_graphic_checkGrid_toggled(bool checked) {grid = checked; update();}
|
||||
void on_graphic_checkGuides_toggled(bool checked);
|
||||
void on_graphic_actionExpandX_triggered(bool checked);
|
||||
@@ -462,7 +466,9 @@ public:
|
||||
__GraphicRegistrator__() {
|
||||
qRegisterMetaType<QVector<QPointF> >("QVector<QPointF>");
|
||||
qRegisterMetaType<Graphic::GraphicsData>("Graphic::GraphicsData");
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
qRegisterMetaTypeStreamOperators<Graphic::GraphicsData>("Graphic::GraphicsData");
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>564</width>
|
||||
<height>484</height>
|
||||
<width>575</width>
|
||||
<height>440</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -180,6 +180,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="graphic_buttonExport">
|
||||
<property name="toolTip">
|
||||
<string>Export graphics ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -20,7 +20,11 @@ private:
|
||||
if (e->type() != QEvent::Paint) return QWidget::event(e);
|
||||
e->accept();
|
||||
QStyleOption opt;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
opt.init(this);
|
||||
#else
|
||||
opt.initFrom(this);
|
||||
#endif
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
emit paintEvent((QPaintEvent * )e);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "piqt.h"
|
||||
#include "qvariantedit.h"
|
||||
#if QT_VERSION >= 0x050200
|
||||
# include <QGeoCoordinate>
|
||||
#endif
|
||||
|
||||
|
||||
const QAD::Enum PI2QADEnum(const PIVariantTypes::Enum & el) {
|
||||
@@ -60,24 +57,105 @@ const QVariant PI2QVariant(const PIVariant & v) {
|
||||
|
||||
|
||||
const PIVariant Q2PIVariant(const QVariant & v) {
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
switch (v.type()) {
|
||||
case QVariant::Bool: return PIVariant(v.toBool());
|
||||
case QVariant::Int: return PIVariant(v.toInt());
|
||||
case QVariant::UInt: return PIVariant(v.toUInt());
|
||||
case QVariant::LongLong: return PIVariant(v.toLongLong());
|
||||
case QVariant::ULongLong: return PIVariant(v.toULongLong());
|
||||
case QVariant::Double: return PIVariant(v.toDouble());
|
||||
case QVariant::ByteArray: return PIVariant(Q2PIByteArray(v.toByteArray()));
|
||||
case QVariant::String: return PIVariant(Q2PIString(v.toString()));
|
||||
case QVariant::StringList: return PIVariant(Q2PIStringList(v.toStringList()));
|
||||
case QVariant::Time: return PIVariant(Q2PITime(v.toTime()));
|
||||
case QVariant::Date: return PIVariant(Q2PIDate(v.toDate()));
|
||||
case QVariant::DateTime: return PIVariant(Q2PIDateTime(v.toDateTime()));
|
||||
case QVariant::Color: return PIVariant(Q2PIColor(v.value<QColor>()));
|
||||
#else
|
||||
switch (v.metaType().id()) {
|
||||
#endif
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Bool:
|
||||
#else
|
||||
case QMetaType::Bool:
|
||||
#endif
|
||||
return PIVariant(v.toBool());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Int:
|
||||
#else
|
||||
case QMetaType::Int:
|
||||
#endif
|
||||
return PIVariant(v.toInt());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::UInt:
|
||||
#else
|
||||
case QMetaType::UInt:
|
||||
#endif
|
||||
return PIVariant(v.toUInt());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::LongLong:
|
||||
#else
|
||||
case QMetaType::LongLong:
|
||||
#endif
|
||||
return PIVariant(v.toLongLong());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::ULongLong:
|
||||
#else
|
||||
case QMetaType::ULongLong:
|
||||
#endif
|
||||
return PIVariant(v.toULongLong());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Double:
|
||||
#else
|
||||
case QMetaType::Double:
|
||||
#endif
|
||||
return PIVariant(v.toDouble());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::ByteArray:
|
||||
#else
|
||||
case QMetaType::QByteArray:
|
||||
#endif
|
||||
return PIVariant(Q2PIByteArray(v.toByteArray()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::String:
|
||||
#else
|
||||
case QMetaType::QString:
|
||||
#endif
|
||||
return PIVariant(Q2PIString(v.toString()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::StringList:
|
||||
#else
|
||||
case QMetaType::QStringList:
|
||||
#endif
|
||||
return PIVariant(Q2PIStringList(v.toStringList()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Time:
|
||||
#else
|
||||
case QMetaType::QTime:
|
||||
#endif
|
||||
return PIVariant(Q2PITime(v.toTime()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Date:
|
||||
#else
|
||||
case QMetaType::QDate:
|
||||
#endif
|
||||
return PIVariant(Q2PIDate(v.toDate()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::DateTime:
|
||||
#else
|
||||
case QMetaType::QDateTime:
|
||||
#endif
|
||||
return PIVariant(Q2PIDateTime(v.toDateTime()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Color:
|
||||
#else
|
||||
case QMetaType::QColor:
|
||||
#endif
|
||||
return PIVariant(Q2PIColor(v.value<QColor>()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Point:
|
||||
case QVariant::PointF: return PIVariant(Q2PIPoint(v.toPointF()));
|
||||
case QVariant::PointF:
|
||||
#else
|
||||
case QMetaType::QPoint:
|
||||
case QMetaType::QPointF:
|
||||
#endif
|
||||
return PIVariant(Q2PIPoint(v.toPointF()));
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Rect:
|
||||
case QVariant::RectF: return PIVariant(Q2PIRect(v.toRectF()));
|
||||
case QVariant::RectF:
|
||||
#else
|
||||
case QMetaType::QRect:
|
||||
case QMetaType::QRectF:
|
||||
#endif
|
||||
return PIVariant(Q2PIRect(v.toRectF()));
|
||||
default: break;
|
||||
}
|
||||
if (v.canConvert<float>()) return PIVariant(v.value<float>());
|
||||
@@ -126,7 +204,7 @@ const PIVariantTypes::Dir QAD2PIDir(const QAD::Dir & v) {
|
||||
}
|
||||
|
||||
|
||||
#if QT_VERSION >= 0x050200
|
||||
#ifdef PIQT_HAS_GEOPOSITION
|
||||
const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v) {
|
||||
PIGeoPosition p(v);
|
||||
p.transformTo(PIGeoPosition::Cartesian);
|
||||
|
||||
@@ -20,16 +20,28 @@
|
||||
#ifndef PIQT_H
|
||||
#define PIQT_H
|
||||
|
||||
#include "pimathmatrix.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "qad_types.h"
|
||||
#include <QVector3D>
|
||||
#include <QDateTime>
|
||||
#include <QColor>
|
||||
#if QT_VERSION >= 0x050200
|
||||
|
||||
#include "pimathmatrix.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "qad_types.h"
|
||||
#include "piqt_macros.h"
|
||||
#if QT_VERSION_MAJOR == 5
|
||||
# if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
# define PIQT_HAS_GEOPOSITION
|
||||
# endif
|
||||
#endif
|
||||
#if QT_VERSION_MAJOR == 6
|
||||
# if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
||||
# define PIQT_HAS_GEOPOSITION
|
||||
# endif
|
||||
#endif
|
||||
#ifdef PIQT_HAS_GEOPOSITION
|
||||
# include <QGeoCoordinate>
|
||||
# include "pigeoposition.h"
|
||||
#endif
|
||||
#include "piqt_macros.h"
|
||||
#include "qad_piqt_export.h"
|
||||
|
||||
|
||||
@@ -137,7 +149,7 @@ QAD_PIQT_EXPORT const PIVariantTypes::IODevice QAD2PIIODevice(const QAD::IODevic
|
||||
|
||||
//inline const PIVariant QString2PIVariant(const QString & v) {return PIVariant::readFromString(QString2PIString(v));}
|
||||
|
||||
#if QT_VERSION >= 0x050200
|
||||
#ifdef PIQT_HAS_GEOPOSITION
|
||||
QAD_PIQT_EXPORT const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v);
|
||||
QAD_PIQT_EXPORT const PIGeoPosition Q2PIGeoPosition(const QGeoCoordinate & v);
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,14 @@
|
||||
namespace PIQt {
|
||||
|
||||
template<typename T> T removePtr(T*) {}
|
||||
template<typename T> QArgument<T> qargument(const T & v) {return QArgument<T>(QMetaType::typeName(qMetaTypeId<T>()), v);}
|
||||
template<typename T> QArgument<T> qargument(const T & v) {
|
||||
return QArgument<T>(
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
QMetaType::typeName(qMetaTypeId<T>())
|
||||
#else
|
||||
QMetaType::fromType<T>().name()
|
||||
#endif
|
||||
, v);}
|
||||
|
||||
template <typename SR, typename O, typename... ARGS>
|
||||
void piqConnect(PIObject * source, const char * event, void(*func)(void*,ARGS...), O * target, SR(O::*slot)(ARGS...)) {
|
||||
|
||||
@@ -5,39 +5,38 @@ ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter
|
||||
HighlightingRule rule;
|
||||
|
||||
valueNameFormat.setForeground(QColor(0, 64, 154));
|
||||
rule.pattern = QRegExp("[^=]"); //"\\b[A-Za-z0-9_]+(?=\\()");
|
||||
rule.pattern = QRegularExpression("[^=]"); //"\\b[A-Za-z0-9_]+(?=\\()");
|
||||
rule.format = valueNameFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
valueFormat.setForeground(QColor(192, 0, 0));
|
||||
rule.pattern = QRegExp("=[^\n]*");
|
||||
rule.pattern = QRegularExpression("=[^\n]*");
|
||||
rule.format = valueFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
equalFormat.setFontWeight(QFont::Bold);
|
||||
equalFormat.setForeground(QColor(96, 126, 0));
|
||||
rule.pattern = QRegExp("=");
|
||||
rule.pattern = QRegularExpression("=");
|
||||
rule.format = equalFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
sectionFormat.setFontWeight(QFont::Bold);
|
||||
sectionFormat.setForeground(QColor(0, 32, 64));
|
||||
rule.pattern = QRegExp("\\[.*\\]");
|
||||
rule.pattern = QRegularExpression("\\[.*\\]");
|
||||
rule.format = sectionFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
//substFormat.setFontWeight(QFont::Bold);
|
||||
substFormat.setForeground(QColor(192, 0, 192));
|
||||
rule.pattern = QRegExp("\\$\\{.*\\}+");
|
||||
rule.pattern.setMinimal(true);
|
||||
rule.pattern = QRegularExpression("\\$\\{.*\\}+");
|
||||
//rule.pattern.setMinimal(true);
|
||||
rule.format = substFormat;
|
||||
highlightingRules.append(rule);
|
||||
rule.pattern = QRegExp("\\$\\{[^\\{]*\\}+");
|
||||
rule.pattern = QRegularExpression("\\$\\{[^\\{]*\\}+");
|
||||
highlightingRules.append(rule);
|
||||
|
||||
singleLineCommentFormat.setFontItalic(true);
|
||||
singleLineCommentFormat.setForeground(QColor(128, 128, 128));
|
||||
rule.pattern = QRegExp("#[^\n]*");
|
||||
rule.pattern = QRegularExpression("#[^\n]*");
|
||||
rule.format = singleLineCommentFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
@@ -50,21 +49,37 @@ ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter
|
||||
|
||||
void ConfigHighlighter::highlightBlock(const QString & text) {
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
QRegExp expression(rule.pattern);
|
||||
QRegularExpression expression(rule.pattern);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
QRegularExpressionMatchIterator i = expression.globalMatch(text);
|
||||
while (i.hasNext()) {
|
||||
QRegularExpressionMatch match = i.next();
|
||||
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
|
||||
}
|
||||
#else
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
setCurrentBlockState(0);
|
||||
|
||||
QRegExp expression = QRegExp("[ |\t]");
|
||||
QRegularExpression expression("[ |\t]");
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
QRegularExpressionMatchIterator i = expression.globalMatch(text);
|
||||
while (i.hasNext()) {
|
||||
QRegularExpressionMatch match = i.next();
|
||||
setFormat(match.capturedStart(), match.capturedLength(), spaceFormat);
|
||||
}
|
||||
#else
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, spaceFormat);
|
||||
index = expression.indexIn(text, index + length);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QTextCursor>
|
||||
#include <QTextCharFormat>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
# include <QRegularExpression>
|
||||
#else
|
||||
# include <QRegExp>
|
||||
typedef QRegExp QRegularExpression;
|
||||
#endif
|
||||
#include "qad_piqt_utils_export.h"
|
||||
|
||||
class QTextDocument;
|
||||
@@ -39,12 +45,12 @@ private:
|
||||
void highlightBlock(const QString &text);
|
||||
|
||||
struct QAD_PIQT_UTILS_EXPORT HighlightingRule {
|
||||
QRegExp pattern;
|
||||
QRegularExpression pattern;
|
||||
QTextCharFormat format;
|
||||
};
|
||||
|
||||
QVector<HighlightingRule> highlightingRules;
|
||||
QRegExp commentStartExpression, commentEndExpression;
|
||||
QRegularExpression commentStartExpression, commentEndExpression;
|
||||
QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat, substFormat;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
if (((DEFINED QGLVIEW) AND QGLVIEW) OR (NOT DEFINED QGLVIEW))
|
||||
find_package(OpenGL REQUIRED)
|
||||
shstk_qt_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
|
||||
shstk_qt_install("qad" FALSE qglview "${out_HDR}" "${out_QM}")
|
||||
shstk_qad_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
|
||||
shstk_qad_install("qad" FALSE qglview "${out_HDR}" "${out_QM}")
|
||||
|
||||
qt_sources(test_SRC DIR "qglview_test")
|
||||
qt_wrap(${test_SRC} CPPS test_CPP)
|
||||
qt_add_executable(qglview_test test_CPP)
|
||||
qt_target_link_libraries(qglview_test qglview)
|
||||
qad_sources(test_SRC DIR "qglview_test")
|
||||
qad_wrap(${test_SRC} CPPS test_CPP)
|
||||
qad_add_executable(qglview_test test_CPP)
|
||||
qad_target_link_libraries(qglview_test qglview)
|
||||
endif()
|
||||
|
||||
@@ -1 +1 @@
|
||||
shstk_qt_plugin(qglview "Gui;Widgets;OpenGL" "qglview")
|
||||
shstk_qad_plugin(qglview "Gui;Widgets;OpenGL" "qglview")
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
#include <QElapsedTimer>
|
||||
#include <QActionGroup>
|
||||
#include "qpiconfig.h"
|
||||
#include "qad_sql_table_export.h"
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ PropertyStorage::Property PropertyStorage::parsePropertyLine(QString l) {
|
||||
ret.value = QVariant(typeFromLetter(pt));
|
||||
if (!pv.isEmpty()) {
|
||||
//qDebug() << "set value !" << pv;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
switch (ret.value.type()) {
|
||||
case QVariant::Bool: pv = pv.toLower(); ret.value = (pv == "on" || pv == "true" || pv == "enable" || pv == "enabled" || pv.toInt() > 0 ? true : false); break;
|
||||
case QVariant::Int: ret.value = pv.toInt(); break;
|
||||
@@ -160,6 +161,18 @@ PropertyStorage::Property PropertyStorage::parsePropertyLine(QString l) {
|
||||
case QVariant::Color: ret.value = QColor(pv); break;
|
||||
default: ret.value = pv; break;
|
||||
};
|
||||
#else
|
||||
switch (ret.value.metaType().id()) {
|
||||
case QMetaType::Bool: pv = pv.toLower(); ret.value = (pv == "on" || pv == "true" || pv == "enable" || pv == "enabled" || pv.toInt() > 0 ? true : false); break;
|
||||
case QMetaType::Int: ret.value = pv.toInt(); break;
|
||||
case QMetaType::UInt: ret.value = pv.toUInt(); break;
|
||||
case QMetaType::LongLong: ret.value = pv.toLongLong(); break;
|
||||
case QMetaType::ULongLong: ret.value = pv.toULongLong(); break;
|
||||
case QMetaType::Double: ret.value = pv.toDouble(); break;
|
||||
case QMetaType::QColor: ret.value = QColor(pv); break;
|
||||
default: ret.value = pv; break;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -115,9 +115,6 @@ protected:
|
||||
|
||||
inline QDebug operator <<(QDebug s, const PropertyStorage::Property & p) {s.nospace() << p.name << " (0x" << QString::number(p.flags, 16) << ") = " << p.value; return s.space();}
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const PropertyStorage & p) {s << p.properties(); return s;}
|
||||
inline QDataStream & operator >>(QDataStream & s, PropertyStorage & p) {s >> p.properties(); return s;}
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const PropertyStorage::Property & p) {
|
||||
ChunkStream cs;
|
||||
cs << cs.chunk(1, p.name) << cs.chunk(2, p.comment) << cs.chunk(3, p.value) << cs.chunk(4, p.flags);
|
||||
@@ -137,5 +134,8 @@ inline QDataStream & operator >>(QDataStream & s, PropertyStorage::Property & p)
|
||||
return s;
|
||||
}
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const PropertyStorage & p) {s << p.properties(); return s;}
|
||||
inline QDataStream & operator >>(QDataStream & s, PropertyStorage & p) {s >> p.properties(); return s;}
|
||||
|
||||
|
||||
#endif // PROPERTYSTORAGE_H
|
||||
|
||||
@@ -26,25 +26,22 @@ __QADTypesRegistrator__::__QADTypesRegistrator__() {
|
||||
_inited = true;
|
||||
|
||||
qRegisterMetaType<QAD::Enumerator>("QAD::Enumerator");
|
||||
qRegisterMetaTypeStreamOperators<QAD::Enumerator>("QAD::Enumerator");
|
||||
|
||||
qRegisterMetaType<QAD::Enum>("QAD::Enum");
|
||||
qRegisterMetaTypeStreamOperators<QAD::Enum>("QAD::Enum");
|
||||
|
||||
qRegisterMetaType<QAD::File>("QAD::File");
|
||||
qRegisterMetaTypeStreamOperators<QAD::File>("QAD::File");
|
||||
|
||||
qRegisterMetaType<QAD::Dir>("QAD::Dir");
|
||||
qRegisterMetaTypeStreamOperators<QAD::Dir>("QAD::Dir");
|
||||
|
||||
qRegisterMetaType<QAD::IODevice>("QAD::IODevice");
|
||||
qRegisterMetaTypeStreamOperators<QAD::IODevice>("QAD::IODevice");
|
||||
|
||||
qRegisterMetaType<QAD::MathVector>("QAD::MathVector");
|
||||
qRegisterMetaTypeStreamOperators<QAD::MathVector>("QAD::MathVector");
|
||||
|
||||
qRegisterMetaType<QAD::MathMatrix>("QAD::MathMatrix");
|
||||
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
qRegisterMetaTypeStreamOperators<QAD::Enumerator>("QAD::Enumerator");
|
||||
qRegisterMetaTypeStreamOperators<QAD::Enum>("QAD::Enum");
|
||||
qRegisterMetaTypeStreamOperators<QAD::File>("QAD::File");
|
||||
qRegisterMetaTypeStreamOperators<QAD::Dir>("QAD::Dir");
|
||||
qRegisterMetaTypeStreamOperators<QAD::IODevice>("QAD::IODevice");
|
||||
qRegisterMetaTypeStreamOperators<QAD::MathVector>("QAD::MathVector");
|
||||
qRegisterMetaTypeStreamOperators<QAD::MathMatrix>("QAD::MathMatrix");
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x050200
|
||||
QMetaType::registerConverter<QAD::Enum, int>(&QAD::Enum::selectedValue);
|
||||
@@ -185,7 +182,13 @@ QString QAD::IODevice::toString() const {
|
||||
|
||||
|
||||
|
||||
QVariant::Type typeFromLetter(const QString & l) {
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
QVariant::Type
|
||||
#else
|
||||
QMetaType
|
||||
#endif
|
||||
typeFromLetter(const QString & l) {
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
if (l.isEmpty()) return QVariant::String;
|
||||
QString ft = l.left(1);
|
||||
if (ft == "l") return QVariant::StringList;
|
||||
@@ -204,6 +207,26 @@ QVariant::Type typeFromLetter(const QString & l) {
|
||||
if (ft == "V") return (QVariant::Type)qMetaTypeId<QAD::MathVector>();
|
||||
if (ft == "M") return (QVariant::Type)qMetaTypeId<QAD::MathMatrix>();
|
||||
return QVariant::String;
|
||||
#else
|
||||
if (l.isEmpty()) return QMetaType::fromType<QString>();
|
||||
QString ft = l.left(1);
|
||||
if (ft == "l") return QMetaType::fromType<QStringList >();
|
||||
if (ft == "b") return QMetaType::fromType<bool >();
|
||||
if (ft == "n") return QMetaType::fromType<int >();
|
||||
if (ft == "f") return QMetaType::fromType<double >();
|
||||
if (ft == "c") return QMetaType::fromType<QColor >();
|
||||
if (ft == "r") return QMetaType::fromType<QRect >();
|
||||
if (ft == "a") return QMetaType::fromType<QRectF >();
|
||||
if (ft == "p") return QMetaType::fromType<QPoint >();
|
||||
if (ft == "v") return QMetaType::fromType<QPointF >();
|
||||
if (ft == "e") return QMetaType::fromType<QAD::Enum >();
|
||||
if (ft == "F") return QMetaType::fromType<QAD::File >();
|
||||
if (ft == "D") return QMetaType::fromType<QAD::Dir >();
|
||||
if (ft == "d") return QMetaType::fromType<QAD::IODevice >();
|
||||
if (ft == "V") return QMetaType::fromType<QAD::MathVector>();
|
||||
if (ft == "M") return QMetaType::fromType<QAD::MathMatrix>();
|
||||
return QMetaType::fromType<QString>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +275,11 @@ int fontHeight(const QWidget * w) {
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
return QApplication::fontMetrics().size(0, "0").height();
|
||||
#else
|
||||
return QFontMetricsF(QApplication::font()).size(0, "0").height();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -276,3 +303,10 @@ QSize preferredIconSize(float x, const QWidget * w) {
|
||||
double appScale(const QWidget * w) {
|
||||
return qMax<double>(fontHeight(w) / 15., 1.);
|
||||
}
|
||||
|
||||
|
||||
void enableHighDPI() {
|
||||
#if QT_VERSION_MAJOR == 5
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef QAD_TYPES_H
|
||||
#define QAD_TYPES_H
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
#include "propertystorage.h"
|
||||
#include "qad_utils_export.h"
|
||||
|
||||
@@ -31,6 +31,16 @@
|
||||
QCoreApplication::setOrganizationName(__TARGET_COMPANY__); \
|
||||
QCoreApplication::setApplicationVersion(__TARGET_VERSION__);
|
||||
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
# define QT_MID_BUTTON Qt::MidButton
|
||||
# include <QMapIterator>
|
||||
template<typename K, typename T>
|
||||
using QMultiMapIterator = QMapIterator<K,T>;
|
||||
#else
|
||||
# define QT_MID_BUTTON Qt::MiddleButton
|
||||
#endif
|
||||
|
||||
|
||||
class QMetaEnum;
|
||||
|
||||
|
||||
@@ -167,13 +177,47 @@ inline QRectF enlargedRect(const QRectF & r, qreal dx, qreal dy, qreal v) {
|
||||
return QRectF(r.left() - v + dx, r.top() - v + dy, r.width() + v+v, r.height() + v+v);
|
||||
}
|
||||
|
||||
QAD_UTILS_EXPORT QVariant::Type typeFromLetter(const QString & l);
|
||||
template <typename T> QSet<T> QList2QSet(const QList<T> & l) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
return QSet<T>(l.begin(), l.end());
|
||||
#else
|
||||
return QSet<T>::fromList(l);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename K, typename T>
|
||||
void addToMap(QMap<K, T> & into, const QMap<K, T> & what) {
|
||||
QMapIterator<K, T> it(what);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (!into.contains(it.key()))
|
||||
into[it.key()] = it.value();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename K, typename T>
|
||||
void addToMapOverwrite(QMap<K, T> & into, const QMap<K, T> & what) {
|
||||
QMapIterator<K, T> it(what);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
into[it.key()] = it.value();
|
||||
}
|
||||
}
|
||||
|
||||
QAD_UTILS_EXPORT
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
QVariant::Type
|
||||
#else
|
||||
QMetaType
|
||||
#endif
|
||||
typeFromLetter(const QString & l);
|
||||
QAD_UTILS_EXPORT QString uniqueName(QString n, const QStringList & names);
|
||||
|
||||
QAD_UTILS_EXPORT int fontHeight(const QWidget * w = 0);
|
||||
QAD_UTILS_EXPORT int lineThickness(const QWidget * w = 0);
|
||||
QAD_UTILS_EXPORT QSize preferredIconSize(float x = 1.f, const QWidget * w = 0);
|
||||
QAD_UTILS_EXPORT double appScale(const QWidget * w = 0);
|
||||
QAD_UTILS_EXPORT void enableHighDPI();
|
||||
|
||||
|
||||
#endif // QAD_TYPES_H
|
||||
|
||||
@@ -303,6 +303,9 @@ QPIConfig::QPIConfig(const QString & path, QStringList dirs) {
|
||||
return;
|
||||
}
|
||||
dev->close();
|
||||
#if QT_VERSION_MAJOR > 5
|
||||
stream.setEncoding(QStringConverter::Utf8);
|
||||
#endif
|
||||
setFileName(cp);
|
||||
open(QIODevice::ReadOnly);
|
||||
parse();
|
||||
@@ -347,7 +350,15 @@ void QPIConfig::setString(QString * str) {
|
||||
|
||||
void QPIConfig::setCodec(const char * codecName) {
|
||||
codec = codecName;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
stream.setCodec(codecName);
|
||||
#else
|
||||
QString cn = QString(codecName).toLower().remove(' ').remove('-').trimmed();
|
||||
QStringConverter::Encoding sc = QStringConverter::System;
|
||||
if (cn == "utf8" ) sc = QStringConverter::Utf8 ;
|
||||
else if (cn == "utf16") sc = QStringConverter::Utf16;
|
||||
stream.setEncoding(sc);
|
||||
#endif
|
||||
parse();
|
||||
}
|
||||
|
||||
@@ -770,8 +781,10 @@ void QPIConfig::parse(QString content) {
|
||||
stream.seek(0);
|
||||
other.clear();
|
||||
lines = centry = 0;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
if (!codec.isEmpty())
|
||||
stream.setCodec(codec.toLatin1().data());
|
||||
#endif
|
||||
while (!stream.atEnd()) {
|
||||
other.push_back(QString());
|
||||
src = str = parseLine(stream.readLine());
|
||||
|
||||
@@ -106,7 +106,13 @@ void EComboBox::filterChanged(const QString & text, bool first) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < iv.model()->rowCount(); ++i) {
|
||||
iv.setRowHidden(i, pi, !iv.model()->index(i, 0, pi).data().toString().contains(QRegExp(text, Qt::CaseInsensitive)));
|
||||
iv.setRowHidden(i, pi, !iv.model()->index(i, 0, pi).data().toString().contains(
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
QRegExp(text, Qt::CaseInsensitive)
|
||||
#else
|
||||
QRegularExpression(text, QRegularExpression::CaseInsensitiveOption)
|
||||
#endif
|
||||
));
|
||||
iv.model()->setData(iv.model()->index(i, 0), iv.model()->index(i, 0, pi).data().toString(), Qt::ToolTipRole);
|
||||
}
|
||||
iv.show();
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
#include <QRegExp>
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
# include <QRegExp>
|
||||
#else
|
||||
# include <QRegularExpression>
|
||||
#endif
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
#include <QStyle>
|
||||
@@ -292,7 +296,13 @@ void EvalSpinBox::focusOutEvent(QFocusEvent * event) {
|
||||
|
||||
void EvalSpinBox::wheelEvent(QWheelEvent * event) {
|
||||
if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
stepByDouble(event->delta() > 0 ? 0.1 : -0.1);
|
||||
stepByDouble(
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
event->delta()
|
||||
#else
|
||||
event->angleDelta().y()
|
||||
#endif
|
||||
> 0 ? 0.1 : -0.1);
|
||||
else
|
||||
QAbstractSpinBox::wheelEvent(event);
|
||||
}
|
||||
@@ -304,8 +314,8 @@ void EvalSpinBox::stepByDouble(double steps) {
|
||||
QString t = text();
|
||||
if (eval->check(t)) {
|
||||
t = eval->expression();
|
||||
//QRegExp re("(\\-?\\d+)");
|
||||
QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
/* QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
|
||||
int pos = 0;
|
||||
if ((pos = re.indexIn(t)) != -1) {
|
||||
double v = t.mid(pos, re.matchedLength()).toDouble();
|
||||
@@ -316,6 +326,10 @@ void EvalSpinBox::stepByDouble(double steps) {
|
||||
double v = steps;
|
||||
t = QString::number(v) + t;
|
||||
}
|
||||
#else*/
|
||||
QRegularExpression re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
|
||||
/// TODO andrey
|
||||
#endif
|
||||
eval->check(t);
|
||||
lineEdit()->setText(eval->expression());
|
||||
}
|
||||
|
||||
@@ -482,7 +482,13 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
break;
|
||||
case QEvent::DragMove:
|
||||
if (!isEnabled()) break;
|
||||
drag_cursor = ui->textCode->cursorForPosition(((QDragMoveEvent*)e)->pos());
|
||||
drag_cursor = ui->textCode->cursorForPosition(
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
((QDragMoveEvent*)e)->pos()
|
||||
#else
|
||||
((QDragMoveEvent*)e)->position().toPoint()
|
||||
#endif
|
||||
);
|
||||
repaintCursor();
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
|
||||
@@ -226,7 +226,8 @@ public slots:
|
||||
void setShowSpaces(bool yes);
|
||||
void setShowLineNumbers(bool yes);
|
||||
void search(const QString & t);
|
||||
void searchNext(bool next = true);
|
||||
void searchNext(bool next);
|
||||
void searchNext() {searchNext(true);}
|
||||
void searchPrevious();
|
||||
void hideSearch();
|
||||
void setWordCompletitionEnabled(bool on) {word_complete = on;}
|
||||
|
||||
@@ -61,7 +61,13 @@ bool QPIConfigWidget::eventFilter(QObject * o, QEvent * e) {
|
||||
if (((QMouseEvent * )e)->buttons() == Qt::RightButton) {
|
||||
qApp->processEvents();
|
||||
itemClicked(pi, 1);
|
||||
popupMenu.popup(((QMouseEvent * )e)->globalPos());
|
||||
popupMenu.popup(
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
((QMouseEvent * )e)->globalPos()
|
||||
#else
|
||||
((QMouseEvent * )e)->globalPosition().toPoint()
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,99 +210,167 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
|
||||
return;
|
||||
}
|
||||
_delete();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
switch (new_value.type()) {
|
||||
#else
|
||||
switch (new_value.metaType().id()) {
|
||||
#endif
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Bool:
|
||||
#else
|
||||
case QMetaType::Bool:
|
||||
#endif
|
||||
_check = new QCheckBox(this);
|
||||
_check->setAutoFillBackground(true);
|
||||
_cur_edit = _check;
|
||||
connect(_check, SIGNAL(toggled(bool)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Int:
|
||||
#else
|
||||
case QMetaType::Int:
|
||||
#endif
|
||||
_spin = new QDoubleSpinBox(this);
|
||||
_spin->setDecimals(0);
|
||||
_spin->setRange(-0x7FFFFFFF, 0x7FFFFFFF);
|
||||
_cur_edit = _spin;
|
||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::UInt:
|
||||
#else
|
||||
case QMetaType::UInt:
|
||||
#endif
|
||||
_spin = new QDoubleSpinBox(this);
|
||||
_spin->setDecimals(0);
|
||||
_spin->setRange(0, 0xFFFFFFFF);
|
||||
_cur_edit = _spin;
|
||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::LongLong:
|
||||
#else
|
||||
case QMetaType::LongLong:
|
||||
#endif
|
||||
_spin = new QDoubleSpinBox(this);
|
||||
_spin->setDecimals(0);
|
||||
_spin->setRange(-0x7FFFFFFFFFFFFFFFL, 0x7FFFFFFFFFFFFFFFL);
|
||||
_cur_edit = _spin;
|
||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::ULongLong:
|
||||
#else
|
||||
case QMetaType::ULongLong:
|
||||
#endif
|
||||
_spin = new QDoubleSpinBox(this);
|
||||
_spin->setDecimals(0);
|
||||
_spin->setRange(0L, 0x7FFFFFFFFFFFFFFFL);
|
||||
_cur_edit = _spin;
|
||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Double:
|
||||
#else
|
||||
case QMetaType::Double:
|
||||
#endif
|
||||
_espin = new EvalSpinBox(this);
|
||||
//_spin->setDecimals(5);
|
||||
//_spin->setRange(-1E+199, 1E+199);
|
||||
_cur_edit = _espin;
|
||||
connect(_espin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Color:
|
||||
#else
|
||||
case QMetaType::QColor:
|
||||
#endif
|
||||
_color = new ColorButton(this);
|
||||
_color->setUseAlphaChannel(true);
|
||||
_cur_edit = _color;
|
||||
connect(_color, SIGNAL(colorChanged(QColor)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::String:
|
||||
#else
|
||||
case QMetaType::QString:
|
||||
#endif
|
||||
_line = new CLineEdit(this);
|
||||
_cur_edit = _line;
|
||||
connect(_line, SIGNAL(textChanged(QString)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::StringList:
|
||||
#else
|
||||
case QMetaType::QStringList:
|
||||
#endif
|
||||
_list = new StringListEdit(this);
|
||||
_cur_edit = _list;
|
||||
connect(_list, SIGNAL(valueChanged()), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Rect:
|
||||
#else
|
||||
case QMetaType::QRect:
|
||||
#endif
|
||||
_rect = new QRectEdit(this);
|
||||
_rect->setDecimals(0);
|
||||
_cur_edit = _rect;
|
||||
connect(_rect, SIGNAL(valueChanged(QRectF)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::RectF:
|
||||
#else
|
||||
case QMetaType::QRectF:
|
||||
#endif
|
||||
_rect = new QRectEdit(this);
|
||||
_rect->setDecimals(3);
|
||||
_cur_edit = _rect;
|
||||
connect(_rect, SIGNAL(valueChanged(QRectF)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Point:
|
||||
#else
|
||||
case QMetaType::QPoint:
|
||||
#endif
|
||||
_point = new QPointEdit(this);
|
||||
_point->setDecimals(0);
|
||||
_cur_edit = _point;
|
||||
connect(_point, SIGNAL(valueChanged(QPointF)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::PointF:
|
||||
#else
|
||||
case QMetaType::QPointF:
|
||||
#endif
|
||||
_point = new QPointEdit(this);
|
||||
_point->setDecimals(3);
|
||||
_cur_edit = _point;
|
||||
connect(_point, SIGNAL(valueChanged(QPointF)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Date:
|
||||
#else
|
||||
case QMetaType::QDate:
|
||||
#endif
|
||||
_date = new QDateEdit(this);
|
||||
_cur_edit = _date;
|
||||
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Time:
|
||||
#else
|
||||
case QMetaType::QTime:
|
||||
#endif
|
||||
_date = new QTimeEdit(this);
|
||||
_cur_edit = _date;
|
||||
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
||||
break;
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::DateTime:
|
||||
#else
|
||||
case QMetaType::QDateTime:
|
||||
#endif
|
||||
_date = new QDateTimeEdit(this);
|
||||
_cur_edit = _date;
|
||||
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
||||
@@ -351,23 +419,107 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
|
||||
|
||||
|
||||
QVariant QVariantEdit::value() const {
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
switch (_value.type()) {
|
||||
case QVariant::Bool: return _check->isChecked();
|
||||
case QVariant::Int: return int(_spin->value());
|
||||
case QVariant::UInt: return (unsigned int)(_spin->value());
|
||||
case QVariant::LongLong: return qlonglong(_spin->value());
|
||||
case QVariant::ULongLong: return qulonglong(_spin->value());
|
||||
case QVariant::Double: return _espin->value();
|
||||
case QVariant::Color: return _color->color();
|
||||
case QVariant::String: return _line->text();
|
||||
case QVariant::StringList: return _list->value();
|
||||
case QVariant::Rect: return _rect->value().toRect();
|
||||
case QVariant::RectF: return _rect->value();
|
||||
case QVariant::Point: return _point->value().toPoint();
|
||||
case QVariant::PointF: return _point->value();
|
||||
case QVariant::Date: return _date->date();
|
||||
case QVariant::Time: return _date->time();
|
||||
case QVariant::DateTime: return _date->dateTime();
|
||||
#else
|
||||
switch (_value.metaType().id()) {
|
||||
#endif
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Bool:
|
||||
#else
|
||||
case QMetaType::Bool:
|
||||
#endif
|
||||
return _check->isChecked();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Int:
|
||||
#else
|
||||
case QMetaType::Int:
|
||||
#endif
|
||||
return int(_spin->value());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::UInt:
|
||||
#else
|
||||
case QMetaType::UInt:
|
||||
#endif
|
||||
return (unsigned int)(_spin->value());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::LongLong:
|
||||
#else
|
||||
case QMetaType::LongLong:
|
||||
#endif
|
||||
return qlonglong(_spin->value());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::ULongLong:
|
||||
#else
|
||||
case QMetaType::ULongLong:
|
||||
#endif
|
||||
return qulonglong(_spin->value());
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Double:
|
||||
#else
|
||||
case QMetaType::Double:
|
||||
#endif
|
||||
return _espin->value();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Color:
|
||||
#else
|
||||
case QMetaType::QColor:
|
||||
#endif
|
||||
return _color->color();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::String:
|
||||
#else
|
||||
case QMetaType::QString:
|
||||
#endif
|
||||
return _line->text();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::StringList:
|
||||
#else
|
||||
case QMetaType::QStringList:
|
||||
#endif
|
||||
return _list->value();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Rect:
|
||||
#else
|
||||
case QMetaType::QRect:
|
||||
#endif
|
||||
return _rect->value().toRect();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::RectF:
|
||||
#else
|
||||
case QMetaType::QRectF:
|
||||
#endif
|
||||
return _rect->value();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Point:
|
||||
#else
|
||||
case QMetaType::QPoint:
|
||||
#endif
|
||||
return _point->value().toPoint();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::PointF:
|
||||
#else
|
||||
case QMetaType::QPointF:
|
||||
#endif
|
||||
return _point->value();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Date:
|
||||
#else
|
||||
case QMetaType::QDate:
|
||||
#endif
|
||||
return _date->date();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::Time:
|
||||
#else
|
||||
case QMetaType::QTime:
|
||||
#endif
|
||||
return _date->time();
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
case QVariant::DateTime:
|
||||
#else
|
||||
case QMetaType::QDateTime:
|
||||
#endif
|
||||
return _date->dateTime();
|
||||
default:
|
||||
if (_value.canConvert<QAD::Enum>() && _enum) {
|
||||
QAD::Enum ret;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#endif
|
||||
#include "session_manager.h"
|
||||
#include "qad_locations.h"
|
||||
#include "qad_types.h"
|
||||
|
||||
|
||||
SessionManager::SessionManager(QString file) {
|
||||
@@ -107,7 +108,7 @@ void SessionManager::save() {
|
||||
sr.setValue(floats[i].first, *floats[i].second, false);
|
||||
QSet<QObject*> all_list;
|
||||
foreach (QObject * c, tsc) {
|
||||
all_list |= QSet<QObject*>::fromList(c->findChildren<QObject*>());
|
||||
all_list |= QList2QSet(c->findChildren<QObject*>());
|
||||
}
|
||||
QMap<const QMetaObject*, QByteArray> funcs = metaFunctions(all_list, "sessionSave");
|
||||
//qDebug() << "check for save" << all_list.size();
|
||||
@@ -231,7 +232,7 @@ void SessionManager::load(bool onlyMainwindow) {
|
||||
*floats[i].second = sr.getValue(floats[i].first, *floats[i].second).toFloat();
|
||||
QSet<QObject*> all_list;
|
||||
foreach (QObject * c, tsc) {
|
||||
all_list |= QSet<QObject*>::fromList(c->findChildren<QObject*>());
|
||||
all_list |= QList2QSet(c->findChildren<QObject*>());
|
||||
}
|
||||
QMap<const QMetaObject*, QByteArray> funcs = metaFunctions(all_list, "sessionLoad");
|
||||
//qDebug() << "check for load" << all_list.size();
|
||||
|
||||
@@ -117,8 +117,10 @@ private:
|
||||
|
||||
public slots:
|
||||
void save();
|
||||
void load(bool onlyMainwindow = false);
|
||||
void clear(bool with_filename = true);
|
||||
void load(bool onlyMainwindow);
|
||||
void load() {load(false);}
|
||||
void clear(bool with_filename);
|
||||
void clear() {clear(true);}
|
||||
|
||||
signals:
|
||||
void loading(QPIConfig & );
|
||||
|
||||
Reference in New Issue
Block a user