28 #include <QFileDialog>
30 #include "core/common/WLogger.h"
31 #include "core/common/WPropertyVariable.h"
32 #include "core/common/constraints/WPropertyConstraintTypes.h"
33 #include "../WGuiConsts.h"
35 #include "WPropertyFilenameWidget.h"
39 m_fnProperty( property ),
40 m_button( &m_parameterWidgets ),
41 m_layout( &m_parameterWidgets ),
42 m_asText( &m_informationWidgets ),
43 m_infoLayout( &m_informationWidgets )
50 m_layout.setMargin( WGLOBAL_MARGIN );
51 m_layout.setSpacing( WGLOBAL_SPACING );
59 m_button.setMinimumHeight( WMIN_WIDGET_HEIGHT );
62 setAcceptDrops(
true );
78 QString val = QString::fromStdString(
m_fnProperty->get().filename().string() );
87 QFileDialog::Option options =
m_fnProperty->countConstraint( PC_CONFIRMOVERWRITE ) != 0 ?
88 ( QFileDialog::Option ) 0 : QFileDialog::DontConfirmOverwrite;
91 if(
m_fnProperty->countConstraint( PC_ISDIRECTORY ) != 0 )
94 path = QFileDialog::getExistingDirectory(
this,
95 QString::fromStdString(
"Select directory for " +
m_fnProperty->getName() ),
99 else if(
m_fnProperty->countConstraint( PC_PATHEXISTS ) != 0 )
101 path = QFileDialog::getOpenFileName(
this,
102 QString::fromStdString(
"Select existing file for " +
m_fnProperty->getName() ),
103 QString::fromStdString(
m_fnProperty->get().string() ), QString(), 0,
108 path = QFileDialog::getSaveFileName(
this,
109 QString::fromStdString(
"Select file for " +
m_fnProperty->getName() ),
110 QString::fromStdString(
m_fnProperty->get().string() ), QString(), 0,
124 if(
event->mimeData()->hasUrls() && (
event->mimeData()->urls().size() == 1 ) )
127 QUrl url = *(
event->mimeData()->urls().begin() );
128 QString path = url.toLocalFile();
129 QFileInfo info( path );
131 bool shouldBeDir = (
m_fnProperty->countConstraint( PC_ISDIRECTORY ) != 0 );
132 bool shouldExist = (
m_fnProperty->countConstraint( PC_PATHEXISTS ) != 0 );
135 bool accept = ( shouldBeDir && info.isDir() ) || !shouldBeDir;
136 accept &= ( shouldExist && info.exists() ) || !shouldExist;
138 event->setAccepted( accept );
144 if(
event->mimeData()->hasUrls() && (
event->mimeData()->urls().size() == 1 ) )
147 QUrl url = *(
event->mimeData()->urls().begin() );
148 QString path = url.toLocalFile();
149 QFileInfo info( path );
151 bool shouldBeDir = (
m_fnProperty->countConstraint( PC_ISDIRECTORY ) != 0 );
152 bool shouldExist = (
m_fnProperty->countConstraint( PC_PATHEXISTS ) != 0 );
155 bool accept = ( shouldBeDir && info.isDir() ) || !shouldBeDir;
156 accept &= ( shouldExist && info.exists() ) || !shouldExist;
virtual void setText(const QString &text)
reimplemented function to setText