Question #252130 on qpdfview changed: https://answers.launchpad.net/qpdfview/+question/252130
Adam Reichold proposed the following answer: Damn, Launchpad questions do not seem to support file attachments. I'll inline the patch but I am sure Thunderbird will mess up the formatting... Am 30.08.2014 um 21:46 schrieb S. Razi Alavizadeh: > Question #252130 on qpdfview changed: > https://answers.launchpad.net/qpdfview/+question/252130 > > S. Razi Alavizadeh posted a new comment: Hi >> attached is a diff of mapping spin box that compiles cleanly and > *should* work as intended. (I changed the order of constructor > parameters so that Qt Creators auto-completion for the "SLOT" > macro applies.) Thank you very much :-) But unfortunately I can't > see attached file neither here nor on my gmail. > > Best Regards, Razi. > === modified file 'sources/miscellaneous.cpp' --- sources/miscellaneous.cpp 2014-08-30 14:13:42 +0000 +++ sources/miscellaneous.cpp 2014-08-30 17:57:45 +0000 @@ -297,6 +297,42 @@ } } +MappingSpinBox::MappingSpinBox(QWidget* parent, const char* textFromValue, const char* valueFromText) : SpinBox(parent) +{ + const QMetaObject* metaObject = parent->metaObject(); + + m_textFromValue = metaObject->method(metaObject->indexOfMethod(textFromValue)); + m_valueFromText = metaObject->method(metaObject->indexOfMethod(valueFromText)); +} + +QString MappingSpinBox::textFromValue(int val) const +{ + QString text; + const bool ok = m_textFromValue.invoke(parent(), Qt::DirectConnection, + Q_RETURN_ARG(QString, text), Q_ARG(int, val)); + + if(!ok) + { + text = SpinBox::textFromValue(val); + } + + return text; +} + +int MappingSpinBox::valueFromText(const QString& text) const +{ + int val; + const bool ok = m_valueFromText.invoke(parent(), Qt::DirectConnection, + Q_RETURN_ARG(int, val), Q_ARG(QString, text)); + + if(!ok) + { + val = SpinBox::valueFromText(text); + } + + return val; +} + ProgressLineEdit::ProgressLineEdit(QWidget* parent) : QLineEdit(parent), m_progress(0) { @@ -337,8 +373,6 @@ } } -// search line edit - SearchLineEdit::SearchLineEdit(QWidget* parent) : ProgressLineEdit(parent) { m_timer = new QTimer(this); === modified file 'sources/miscellaneous.h' --- sources/miscellaneous.h 2014-03-29 10:20:32 +0000 +++ sources/miscellaneous.h 2014-08-30 17:57:35 +0000 @@ -26,6 +26,7 @@ #include <QComboBox> #include <QGraphicsEffect> #include <QLineEdit> +#include <QMetaMethod> #include <QPainter> #include <QSpinBox> #include <QTreeView> @@ -191,6 +192,25 @@ }; +// mapping spin box + +class MappingSpinBox : public SpinBox +{ + Q_OBJECT + +public: + MappingSpinBox(QObject* parent, const char* textFromValue, const char* valueFromText); + +protected: + QString textFromValue(int val) const; + int valueFromText(const QString& text) const; + +private: + QMetaMethod m_textFromValue; + QMetaMethod m_valueFromText; + +}; + // progress line edit class ProgressLineEdit : public QLineEdit -- You received this question notification because you are a member of qpdfview, which is an answer contact for qpdfview. -- Mailing list: https://launchpad.net/~qpdfview Post to : [email protected] Unsubscribe : https://launchpad.net/~qpdfview More help : https://help.launchpad.net/ListHelp

