From fdfeae05c194e1870b2f2f8b0c0bdcecb4d73c6e Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sun, 30 Mar 2014 18:17:40 -0400 Subject: [PATCH] Add some commented-out code about using QFileSystemModel + QCompleter This needs looked at later. The below causes a noticable delay when opening the dialog - I'm not entirely sure this is the best way to handle this. Issue is QLineEdit->SetCompleter() won't work w/ KDE's KUrlCompletion --- src/EditProfileDialog.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index bb6c49235..f52d6dc4b 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include // KDE #include @@ -261,17 +263,34 @@ void EditProfileDialog::setupGeneralPage(const Profile::Ptr profile) ShellCommand command(profile->command() , profile->arguments()); _ui->commandEdit->setText(command.fullCommand()); + #pragma message("Look at this setCompletionObject again") // KUrlCompletion* exeCompletion = new KUrlCompletion(KUrlCompletion::ExeCompletion); // exeCompletion->setParent(this); // exeCompletion->setDir(QUrl()); // _ui->commandEdit->setCompletionObject(exeCompletion); +/* The below causes a noticable delay when opening the dialog - I'm not entirely sure + this is the best way to handle this. + Issue is that QLineEdit->SetCompleter() won't work w/ KDE's KUrlCompletion + + QFileSystemModel *commandEditDirModel = new QFileSystemModel(this); + commandEditDirModel->setFilter(QDir::AllEntries); + QFileInfo commandFileInfo(profile->command()); + // If command is /usr/bin/zsh, start at /usr/bin for completion + commandEditDirModel->setRootPath(commandFileInfo.absolutePath()); + QCompleter *commandEditCompleter = new QCompleter(this); + commandEditCompleter->setModel(commandEditDirModel); + _ui->commandEdit->setCompleter(commandEditCompleter); + + QFileSystemModel *initialEditDirModel = new QFileSystemModel(this); + initialEditDirModel->setFilter(QDir::AllEntries); + initialEditDirModel->setRootPath(QString('/')); _ui->initialDirEdit->setText(profile->defaultWorkingDirectory()); -#pragma message("Look at this setCompletionObject again") -// KUrlCompletion* dirCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion); -// dirCompletion->setParent(this); -// _ui->initialDirEdit->setCompletionObject(dirCompletion); + QCompleter *initialDirCompleter = new QCompleter(this); + initialDirCompleter->setModel(initialEditDirModel); + _ui->initialDirEdit->setCompleter(initialDirCompleter); +*/ _ui->initialDirEdit->setClearButtonEnabled(true); _ui->dirSelectButton->setIcon(KIcon("folder-open"));