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
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_lineEdit = new QLineEdit(this);
m_comboBox = new QComboBox(this);
......@@ -126,16 +126,20 @@ void FileWidget::setupComboBox()
m_lock = true;
m_comboBox->clear();
if (m_itemNode.isValid()) {
QDir dir = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).absoluteDir();
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));
}
}
QDir dir;
if (m_itemNode.isValid())
dir = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).absoluteDir();
else if (m_path.isValid())
dir = QFileInfo(m_path.toLocalFile()).absoluteDir();
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_lock = false;
......
......@@ -33,7 +33,7 @@
#include <QtGui/QWidget>
#include <QLabel>
#include <QPushButton>
#include <QToolButton>
#include <QLineEdit>
#include <QComboBox>
#include <QUrl>
......@@ -49,7 +49,8 @@ class FileWidget : public QWidget
Q_PROPERTY(QString fileName READ fileName WRITE setFileNameStr NOTIFY fileNameChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter)
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:
......@@ -67,6 +68,10 @@ public:
}
void setPath(const QUrl &url) { m_path = url; setupComboBox(); }
QUrl path() const { return m_path; }
QString text() const
{
return QString();
......@@ -104,10 +109,11 @@ private:
void setupComboBox();
QPushButton *m_pushButton;
QToolButton *m_pushButton;
QLineEdit *m_lineEdit;
QComboBox *m_comboBox;
QUrl m_fileName;
QUrl m_path;
QmlDesigner::QmlItemNode m_itemNode;
QString m_filter;
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