Commit 126a077c authored by hjk's avatar hjk

Inline pluginview widget code

No need to have a single treeview in a .ui file, and one step
closer to make it searchable.

Change-Id: I3aa27ac695ea3c55000473ae56e8c5b0330c1adf
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 5640635d
......@@ -33,7 +33,7 @@ SOURCES += pluginerrorview.cpp \
optionsparser.cpp \
plugincollection.cpp \
pluginerroroverview.cpp
FORMS += pluginview.ui \
FORMS += \
pluginerrorview.ui \
plugindetailsview.ui \
pluginerroroverview.ui
......
......@@ -41,7 +41,6 @@ QtcLibrary {
"pluginview.cpp",
"pluginview.h",
"pluginview.qrc",
"pluginview.ui",
"images/error.png",
"images/notloaded.png",
"images/ok.png",
......
......@@ -31,14 +31,13 @@
#include "pluginmanager.h"
#include "pluginspec.h"
#include "plugincollection.h"
#include "ui_pluginview.h"
#include <QDebug>
#include <QDir>
#include <QGridLayout>
#include <QHeaderView>
#include <QTreeWidgetItem>
#include <QPalette>
#include <QDebug>
#include <QTreeWidgetItem>
/*!
\class ExtensionSystem::PluginView
......@@ -76,12 +75,30 @@ Q_DECLARE_METATYPE(ExtensionSystem::PluginCollection*)
*/
PluginView::PluginView(QWidget *parent)
: QWidget(parent),
m_ui(new Internal::Ui::PluginView),
m_allowCheckStateUpdate(true),
C_LOAD(1)
{
m_ui->setupUi(this);
QHeaderView *header = m_ui->categoryWidget->header();
m_categoryWidget = new QTreeWidget(this);
m_categoryWidget->setAlternatingRowColors(true);
m_categoryWidget->setIndentation(20);
m_categoryWidget->setUniformRowHeights(true);
m_categoryWidget->setSortingEnabled(true);
m_categoryWidget->setColumnCount(4);
m_categoryWidget->setColumnWidth(C_LOAD, 40);
m_categoryWidget->header()->setDefaultSectionSize(120);
m_categoryWidget->header()->setMinimumSectionSize(35);
QTreeWidgetItem *headerItem = m_categoryWidget->headerItem();
headerItem->setText(0, tr("Name"));
headerItem->setText(1, tr("Load"));
headerItem->setText(2, tr("Version"));
headerItem->setText(3, tr("Vendor"));
QGridLayout *gridLayout = new QGridLayout(this);
gridLayout->setContentsMargins(2, 2, 2, 2);
gridLayout->addWidget(m_categoryWidget, 1, 0, 1, 1);
QHeaderView *header = m_categoryWidget->header();
header->setResizeMode(0, QHeaderView::ResizeToContents);
header->setResizeMode(2, QHeaderView::ResizeToContents);
......@@ -89,16 +106,14 @@ PluginView::PluginView(QWidget *parent)
m_errorIcon = QIcon(QLatin1String(":/extensionsystem/images/error.png"));
m_notLoadedIcon = QIcon(QLatin1String(":/extensionsystem/images/notloaded.png"));
m_ui->categoryWidget->setColumnWidth(C_LOAD, 40);
// cannot disable these
m_whitelist << QString::fromLatin1("Core") << QString::fromLatin1("Locator")
<< QString::fromLatin1("Find") << QString::fromLatin1("TextEditor");
connect(PluginManager::instance(), SIGNAL(pluginsChanged()), this, SLOT(updateList()));
connect(m_ui->categoryWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
connect(m_categoryWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
this, SLOT(selectPlugin(QTreeWidgetItem*)));
connect(m_ui->categoryWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
connect(m_categoryWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
this, SLOT(activatePlugin(QTreeWidgetItem*)));
updateList();
......@@ -109,7 +124,6 @@ PluginView::PluginView(QWidget *parent)
*/
PluginView::~PluginView()
{
delete m_ui;
}
/*!
......@@ -117,16 +131,16 @@ PluginView::~PluginView()
*/
PluginSpec *PluginView::currentPlugin() const
{
if (!m_ui->categoryWidget->currentItem())
if (!m_categoryWidget->currentItem())
return 0;
if (!m_ui->categoryWidget->currentItem()->data(0, Qt::UserRole).isNull())
return m_ui->categoryWidget->currentItem()->data(0, Qt::UserRole).value<PluginSpec *>();
if (!m_categoryWidget->currentItem()->data(0, Qt::UserRole).isNull())
return m_categoryWidget->currentItem()->data(0, Qt::UserRole).value<PluginSpec *>();
return 0;
}
void PluginView::updateList()
{
connect(m_ui->categoryWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
connect(m_categoryWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
this, SLOT(updatePluginSettings(QTreeWidgetItem*,int)));
PluginCollection *defaultCollection = 0;
......@@ -176,15 +190,15 @@ void PluginView::updateList()
updatePluginDependencies();
m_ui->categoryWidget->clear();
m_categoryWidget->clear();
if (!m_items.isEmpty()) {
m_ui->categoryWidget->addTopLevelItems(m_items);
m_ui->categoryWidget->expandAll();
m_categoryWidget->addTopLevelItems(m_items);
m_categoryWidget->expandAll();
}
m_ui->categoryWidget->sortItems(0, Qt::AscendingOrder);
if (m_ui->categoryWidget->topLevelItemCount())
m_ui->categoryWidget->setCurrentItem(m_ui->categoryWidget->topLevelItem(0));
m_categoryWidget->sortItems(0, Qt::AscendingOrder);
if (m_categoryWidget->topLevelItemCount())
m_categoryWidget->setCurrentItem(m_categoryWidget->topLevelItem(0));
}
int PluginView::parsePluginSpecs(QTreeWidgetItem *parentItem, Qt::CheckState &groupState, QList<PluginSpec*> plugins)
......
......@@ -37,6 +37,7 @@
#include <QIcon>
QT_BEGIN_NAMESPACE
class QTreeWidget;
class QTreeWidgetItem;
QT_END_NAMESPACE
......@@ -46,12 +47,6 @@ class PluginManager;
class PluginSpec;
class PluginCollection;
namespace Internal {
namespace Ui {
class PluginView;
} // namespace Ui
} // namespace Internal
class EXTENSIONSYSTEM_EXPORT PluginView : public QWidget
{
Q_OBJECT
......@@ -79,7 +74,7 @@ private:
void updatePluginDependencies();
int parsePluginSpecs(QTreeWidgetItem *parentItem, Qt::CheckState &groupState, QList<PluginSpec*> plugins);
Internal::Ui::PluginView *m_ui;
QTreeWidget *m_categoryWidget;
QList<QTreeWidgetItem*> m_items;
QHash<PluginSpec*, QTreeWidgetItem*> m_specToItem;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtensionSystem::Internal::PluginView</class>
<widget class="QWidget" name="ExtensionSystem::Internal::PluginView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>773</width>
<height>304</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>2</number>
</property>
<item row="1" column="0">
<widget class="QTreeWidget" name="categoryWidget">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="indentation">
<number>20</number>
</property>
<property name="rootIsDecorated">
<bool>true</bool>
</property>
<property name="uniformRowHeights">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
</property>
<attribute name="headerDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="headerHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>35</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>35</number>
</attribute>
<attribute name="headerHighlightSections">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Load</string>
</property>
</column>
<column>
<property name="text">
<string>Version</string>
</property>
</column>
<column>
<property name="text">
<string>Vendor</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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