forked from qt-creator/qt-creator
BaseTreeView: Make resizeColumns() publicly accessible
Simplifies the only used code path through the model and a custom signal. Change-Id: I9bbab725cdd122b7261a8f14b101786e38e61e57 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -47,8 +47,6 @@ const char ColumnKey[] = "Columns";
|
|||||||
|
|
||||||
class BaseTreeViewPrivate : public QObject
|
class BaseTreeViewPrivate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseTreeViewPrivate(BaseTreeView *parent)
|
explicit BaseTreeViewPrivate(BaseTreeView *parent)
|
||||||
: q(parent), m_settings(0), m_expectUserChanges(false), m_progressIndicator(0)
|
: q(parent), m_settings(0), m_expectUserChanges(false), m_progressIndicator(0)
|
||||||
@@ -169,7 +167,7 @@ public:
|
|||||||
return minimum;
|
return minimum;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_SLOT void resizeColumns() // Needs moc, see BaseTreeView::setModel
|
void resizeColumns()
|
||||||
{
|
{
|
||||||
QHeaderView *h = q->header();
|
QHeaderView *h = q->header();
|
||||||
QTC_ASSERT(h, return);
|
QTC_ASSERT(h, return);
|
||||||
@@ -281,7 +279,6 @@ void BaseTreeView::setModel(QAbstractItemModel *m)
|
|||||||
};
|
};
|
||||||
#define DESC(sign, receiver, slot) { #sign, SIGNAL(sign), receiver, SLOT(slot) }
|
#define DESC(sign, receiver, slot) { #sign, SIGNAL(sign), receiver, SLOT(slot) }
|
||||||
const ExtraConnection c[] = {
|
const ExtraConnection c[] = {
|
||||||
DESC(columnAdjustmentRequested(), d, resizeColumns()),
|
|
||||||
DESC(requestExpansion(QModelIndex), this, expand(QModelIndex))
|
DESC(requestExpansion(QModelIndex), this, expand(QModelIndex))
|
||||||
};
|
};
|
||||||
#undef DESC
|
#undef DESC
|
||||||
@@ -406,6 +403,11 @@ void BaseTreeView::rowClicked(const QModelIndex &index)
|
|||||||
model()->setData(index, QVariant(), ItemClickedRole);
|
model()->setData(index, QVariant(), ItemClickedRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTreeView::resizeColumns()
|
||||||
|
{
|
||||||
|
d->resizeColumns();
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTreeView::setSettings(QSettings *settings, const QByteArray &key)
|
void BaseTreeView::setSettings(QSettings *settings, const QByteArray &key)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!d->m_settings, qDebug() << "DUPLICATED setSettings" << key);
|
QTC_ASSERT(!d->m_settings, qDebug() << "DUPLICATED setSettings" << key);
|
||||||
@@ -454,5 +456,3 @@ QModelIndexList ItemViewEvent::currentOrSelectedRows() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|
||||||
#include "basetreeview.moc"
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public:
|
|||||||
|
|
||||||
void showProgressIndicator();
|
void showProgressIndicator();
|
||||||
void hideProgressIndicator();
|
void hideProgressIndicator();
|
||||||
|
void resizeColumns();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void aboutToShow();
|
void aboutToShow();
|
||||||
|
|||||||
@@ -3154,6 +3154,7 @@ void updateWatchersWindow(bool showWatch, bool showReturn)
|
|||||||
{
|
{
|
||||||
dd->m_watchersWindow->setVisible(showWatch);
|
dd->m_watchersWindow->setVisible(showWatch);
|
||||||
dd->m_returnWindow->setVisible(showReturn);
|
dd->m_returnWindow->setVisible(showReturn);
|
||||||
|
dd->m_localsView->resizeColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasSnapshots()
|
bool hasSnapshots()
|
||||||
|
|||||||
@@ -1126,7 +1126,7 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
|
|||||||
m_expandedINames.remove(item->iname);
|
m_expandedINames.remove(item->iname);
|
||||||
}
|
}
|
||||||
if (item->iname.contains('.'))
|
if (item->iname.contains('.'))
|
||||||
emit columnAdjustmentRequested();
|
m_handler->updateWatchersWindow();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case LocalsTypeFormatRole:
|
case LocalsTypeFormatRole:
|
||||||
@@ -2347,8 +2347,6 @@ void WatchModel::clearWatches()
|
|||||||
|
|
||||||
void WatchHandler::updateWatchersWindow()
|
void WatchHandler::updateWatchersWindow()
|
||||||
{
|
{
|
||||||
emit m_model->columnAdjustmentRequested();
|
|
||||||
|
|
||||||
// Force show/hide of watchers and return view.
|
// Force show/hide of watchers and return view.
|
||||||
int showWatch = !theWatcherNames.isEmpty();
|
int showWatch = !theWatcherNames.isEmpty();
|
||||||
int showReturn = m_model->m_returnRoot->childCount() != 0;
|
int showReturn = m_model->m_returnRoot->childCount() != 0;
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ signals:
|
|||||||
void currentIndexRequested(const QModelIndex &idx);
|
void currentIndexRequested(const QModelIndex &idx);
|
||||||
void itemIsExpanded(const QModelIndex &idx);
|
void itemIsExpanded(const QModelIndex &idx);
|
||||||
void inameIsExpanded(const QString &iname);
|
void inameIsExpanded(const QString &iname);
|
||||||
void columnAdjustmentRequested();
|
|
||||||
void updateStarted();
|
void updateStarted();
|
||||||
void updateFinished();
|
void updateFinished();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user