Commit 1b9cf766 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk
Browse files

ProfileChooser: Introduce flags specifying which profiles to list.



Introduce flags to filter profiles that have a debugger
configured, restrict to host abi and include invalid profiles
(which is not relevant if only debugging is desired).
Introduce convenience flags for debugging.

Introduce populate() function for cleanliness.

Change-Id: I476c40cc9a59e4dd5b1bc7c49597e9169c053754
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 3fc4511f
......@@ -69,7 +69,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Start Remote Analysis"));
d->profileChooser = new ProfileChooser(this, true);
d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->executable = new QLineEdit(this);
d->arguments = new QLineEdit(this);
d->workingDirectory = new QLineEdit(this);
......
......@@ -215,7 +215,7 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
d->overrideStartScriptFileName->setExpectedKind(PathChooser::File);
d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script"));
d->profileComboBox = new ProfileChooser(this, false);
d->profileComboBox = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
......@@ -346,7 +346,7 @@ AttachExternalDialog::AttachExternalDialog(QWidget *parent)
d->filterWidget = new FilterLineEdit(this);
d->filterWidget->setFocus(Qt::TabFocusReason);
d->profileComboBox = new ProfileChooser(this, true);
d->profileComboBox = new ProfileChooser(this, ProfileChooser::LocalDebugging);
d->procView = new QTreeView(this);
d->procView->setAlternatingRowColors(true);
......@@ -628,7 +628,7 @@ StartExternalDialog::StartExternalDialog(QWidget *parent)
d->runInTerminalCheckBox = new QCheckBox(this);
d->profileChooser = new ProfileChooser(this, true);
d->profileChooser = new ProfileChooser(this, ProfileChooser::LocalDebugging);
d->breakAtMainCheckBox = new QCheckBox(this);
d->breakAtMainCheckBox->setText(QString());
......@@ -939,7 +939,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent, bool enableStartScript)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Start Debugger"));
d->profileChooser = new ProfileChooser(this);
d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->executablePathChooser = new PathChooser(this);
d->executablePathChooser->setExpectedKind(PathChooser::File);
......@@ -1149,7 +1149,7 @@ AttachToQmlPortDialog::AttachToQmlPortDialog(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Start Debugger"));
d->profileChooser = new ProfileChooser(this);
d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->hostLineEdit = new QLineEdit(this);
d->hostLineEdit->setText(QString::fromUtf8("localhost"));
......
......@@ -114,7 +114,7 @@ LoadRemoteCoreFileDialog::LoadRemoteCoreFileDialog(QWidget *parent)
d->deviceComboBox = new QComboBox(this);
d->profileChooser = new ProfileChooser(this);
d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->fileSystemModel = new SftpFileSystemModel(this);
//executablePathChooser = new PathChooser(q);
......
......@@ -43,21 +43,28 @@
namespace ProjectExplorer {
ProfileChooser::ProfileChooser(QWidget *parent, bool hostAbiOnly) :
ProfileChooser::ProfileChooser(QWidget *parent, unsigned flags) :
QComboBox(parent)
{
populate(flags);
}
void ProfileChooser::populate(unsigned flags)
{
clear();
const Abi hostAbi = Abi::hostAbi();
foreach (const Profile *profile, ProfileManager::instance()->profiles()) {
if (!profile->isValid())
if (!profile->isValid() && !(flags & IncludeInvalidProfiles))
continue;
ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
if (!tc)
continue;
const Abi abi = tc->targetAbi();
if (hostAbiOnly && hostAbi.os() != abi.os())
if ((flags & HostAbiOnly) && hostAbi.os() != abi.os())
continue;
const QString debuggerCommand = profile->value(Core::Id("Debugger.Information")).toString();
if ((flags & HasDebugger) && debuggerCommand.isEmpty())
continue;
const QString completeBase = QFileInfo(debuggerCommand).completeBaseName();
const QString name = tr("%1 (%2)").arg(profile->displayName(), completeBase);
addItem(name, qVariantFromValue(profile->id()));
......
......@@ -47,7 +47,15 @@ class PROJECTEXPLORER_EXPORT ProfileChooser : public QComboBox
Q_OBJECT
public:
explicit ProfileChooser(QWidget *parent, bool hostAbiOnly = false);
enum Flags {
HostAbiOnly = 0x1,
IncludeInvalidProfiles = 0x2,
HasDebugger = 0x4,
RemoteDebugging = IncludeInvalidProfiles | HasDebugger,
LocalDebugging = RemoteDebugging | HostAbiOnly
};
explicit ProfileChooser(QWidget *parent, unsigned flags = 0);
void setCurrentProfileId(Core::Id id);
Core::Id currentProfileId() const;
......@@ -55,6 +63,7 @@ public:
Profile *currentProfile() const;
private:
void populate(unsigned flags);
Profile *profileAt(int index) const;
};
......
......@@ -119,7 +119,7 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q
deviceComboBox = new QComboBox(q);
profileChooser = new ProfileChooser(q);
profileChooser = new ProfileChooser(q, ProfileChooser::RemoteDebugging);
// sysrootPathChooser = new PathChooser(q);
// sysrootPathChooser->setExpectedKind(PathChooser::Directory);
// sysrootPathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Sysroot"));
......
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