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: hjk <qthjk@ovi.com>
This commit is contained in:
Friedemann Kleint
2012-07-24 16:41:15 +02:00
committed by hjk
parent 3fc4511fdf
commit 1b9cf76600
6 changed files with 29 additions and 13 deletions

View File

@@ -69,7 +69,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Start Remote Analysis")); setWindowTitle(tr("Start Remote Analysis"));
d->profileChooser = new ProfileChooser(this, true); d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->executable = new QLineEdit(this); d->executable = new QLineEdit(this);
d->arguments = new QLineEdit(this); d->arguments = new QLineEdit(this);
d->workingDirectory = new QLineEdit(this); d->workingDirectory = new QLineEdit(this);

View File

@@ -215,7 +215,7 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
d->overrideStartScriptFileName->setExpectedKind(PathChooser::File); d->overrideStartScriptFileName->setExpectedKind(PathChooser::File);
d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script")); 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); QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine); line->setFrameShape(QFrame::HLine);
@@ -346,7 +346,7 @@ AttachExternalDialog::AttachExternalDialog(QWidget *parent)
d->filterWidget = new FilterLineEdit(this); d->filterWidget = new FilterLineEdit(this);
d->filterWidget->setFocus(Qt::TabFocusReason); 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 = new QTreeView(this);
d->procView->setAlternatingRowColors(true); d->procView->setAlternatingRowColors(true);
@@ -628,7 +628,7 @@ StartExternalDialog::StartExternalDialog(QWidget *parent)
d->runInTerminalCheckBox = new QCheckBox(this); 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 = new QCheckBox(this);
d->breakAtMainCheckBox->setText(QString()); d->breakAtMainCheckBox->setText(QString());
@@ -939,7 +939,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent, bool enableStartScript)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Start Debugger")); setWindowTitle(tr("Start Debugger"));
d->profileChooser = new ProfileChooser(this); d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->executablePathChooser = new PathChooser(this); d->executablePathChooser = new PathChooser(this);
d->executablePathChooser->setExpectedKind(PathChooser::File); d->executablePathChooser->setExpectedKind(PathChooser::File);
@@ -1149,7 +1149,7 @@ AttachToQmlPortDialog::AttachToQmlPortDialog(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Start Debugger")); setWindowTitle(tr("Start Debugger"));
d->profileChooser = new ProfileChooser(this); d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->hostLineEdit = new QLineEdit(this); d->hostLineEdit = new QLineEdit(this);
d->hostLineEdit->setText(QString::fromUtf8("localhost")); d->hostLineEdit->setText(QString::fromUtf8("localhost"));

View File

@@ -114,7 +114,7 @@ LoadRemoteCoreFileDialog::LoadRemoteCoreFileDialog(QWidget *parent)
d->deviceComboBox = new QComboBox(this); d->deviceComboBox = new QComboBox(this);
d->profileChooser = new ProfileChooser(this); d->profileChooser = new ProfileChooser(this, ProfileChooser::RemoteDebugging);
d->fileSystemModel = new SftpFileSystemModel(this); d->fileSystemModel = new SftpFileSystemModel(this);
//executablePathChooser = new PathChooser(q); //executablePathChooser = new PathChooser(q);

View File

@@ -43,21 +43,28 @@
namespace ProjectExplorer { namespace ProjectExplorer {
ProfileChooser::ProfileChooser(QWidget *parent, bool hostAbiOnly) : ProfileChooser::ProfileChooser(QWidget *parent, unsigned flags) :
QComboBox(parent) QComboBox(parent)
{ {
populate(flags);
}
void ProfileChooser::populate(unsigned flags)
{
clear();
const Abi hostAbi = Abi::hostAbi(); const Abi hostAbi = Abi::hostAbi();
foreach (const Profile *profile, ProfileManager::instance()->profiles()) { foreach (const Profile *profile, ProfileManager::instance()->profiles()) {
if (!profile->isValid()) if (!profile->isValid() && !(flags & IncludeInvalidProfiles))
continue; continue;
ToolChain *tc = ToolChainProfileInformation::toolChain(profile); ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
if (!tc) if (!tc)
continue; continue;
const Abi abi = tc->targetAbi(); const Abi abi = tc->targetAbi();
if (hostAbiOnly && hostAbi.os() != abi.os()) if ((flags & HostAbiOnly) && hostAbi.os() != abi.os())
continue; continue;
const QString debuggerCommand = profile->value(Core::Id("Debugger.Information")).toString(); const QString debuggerCommand = profile->value(Core::Id("Debugger.Information")).toString();
if ((flags & HasDebugger) && debuggerCommand.isEmpty())
continue;
const QString completeBase = QFileInfo(debuggerCommand).completeBaseName(); const QString completeBase = QFileInfo(debuggerCommand).completeBaseName();
const QString name = tr("%1 (%2)").arg(profile->displayName(), completeBase); const QString name = tr("%1 (%2)").arg(profile->displayName(), completeBase);
addItem(name, qVariantFromValue(profile->id())); addItem(name, qVariantFromValue(profile->id()));

View File

@@ -47,7 +47,15 @@ class PROJECTEXPLORER_EXPORT ProfileChooser : public QComboBox
Q_OBJECT Q_OBJECT
public: 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); void setCurrentProfileId(Core::Id id);
Core::Id currentProfileId() const; Core::Id currentProfileId() const;
@@ -55,6 +63,7 @@ public:
Profile *currentProfile() const; Profile *currentProfile() const;
private: private:
void populate(unsigned flags);
Profile *profileAt(int index) const; Profile *profileAt(int index) const;
}; };

View File

@@ -119,7 +119,7 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q
deviceComboBox = new QComboBox(q); deviceComboBox = new QComboBox(q);
profileChooser = new ProfileChooser(q); profileChooser = new ProfileChooser(q, ProfileChooser::RemoteDebugging);
// sysrootPathChooser = new PathChooser(q); // sysrootPathChooser = new PathChooser(q);
// sysrootPathChooser->setExpectedKind(PathChooser::Directory); // sysrootPathChooser->setExpectedKind(PathChooser::Directory);
// sysrootPathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Sysroot")); // sysrootPathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Sysroot"));