Commit c502ca9d authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.propertyEditor: FileWidget works without model

parent 7e0af03b
...@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE ...@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE
FileWidget::FileWidget(QWidget *parent) : QWidget(parent), m_filter("(*.*)"), m_showComboBox(false), m_lock(false) FileWidget::FileWidget(QWidget *parent) : QWidget(parent), m_filter("(*.*)"), m_showComboBox(false), m_lock(false)
{ {
m_pushButton = new QPushButton(this); m_pushButton = new QToolButton(this);
m_pushButton->setFixedWidth(32); m_pushButton->setFixedWidth(32);
m_lineEdit = new QLineEdit(this); m_lineEdit = new QLineEdit(this);
m_comboBox = new QComboBox(this); m_comboBox = new QComboBox(this);
...@@ -126,16 +126,20 @@ void FileWidget::setupComboBox() ...@@ -126,16 +126,20 @@ void FileWidget::setupComboBox()
m_lock = true; m_lock = true;
m_comboBox->clear(); m_comboBox->clear();
if (m_itemNode.isValid()) { QDir dir;
QDir dir = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).absoluteDir();
QStringList filterList = m_filter.split(' '); if (m_itemNode.isValid())
QDirIterator it(dir.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories); dir = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).absoluteDir();
while (it.hasNext()) { else if (m_path.isValid())
QString absolutePath = it.next(); dir = QFileInfo(m_path.toLocalFile()).absoluteDir();
m_comboBox->addItem(dir.relativeFilePath(absolutePath));
}
}
QStringList filterList = m_filter.split(' ');
QDirIterator it(dir.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) {
QString absolutePath = it.next();
m_comboBox->addItem(dir.relativeFilePath(absolutePath));
}
m_comboBox->setEditText(m_fileName.toString()); m_comboBox->setEditText(m_fileName.toString());
m_lock = false; m_lock = false;
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QToolButton>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox> #include <QComboBox>
#include <QUrl> #include <QUrl>
...@@ -49,7 +49,8 @@ class FileWidget : public QWidget ...@@ -49,7 +49,8 @@ class FileWidget : public QWidget
Q_PROPERTY(QString fileName READ fileName WRITE setFileNameStr NOTIFY fileNameChanged) Q_PROPERTY(QString fileName READ fileName WRITE setFileNameStr NOTIFY fileNameChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter) Q_PROPERTY(QString filter READ filter WRITE setFilter)
Q_PROPERTY(bool showComboBox READ showComboBox WRITE setShowComboBox) Q_PROPERTY(bool showComboBox READ showComboBox WRITE setShowComboBox)
Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged) Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged)
Q_PROPERTY(QUrl path READ path WRITE setPath)
public: public:
...@@ -67,6 +68,10 @@ public: ...@@ -67,6 +68,10 @@ public:
} }
void setPath(const QUrl &url) { m_path = url; setupComboBox(); }
QUrl path() const { return m_path; }
QString text() const QString text() const
{ {
return QString(); return QString();
...@@ -104,10 +109,11 @@ private: ...@@ -104,10 +109,11 @@ private:
void setupComboBox(); void setupComboBox();
QPushButton *m_pushButton; QToolButton *m_pushButton;
QLineEdit *m_lineEdit; QLineEdit *m_lineEdit;
QComboBox *m_comboBox; QComboBox *m_comboBox;
QUrl m_fileName; QUrl m_fileName;
QUrl m_path;
QmlDesigner::QmlItemNode m_itemNode; QmlDesigner::QmlItemNode m_itemNode;
QString m_filter; QString m_filter;
bool m_showComboBox; bool m_showComboBox;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment