Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kdiroperatordetailview.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 55 | if (model->rowCount() == 0) { | |||
---|---|---|---|---|---|
58 | QAbstractProxyModel *proxyModel = static_cast<QAbstractProxyModel *>(model); | 58 | QAbstractProxyModel *proxyModel = static_cast<QAbstractProxyModel *>(model); | ||
59 | KDirModel *dirModel = static_cast<KDirModel *>(proxyModel->sourceModel()); | 59 | KDirModel *dirModel = static_cast<KDirModel *>(proxyModel->sourceModel()); | ||
60 | connect(dirModel->dirLister(), SIGNAL(completed()), | 60 | connect(dirModel->dirLister(), SIGNAL(completed()), | ||
61 | this, SLOT(resetResizing())); | 61 | this, SLOT(resetResizing())); | ||
62 | } else { | 62 | } else { | ||
63 | resetResizing(); | 63 | resetResizing(); | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | connect(model, SIGNAL(layoutChanged()), this, SLOT(expandNameColumn())); | | |||
67 | | ||||
68 | QTreeView::setModel(model); | 66 | QTreeView::setModel(model); | ||
69 | } | 67 | } | ||
70 | 68 | | |||
71 | bool KDirOperatorDetailView::setViewMode(KFile::FileView viewMode) | 69 | bool KDirOperatorDetailView::setViewMode(KFile::FileView viewMode) | ||
72 | { | 70 | { | ||
73 | bool tree = false; | 71 | bool tree = false; | ||
74 | 72 | | |||
75 | if (KFile::isDetailView(viewMode)) { | 73 | if (KFile::isDetailView(viewMode)) { | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | |||||
150 | 148 | | |||
151 | void KDirOperatorDetailView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | 149 | void KDirOperatorDetailView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | ||
152 | { | 150 | { | ||
153 | QTreeView::currentChanged(current, previous); | 151 | QTreeView::currentChanged(current, previous); | ||
154 | } | 152 | } | ||
155 | 153 | | |||
156 | void KDirOperatorDetailView::resetResizing() | 154 | void KDirOperatorDetailView::resetResizing() | ||
157 | { | 155 | { | ||
158 | QTimer::singleShot(300, this, SLOT(disableColumnResizing())); | 156 | connect(model(), &QAbstractItemModel::layoutChanged, this, &KDirOperatorDetailView::expandNameColumn, | ||
dfaure: Is there any risk that this connect is done multiple times? | |||||
To be honest, I don't know. I'll add Qt::UniqueConnection just to be safe mkoller: To be honest, I don't know. I'll add Qt::UniqueConnection just to be safe | |||||
159 | } | 157 | Qt::UniqueConnection); | ||
160 | 158 | | |||
161 | void KDirOperatorDetailView::disableColumnResizing() | 159 | expandNameColumn(); | ||
162 | { | | |||
163 | m_resizeColumns = false; | 160 | m_resizeColumns = false; | ||
164 | } | 161 | } | ||
165 | 162 | | |||
166 | void KDirOperatorDetailView::expandNameColumn() | 163 | void KDirOperatorDetailView::expandNameColumn() | ||
167 | { | 164 | { | ||
168 | if (m_resizeColumns) { | 165 | if (m_resizeColumns) { | ||
169 | QHeaderView *headerView = header(); | 166 | QHeaderView *headerView = header(); | ||
170 | headerView->resizeSections(QHeaderView::ResizeToContents); | 167 | headerView->resizeSections(QHeaderView::ResizeToContents); | ||
Show All 14 Lines |
Is there any risk that this connect is done multiple times?