diff options
author | kh1 <qt-info@nokia.com> | 2011-06-20 14:01:49 +0200 |
---|---|---|
committer | kh1 <qt-info@nokia.com> | 2011-06-20 14:01:49 +0200 |
commit | 975eefb869b1bfa19d6590ad83fa7ae1f5f71089 (patch) | |
tree | 6e6f1249d7dff986bbfb44523062c04f93598cca | |
parent | 46be5a4eac4474b42a4ea6f61430d59a8604a3c2 (diff) |
Fix bug where we had to specify a column more then needed.
-rw-r--r-- | examples/testapp/componentselectiondialog.cpp | 2 | ||||
-rw-r--r-- | installerbuilder/libinstaller/componentmodel.cpp | 22 | ||||
-rw-r--r-- | installerbuilder/libinstaller/packagemanagergui.cpp | 4 |
3 files changed, 13 insertions, 15 deletions
diff --git a/examples/testapp/componentselectiondialog.cpp b/examples/testapp/componentselectiondialog.cpp index 4db0a2d5d..d46f08275 100644 --- a/examples/testapp/componentselectiondialog.cpp +++ b/examples/testapp/componentselectiondialog.cpp @@ -123,7 +123,7 @@ ComponentSelectionDialog::ComponentSelectionDialog(PackageManagerCore *core, QWi d->ui.splitter->setStretchFactor(1, 1); d->ui.splitter->setCollapsible(0, false); - d->componentModel = new ComponentModel(5, core); + d->componentModel = new ComponentModel(4, core); d->componentModel->setHeaderData(0, Qt::Horizontal, tr("Name")); d->componentModel->setHeaderData(1, Qt::Horizontal, tr("Installed Version")); d->componentModel->setHeaderData(2, Qt::Horizontal, tr("New Version")); diff --git a/installerbuilder/libinstaller/componentmodel.cpp b/installerbuilder/libinstaller/componentmodel.cpp index 992f0eb50..72fa8766d 100644 --- a/installerbuilder/libinstaller/componentmodel.cpp +++ b/installerbuilder/libinstaller/componentmodel.cpp @@ -131,21 +131,19 @@ bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, in QVariant ComponentModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Vertical || section < 0 || section >= columnCount()) - return QAbstractItemModel::headerData(section, orientation, role); - return m_headerData.at(section); + if (section >= 0 && section < columnCount() && orientation == Qt::Horizontal && role == Qt::DisplayRole) + return m_headerData.at(section); + return QAbstractItemModel::headerData(section, orientation, role); } -bool ComponentModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, - int role) +bool ComponentModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { - if (orientation == Qt::Vertical || section < 0 || section >= columnCount()) - return QAbstractItemModel::setHeaderData(section, orientation, value, role); - - m_headerData.replace(section, value); - emit headerDataChanged(orientation, section, section); - - return true; + if (section >= 0 && section < columnCount() && orientation == Qt::Horizontal && role == Qt::DisplayRole) { + m_headerData.replace(section, value); + emit headerDataChanged(orientation, section, section); + return true; + } + return QAbstractItemModel::setHeaderData(section, orientation, value, role); } Qt::ItemFlags ComponentModel::flags(const QModelIndex &index) const diff --git a/installerbuilder/libinstaller/packagemanagergui.cpp b/installerbuilder/libinstaller/packagemanagergui.cpp index 08491ce54..38dff0b0b 100644 --- a/installerbuilder/libinstaller/packagemanagergui.cpp +++ b/installerbuilder/libinstaller/packagemanagergui.cpp @@ -875,8 +875,8 @@ public: : q(qq) , m_core(core) , m_treeView(new QTreeView(q)) - , m_allModel(new ComponentModel(5, m_core)) - , m_updaterModel(new ComponentModel(5, m_core)) + , m_allModel(new ComponentModel(4, m_core)) + , m_updaterModel(new ComponentModel(4, m_core)) { m_treeView->setObjectName(QLatin1String("ComponentTreeView")); |