summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfiledialog_p.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-11-10 13:07:01 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-11 10:58:10 +0100
commitaf914694d81317b4a7bf0804d9d34a1f3bf2cf48 (patch)
tree039dc97541bc51cdeddf21b5f8949d5e998b18de /src/widgets/dialogs/qfiledialog_p.h
parent9a8a70d8e42f7e8fee8398affa5680adb2ba24d6 (diff)
QPlatformDialogHelper: Split class hierarchy, decouple from Dialog
- Introduce hierarchy of QPlatformDialogHelper-derived classes for font, color and file dialogs. - Start reducing dependencies on QDialog: * Remove QDialog-specifics from interface, introduce enumeration for DialogCode * Make the helpers Q_OBJECTS to be able to add the signals passed on to the QDialogs * Remove QDialogPrivate pointer - Split setVisible_sys() in show_sys() (factory method for native dialogs) and hide_sys(). Pass parent window to show_sys(), removing the necessity to query the QDialog for it - Introduce a styleHint() similar to QGuiApplication's for platform-specific - Fix compile in cocoa/windows, reduce depency on QDialog (-private) classes. Change-Id: Ic1cb715e1edf767f2cb18b9780341d189339ef1d Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/widgets/dialogs/qfiledialog_p.h')
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 6d4a00e681..383734950c 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -114,6 +114,9 @@ class Q_WIDGETS_EXPORT QFileDialogPrivate : public QDialogPrivate
public:
QFileDialogPrivate();
+ QPlatformFileDialogHelper *platformFileDialogHelper() const
+ { return static_cast<QPlatformFileDialogHelper *>(platformHelper()); }
+
void createToolButtons();
void createMenuActions();
void createWidgets();
@@ -262,7 +265,6 @@ public:
// dialog. Returning false means that a non-native dialog must be
// used instead.
bool canBeNativeDialog();
- bool setVisible_sys(bool visible);
void deleteNativeDialog_sys();
QDialog::DialogCode dialogResultCode_sys();
@@ -289,6 +291,8 @@ public:
~QFileDialogPrivate();
private:
+ virtual void initHelper(QPlatformDialogHelper *);
+
Q_DISABLE_COPY(QFileDialogPrivate)
};
@@ -344,6 +348,16 @@ private:
QFileDialogPrivate *d_ptr;
};
+void QFileDialogPrivate::initHelper(QPlatformDialogHelper *h)
+{
+ QFileDialog *d = q_func();
+ QObject::connect(h, SIGNAL(fileSelected(QString)), d, SIGNAL(fileSelected(QString)));
+ QObject::connect(h, SIGNAL(filesSelected(QStringList)), d, SIGNAL(filesSelected(QStringList)));
+ QObject::connect(h, SIGNAL(currentChanged(QString)), d, SIGNAL(currentChanged(QString)));
+ QObject::connect(h, SIGNAL(directoryEntered(QString)), d, SIGNAL(directoryEntered(QString)));
+ QObject::connect(h, SIGNAL(filterSelected(QString)), d, SIGNAL(filterSelected(QString)));
+}
+
inline QModelIndex QFileDialogPrivate::mapToSource(const QModelIndex &index) const {
#ifdef QT_NO_PROXYMODEL
return index;
@@ -366,71 +380,68 @@ inline QString QFileDialogPrivate::rootPath() const {
// Dummies for platforms that don't use native dialogs:
inline void QFileDialogPrivate::deleteNativeDialog_sys()
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) {
helper->deleteNativeDialog_sys();
-}
-
-inline bool QFileDialogPrivate::setVisible_sys(bool visible)
-{
- if (QPlatformDialogHelper *helper = platformHelper())
- return helper->setVisible_sys(visible);
- return false;
+ nativeDialogInUse = false;
+ }
}
inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys()
{
+ QDialog::DialogCode result = QDialog::Rejected;
if (QPlatformDialogHelper *helper = platformHelper())
- return helper->dialogResultCode_sys();
- return QDialog::Rejected;
+ if (helper->dialogResultCode_sys() == QPlatformDialogHelper::Accepted)
+ result = QDialog::Accepted;
+ return result;
}
inline void QFileDialogPrivate::setDirectory_sys(const QString &directory)
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->setDirectory_sys(directory);
}
inline QString QFileDialogPrivate::directory_sys() const
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
return helper->directory_sys();
return QString();
}
inline void QFileDialogPrivate::selectFile_sys(const QString &filename)
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->selectFile_sys(filename);
}
inline QStringList QFileDialogPrivate::selectedFiles_sys() const
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
return helper->selectedFiles_sys();
return QStringList();
}
inline void QFileDialogPrivate::setFilter_sys()
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->setFilter_sys();
}
inline void QFileDialogPrivate::setNameFilters_sys(const QStringList &filters)
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->setNameFilters_sys(filters);
}
inline void QFileDialogPrivate::selectNameFilter_sys(const QString &filter)
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->selectNameFilter_sys(filter);
}
inline QString QFileDialogPrivate::selectedNameFilter_sys() const
{
- if (QPlatformDialogHelper *helper = platformHelper())
+ if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
return helper->selectedNameFilter_sys();
return QString();
}