|
|
|
@ -162,6 +162,8 @@ Private::FileLineEdit::FileLineEdit(QWidget *parent)
@@ -162,6 +162,8 @@ Private::FileLineEdit::FileLineEdit(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
m_completer->setModel(m_completerModel); |
|
|
|
|
setCompleter(m_completer); |
|
|
|
|
|
|
|
|
|
connect(this, &QLineEdit::textChanged, this, &FileLineEdit::validateText); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Private::FileLineEdit::~FileLineEdit() |
|
|
|
@ -215,12 +217,37 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
@@ -215,12 +217,37 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
|
|
|
|
|
m_completerModel->setRootPath(Path(text()).data()); |
|
|
|
|
showCompletionPopup(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const auto *validator = qobject_cast<const FileSystemPathValidator *>(this->validator()); |
|
|
|
|
if (validator) |
|
|
|
|
void Private::FileLineEdit::contextMenuEvent(QContextMenuEvent *event) |
|
|
|
|
{ |
|
|
|
|
QMenu *menu = createStandardContextMenu(); |
|
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
|
|
|
|
|
|
if (m_browseAction) |
|
|
|
|
{ |
|
|
|
|
menu->addSeparator(); |
|
|
|
|
menu->addAction(m_browseAction); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
menu->popup(event->globalPos()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Private::FileLineEdit::showCompletionPopup() |
|
|
|
|
{ |
|
|
|
|
m_completer->setCompletionPrefix(text()); |
|
|
|
|
m_completer->complete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Private::FileLineEdit::validateText() |
|
|
|
|
{ |
|
|
|
|
const auto *validator = qobject_cast<const FileSystemPathValidator *>(this->validator()); |
|
|
|
|
if (!validator) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
const FileSystemPathValidator::TestResult lastTestResult = validator->lastTestResult(); |
|
|
|
|
const QValidator::State lastState = validator->lastValidationState(); |
|
|
|
|
|
|
|
|
|
if (lastTestResult == FileSystemPathValidator::TestResult::OK) |
|
|
|
|
{ |
|
|
|
|
delete m_warningAction; |
|
|
|
@ -243,27 +270,6 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
@@ -243,27 +270,6 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
|
|
|
|
|
m_warningAction->setIcon(style()->standardIcon(QStyle::SP_MessageBoxInformation)); |
|
|
|
|
m_warningAction->setToolTip(warningText(lastTestResult)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Private::FileLineEdit::contextMenuEvent(QContextMenuEvent *event) |
|
|
|
|
{ |
|
|
|
|
QMenu *menu = createStandardContextMenu(); |
|
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
|
|
|
|
|
|
if (m_browseAction) |
|
|
|
|
{ |
|
|
|
|
menu->addSeparator(); |
|
|
|
|
menu->addAction(m_browseAction); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
menu->popup(event->globalPos()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Private::FileLineEdit::showCompletionPopup() |
|
|
|
|
{ |
|
|
|
|
m_completer->setCompletionPrefix(text()); |
|
|
|
|
m_completer->complete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString Private::FileLineEdit::warningText(const FileSystemPathValidator::TestResult result) |
|
|
|
|