126 lines
3.3 KiB
C++
126 lines
3.3 KiB
C++
/**
|
|
* @file QtOpenfileDialogfactory.h
|
|
* @brief 打开文件对话框属性项定制(弹打开文件对话框)
|
|
* @date 2015-08-18
|
|
* @author: hudfang
|
|
*/
|
|
#ifndef CQTOPENFILEDIALOGFACTORY_H
|
|
#define CQTOPENFILEDIALOGFACTORY_H
|
|
|
|
#include <QtGui/QLabel>
|
|
#include <QtGui/QToolButton>
|
|
#include <QMap>
|
|
#include "qteditorfactory.h"
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class CQtOpenfileDialogFactoryPrivate;
|
|
class CQtOpenfileDialogPropertyManagerPrivate;
|
|
class QTPROPERTYBROWSER_EXPORT CQtOpenfileDialogPropertyManager : public QtAbstractPropertyManager
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CQtOpenfileDialogPropertyManager(QObject *parent = 0);
|
|
~CQtOpenfileDialogPropertyManager();
|
|
|
|
QString value(const QtProperty *property) const;
|
|
QStringList enumNames(const QtProperty *property) const;
|
|
QMap<int, QString> enumIcons(const QtProperty *property) const;
|
|
QString defaultDir;
|
|
QString filter;
|
|
|
|
public Q_SLOTS:
|
|
void setValue(QtProperty *property, QString val);
|
|
Q_SIGNALS:
|
|
void valueChanged(QtProperty *property, const QVariant &);
|
|
protected:
|
|
QString valueText(const QtProperty *property) const;
|
|
virtual void initializeProperty(QtProperty *property);
|
|
virtual void uninitializeProperty(QtProperty *property);
|
|
private:
|
|
QScopedPointer<CQtOpenfileDialogPropertyManagerPrivate> d_ptr;
|
|
|
|
|
|
Q_DECLARE_PRIVATE(CQtOpenfileDialogPropertyManager)
|
|
Q_DISABLE_COPY(CQtOpenfileDialogPropertyManager)
|
|
};
|
|
|
|
|
|
|
|
class QTPROPERTYBROWSER_EXPORT CQtOpenfileDialogPropertyManagerPrivate
|
|
{
|
|
CQtOpenfileDialogPropertyManager *q_ptr;
|
|
Q_DECLARE_PUBLIC(CQtOpenfileDialogPropertyManager)
|
|
public:
|
|
|
|
typedef QMap<const QtProperty *, QString> PropertyValueMap;
|
|
PropertyValueMap m_values;
|
|
};
|
|
|
|
|
|
class CQtOpenfileDialogFactoryPrivate;
|
|
|
|
class QTPROPERTYBROWSER_EXPORT CQtOpenfileDialogFactory : public QtAbstractEditorFactory<CQtOpenfileDialogPropertyManager>
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CQtOpenfileDialogFactory(QObject *parent = 0);
|
|
~CQtOpenfileDialogFactory();
|
|
protected:
|
|
void connectPropertyManager(CQtOpenfileDialogPropertyManager *manager);
|
|
QWidget *createEditor(CQtOpenfileDialogPropertyManager *manager, QtProperty *property,
|
|
QWidget *parent);
|
|
void disconnectPropertyManager(CQtOpenfileDialogPropertyManager *manager);
|
|
private:
|
|
QScopedPointer<CQtOpenfileDialogFactoryPrivate> d_ptr;
|
|
Q_DECLARE_PRIVATE(CQtOpenfileDialogFactory)
|
|
Q_DISABLE_COPY(CQtOpenfileDialogFactory)
|
|
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, QString))
|
|
Q_PRIVATE_SLOT(d_func(), void slotSetValue(QString))
|
|
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
|
|
|
|
};
|
|
|
|
|
|
class CQtOpenfileDialogEditWidget;
|
|
class QTPROPERTYBROWSER_EXPORT CQtOpenfileDialogFactoryPrivate : public EditorFactoryPrivate<CQtOpenfileDialogEditWidget>
|
|
{
|
|
CQtOpenfileDialogFactory *q_ptr;
|
|
Q_DECLARE_PUBLIC(CQtOpenfileDialogFactory)
|
|
public:
|
|
|
|
void slotPropertyChanged(QtProperty *property, QString value);
|
|
void slotSetValue(QString value);
|
|
};
|
|
|
|
// CQtOpenfileDialogEditWidget
|
|
QString GetImagePath();
|
|
class CQtOpenfileDialogEditWidget : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CQtOpenfileDialogEditWidget(QWidget *parent);
|
|
|
|
bool eventFilter(QObject *obj, QEvent *ev);
|
|
QString defaultDir;
|
|
QString filter;
|
|
public Q_SLOTS:
|
|
void setValue(const QString &value);
|
|
|
|
private Q_SLOTS:
|
|
void buttonClicked();
|
|
|
|
Q_SIGNALS:
|
|
void valueChanged(const QString &value);
|
|
|
|
private:
|
|
QString m_fileName;
|
|
QLabel *m_label;
|
|
QToolButton *m_button;
|
|
|
|
};
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
#endif
|
|
|