//
#include "QtxPathEdit.h"
+#include <QApplication>
#include <QLayout>
#include <QDirModel>
#include <QLineEdit>
#include <QCompleter>
+#include <QKeyEvent>
#include <QToolButton>
#include <QFileDialog>
#include <QRegExpValidator>
\brief Constructor
\param type widget mode (Qtx::PathType)
\param parent parent widget
+ \param browse if \c true, automatically finish editing of file path when
+ user presses OK in "Select File/Directory" dialog box
\sa pathType(), setPathType()
*/
-QtxPathEdit::QtxPathEdit( const Qtx::PathType type, QWidget* parent )
+QtxPathEdit::QtxPathEdit( const Qtx::PathType type, QWidget* parent, bool browse )
: QFrame( parent ),
- myType( type )
+ myType( type ),
+ myBrowse ( browse )
{
initialize();
}
Qtx::PT_OpenFile mode is used by default.
\param parent parent widget
+ \param browse if \c true, automatically finish editing of file path when
+ user presses OK in "Select File/Directory" dialog box
\sa pathType(), setPathType()
*/
-QtxPathEdit::QtxPathEdit( QWidget* parent )
+QtxPathEdit::QtxPathEdit( QWidget* parent, bool browse )
: QFrame( parent ),
- myType( Qtx::PT_OpenFile )
+ myType( Qtx::PT_OpenFile ),
+ myBrowse ( browse )
{
initialize();
}
myPath->setText( QDir::convertSeparators( path ) );
myPath->setFocus();
+
+ if ( !path.isEmpty() && myBrowse )
+ QApplication::postEvent( myPath, new QKeyEvent( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier ) );
}
/*!
Q_OBJECT
public:
- QtxPathEdit( const Qtx::PathType, QWidget* = 0 );
- QtxPathEdit( QWidget* = 0 );
+ QtxPathEdit( const Qtx::PathType, QWidget* = 0, bool = false );
+ QtxPathEdit( QWidget* = 0, bool = false );
virtual ~QtxPathEdit();
QString path() const;
QLineEdit* myPath;
Qtx::PathType myType;
QString myFilter;
+ bool myBrowse;
};
#endif