{}
public:
- QPointer<QObject> dialogParent;
QString title;
QString label;
bool dialogAccepted;
};
DeclarativeInputDialogAttached::DeclarativeInputDialogAttached(QObject *parent)
- : QObject(parent), d(new Private)
+ : StaticDialogMethodAttached(parent), d(new Private)
{
}
delete d;
}
-void DeclarativeInputDialogAttached::setDialogParent(QObject *parent)
-{
- if (parent == d->dialogParent)
- return;
-
- d->dialogParent = parent;
- emit dialogParentChanged(parent);
-}
-
-QObject *DeclarativeInputDialogAttached::dialogParent() const
-{
- return d->dialogParent;
-}
-
void DeclarativeInputDialogAttached::setTitle(const QString &title)
{
if (title == d->title)
double DeclarativeInputDialogAttached::getDouble()
{
- QWidget *parent = bestParentWindow(d->dialogParent);
+ QWidget *parent = bestParentWindow();
bool ok = false;
const double value = d->value.canConvert<double>() ? d->value.value<double>() : 0.0;
const double min = d->min.canConvert<double>() ? d->min.value<double>() : -2147483647;
int DeclarativeInputDialogAttached::getInt()
{
- QWidget *parent = bestParentWindow(d->dialogParent);
+ QWidget *parent = bestParentWindow();
bool ok = false;
const int value = d->value.canConvert<int>() ? d->value.value<int>() : 0;
const int min = d->min.canConvert<int>() ? d->min.value<int>() : -2147483647;
QString DeclarativeInputDialogAttached::getItem(const QStringList &items)
{
- QWidget *parent = bestParentWindow(d->dialogParent);
+ QWidget *parent = bestParentWindow();
bool ok = false;
const QString retVal = QInputDialog::getItem(parent, d->title, d->label, items, d->currentItem, d->itemsEditable, &ok);
QString DeclarativeInputDialogAttached::getText()
{
- QWidget *parent = bestParentWindow(d->dialogParent);
+ QWidget *parent = bestParentWindow();
bool ok = false;
const QString retVal = QInputDialog::getText(parent, d->title, d->label, d->echoMode, d->text, &ok);
emit dialogAcceptedChanged(accepted);
}
-QWidget *DeclarativeInputDialogAttached::bestParentWindow(QObject *parent) const
-{
- if (!parent)
- parent = this->parent();
-
- // if parent is a Declarative Object, search the proxied hierarchy
- AbstractDeclarativeObject *declarativeObject = dynamic_cast<AbstractDeclarativeObject*>(parent);
- if (declarativeObject)
- parent = declarativeObject->object();
-
- while (parent) {
- QWidget *widget = qobject_cast<QWidget*>(parent);
- if (widget)
- return widget->topLevelWidget();
-
- parent = parent->parent();
- }
-
- return 0;
-}
-
DeclarativeInputDialog::DeclarativeInputDialog(QObject *parent) : DeclarativeWidgetProxy<InputDialog>(parent)
{
connectAllSignals(m_proxiedObject, this);
#include "declarativewidgetproxy_p.h"
#include "objectadaptors_p.h"
+#include "staticdialogmethodattached_p.h"
-class DeclarativeInputDialogAttached : public QObject
+class DeclarativeInputDialogAttached : public StaticDialogMethodAttached
{
Q_OBJECT
- Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged)
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
Q_PROPERTY(bool ok READ dialogAccepted NOTIFY dialogAcceptedChanged)
DeclarativeInputDialogAttached(QObject *parent = 0);
~DeclarativeInputDialogAttached();
- void setDialogParent(QObject *parent);
- QObject *dialogParent() const;
-
void setTitle(const QString &title);
QString title() const;
Q_INVOKABLE QString getText();
Q_SIGNALS:
- void dialogParentChanged(QObject *parent);
void titleChanged(const QString &title);
void labelChanged(const QString &label);
void dialogAcceptedChanged(bool accepted);
private:
void setDialogAccepted(bool accepted);
- QWidget *bestParentWindow(QObject *parent) const;
class Private;
Private *const d;