mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
When switching from e. g. the icons view to the details view, additional information properties like 'Size' and 'Date' are added as default (showing a details-view without details does not make sense as default setting...). This fix assures that the additional information properties are removed again when switching back to the icons view. Only if the user modified the additional information properties by a GUI-interaction (e. g. by adding a 'Type'), this information is persistet also when switching back to the icon-view.
BUG: 151891 svn path=/trunk/KDE/kdebase/apps/; revision=733313
This commit is contained in:
parent
96f134eecc
commit
f1d1a18a71
4 changed files with 76 additions and 32 deletions
|
@ -43,6 +43,7 @@
|
|||
DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) :
|
||||
QTreeView(parent),
|
||||
m_controller(controller),
|
||||
m_clearAdditionalInfo(false),
|
||||
m_dragging(false),
|
||||
m_showElasticBand(false),
|
||||
m_elasticBandOrigin(),
|
||||
|
@ -349,6 +350,20 @@ void DolphinDetailsView::resizeEvent(QResizeEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
void DolphinDetailsView::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (m_clearAdditionalInfo) {
|
||||
disconnect(m_controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
|
||||
this, SLOT(updateColumnVisibility()));
|
||||
|
||||
KFileItemDelegate::InformationList info;
|
||||
info.append(KFileItemDelegate::NoInformation);
|
||||
m_controller->indicateAdditionalInfoChange(info);
|
||||
m_clearAdditionalInfo = true;
|
||||
}
|
||||
QTreeView::closeEvent(event);
|
||||
}
|
||||
|
||||
void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
|
||||
{
|
||||
QHeaderView* headerView = header();
|
||||
|
@ -457,17 +472,7 @@ void DolphinDetailsView::configureColumns(const QPoint& pos)
|
|||
const int columnIndex = activatedAction->data().toInt();
|
||||
|
||||
KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
|
||||
KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
|
||||
switch (columnIndex) {
|
||||
case DolphinModel::Size: info = KFileItemDelegate::Size; break;
|
||||
case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
|
||||
case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
|
||||
case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
|
||||
case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
|
||||
case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
const KFileItemDelegate::Information info = infoForColumn(columnIndex);
|
||||
if (show) {
|
||||
Q_ASSERT(!list.contains(info));
|
||||
list.append(info);
|
||||
|
@ -485,7 +490,10 @@ void DolphinDetailsView::configureColumns(const QPoint& pos)
|
|||
void DolphinDetailsView::updateColumnVisibility()
|
||||
{
|
||||
KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
|
||||
if (list.isEmpty() || list.contains(KFileItemDelegate::NoInformation)) {
|
||||
const bool useDefaultColumns = !isVisible() &&
|
||||
(list.isEmpty() ||
|
||||
list.contains(KFileItemDelegate::NoInformation));
|
||||
if (useDefaultColumns) {
|
||||
// Using the details view without any additional information (-> additional column)
|
||||
// makes no sense and leads to a usability problem as no viewport area is available
|
||||
// anymore. Hence as fallback provide at least a size and date column.
|
||||
|
@ -493,14 +501,17 @@ void DolphinDetailsView::updateColumnVisibility()
|
|||
list.append(KFileItemDelegate::Size);
|
||||
list.append(KFileItemDelegate::ModificationTime);
|
||||
m_controller->indicateAdditionalInfoChange(list);
|
||||
m_clearAdditionalInfo = true;
|
||||
}
|
||||
|
||||
setColumnHidden(DolphinModel::Size, !list.contains(KFileItemDelegate::Size));
|
||||
setColumnHidden(DolphinModel::ModifiedTime, !list.contains(KFileItemDelegate::ModificationTime));
|
||||
setColumnHidden(DolphinModel::Permissions, !list.contains(KFileItemDelegate::Permissions));
|
||||
setColumnHidden(DolphinModel::Owner, !list.contains(KFileItemDelegate::Owner));
|
||||
setColumnHidden(DolphinModel::Group, !list.contains(KFileItemDelegate::OwnerAndGroup));
|
||||
setColumnHidden(DolphinModel::Type, !list.contains(KFileItemDelegate::FriendlyMimeType));
|
||||
for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
|
||||
const KFileItemDelegate::Information info = infoForColumn(i);
|
||||
const bool hide = !list.contains(info);
|
||||
if (isColumnHidden(i) != hide) {
|
||||
setColumnHidden(i, hide);
|
||||
m_clearAdditionalInfo = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DolphinDetailsView::isZoomInPossible() const
|
||||
|
@ -553,4 +564,21 @@ KFileItem DolphinDetailsView::itemForIndex(const QModelIndex& index) const
|
|||
return dirModel->itemForIndex(dirIndex);
|
||||
}
|
||||
|
||||
KFileItemDelegate::Information DolphinDetailsView::infoForColumn(int columnIndex) const
|
||||
{
|
||||
KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
|
||||
|
||||
switch (columnIndex) {
|
||||
case DolphinModel::Size: info = KFileItemDelegate::Size; break;
|
||||
case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
|
||||
case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
|
||||
case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
|
||||
case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
|
||||
case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
#include "dolphindetailsview.moc"
|
||||
|
|
|
@ -58,6 +58,7 @@ protected:
|
|||
virtual void paintEvent(QPaintEvent* event);
|
||||
virtual void keyPressEvent(QKeyEvent* event);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
|
||||
private slots:
|
||||
/**
|
||||
|
@ -135,10 +136,14 @@ private:
|
|||
|
||||
KFileItem itemForIndex(const QModelIndex& index) const;
|
||||
|
||||
KFileItemDelegate::Information infoForColumn(int columnIndex) const;
|
||||
|
||||
private:
|
||||
DolphinController* m_controller;
|
||||
QStyleOptionViewItem m_viewOptions;
|
||||
|
||||
bool m_clearAdditionalInfo;
|
||||
|
||||
bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
|
||||
QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
|
||||
|
||||
|
|
|
@ -194,6 +194,11 @@ void DolphinView::setMode(Mode mode)
|
|||
m_controller->setUrl(root);
|
||||
}
|
||||
|
||||
deleteView();
|
||||
|
||||
// It is important to read the view properties _after_ deleting the view,
|
||||
// as e. g. the detail view might adjust the additional information properties
|
||||
// after getting closed:
|
||||
const KUrl viewPropsUrl = viewPropertiesUrl();
|
||||
ViewProperties props(viewPropsUrl);
|
||||
props.setViewMode(m_mode);
|
||||
|
@ -770,6 +775,7 @@ void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList&
|
|||
{
|
||||
ViewProperties props(viewPropertiesUrl());
|
||||
props.setAdditionalInfo(info);
|
||||
props.save();
|
||||
|
||||
m_fileItemDelegate->setShowInformation(info);
|
||||
|
||||
|
@ -826,24 +832,12 @@ void DolphinView::clearHoverInformation()
|
|||
|
||||
void DolphinView::createView()
|
||||
{
|
||||
// delete current view
|
||||
QAbstractItemView* view = itemView();
|
||||
if (view != 0) {
|
||||
m_topLayout->removeWidget(view);
|
||||
view->close();
|
||||
view->deleteLater();
|
||||
view = 0;
|
||||
m_iconsView = 0;
|
||||
m_detailsView = 0;
|
||||
m_columnView = 0;
|
||||
m_fileItemDelegate = 0;
|
||||
}
|
||||
|
||||
deleteView();
|
||||
Q_ASSERT(m_iconsView == 0);
|
||||
Q_ASSERT(m_detailsView == 0);
|
||||
Q_ASSERT(m_columnView == 0);
|
||||
|
||||
// ... and recreate it representing the current mode
|
||||
QAbstractItemView* view = 0;
|
||||
switch (m_mode) {
|
||||
case IconsView: {
|
||||
m_iconsView = new DolphinIconsView(this, m_controller);
|
||||
|
@ -881,6 +875,21 @@ void DolphinView::createView()
|
|||
this, SLOT(emitContentsMoved()));
|
||||
}
|
||||
|
||||
void DolphinView::deleteView()
|
||||
{
|
||||
QAbstractItemView* view = itemView();
|
||||
if (view != 0) {
|
||||
m_topLayout->removeWidget(view);
|
||||
view->close();
|
||||
view->deleteLater();
|
||||
view = 0;
|
||||
m_iconsView = 0;
|
||||
m_detailsView = 0;
|
||||
m_columnView = 0;
|
||||
m_fileItemDelegate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractItemView* DolphinView::itemView() const
|
||||
{
|
||||
if (m_detailsView != 0) {
|
||||
|
|
|
@ -566,6 +566,8 @@ private:
|
|||
*/
|
||||
void createView();
|
||||
|
||||
void deleteView();
|
||||
|
||||
/**
|
||||
* Returns a pointer to the currently used item view, which is either
|
||||
* a ListView or a TreeView.
|
||||
|
|
Loading…
Reference in a new issue