Commit a6032652 authored by hjk's avatar hjk
Browse files

ProjectWindow: More tree polish



- Remove 'panel memory effect' when switching kits

  Previously, each target entry memorized when its Build or
  Run page was used, and when switching to the target, that
  page came up.

  Now, don't use that when switching targets, but instead
  take the same page as is selected on the target we are
  switching from.

- Disable selection of the Build&Run and Project Settings
  "group entries"

Change-Id: I2214f8edc38be2e76a50f8984aa75d8f78b62026
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Alessandro Portale's avatarAlessandro Portale <alessandro.portale@qt.io>
parent f7e4c2fb
......@@ -148,7 +148,7 @@ public:
Qt::ItemFlags flags(int) const override
{
return Qt::ItemIsEnabled;
return Qt::NoItemFlags;
}
QVariant data(int column, int role) const override
......@@ -179,13 +179,6 @@ public:
return true;
}
if (role == ItemActivatedDirectlyRole) {
m_currentPanelIndex = 0; // Use the first ('Editor') page.
parent()->setData(0, QVariant::fromValue(static_cast<TreeItem *>(this)),
ItemActivatedFromBelowRole);
return true;
}
return false;
}
......@@ -541,10 +534,13 @@ void SelectorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QStyleOptionViewItem opt = option;
if (TreeItem *item = model->itemForIndex(index)) {
switch (item->level()) {
case 2:
case 2: {
QColor col = creatorTheme()->color(Theme::TextColorNormal);
opt.palette.setColor(QPalette::Text, col);
opt.font.setBold(true);
opt.font.setPointSizeF(opt.font.pointSizeF() * 1.2);
break;
}
}
}
QStyledItemDelegate::paint(painter, opt, index);
......
......@@ -313,6 +313,8 @@ class TargetItem : public TypedTreeItem<TreeItem, TargetGroupItem>
Q_DECLARE_TR_FUNCTIONS(TargetSettingsPanelWidget)
public:
enum { DefaultPage = 1 }; // Run page.
TargetItem(Project *project, Id kitId)
: m_project(project), m_kitId(kitId)
{
......@@ -405,10 +407,16 @@ public:
if (role == ItemActivatedDirectlyRole) {
QTC_ASSERT(!data.isValid(), return false);
if (!isEnabled()) {
m_currentChild = DefaultPage;
Kit *k = KitManager::find(m_kitId);
m_project->addTarget(m_project->createTarget(k));
} else {
// Go to Run page, when on Run previously etc.
TargetItem *previousItem = parent()->currentTargetItem();
m_currentChild = previousItem ? previousItem->m_currentChild : DefaultPage;
SessionManager::setActiveTarget(m_project, target(), SetActive::Cascade);
parent()->setData(column, QVariant::fromValue(static_cast<TreeItem *>(this)),
ItemActivatedFromBelowRole);
}
return true;
}
......@@ -506,7 +514,7 @@ public:
public:
QPointer<Project> m_project; // Not owned.
Id m_kitId;
int m_currentChild = 1; // Use run page by default.
int m_currentChild = DefaultPage; // Use run page by default.
private:
enum class IconOverlay {
......@@ -792,7 +800,7 @@ bool TargetGroupItem::setData(int column, const QVariant &data, int role)
Qt::ItemFlags TargetGroupItem::flags(int) const
{
return Qt::ItemIsEnabled;
return Qt::NoItemFlags;
}
TargetItem *TargetGroupItem::currentTargetItem() const
......
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