Remember the additional-info property (size, date, type, ...) for each view mode (icons view, details view, column view) individually.

BUG: 154434
CCMAIL: hein@kde.org

svn path=/trunk/KDE/kdebase/apps/; revision=757791
This commit is contained in:
Peter Penz 2008-01-05 22:09:07 +00:00
parent 64b6e679d6
commit e3ed05b372
11 changed files with 86 additions and 71 deletions

View file

@ -26,10 +26,6 @@
<label context="@label">Bold</label> <label context="@label">Bold</label>
<default>false</default> <default>false</default>
</entry> </entry>
<entry name="ShowAdditionalInfo" type="Bool">
<label context="@label">Allow showing of additional information</label>
<default>true</default>
</entry>
<entry name="ItemHeight" type="Int"> <entry name="ItemHeight" type="Int">
<label context="@label">Item height</label> <label context="@label">Item height</label>
<!-- <!--

View file

@ -46,7 +46,6 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
m_controller(controller), m_controller(controller),
m_font(), m_font(),
m_decorationSize(), m_decorationSize(),
m_clearAdditionalInfo(false),
m_dragging(false), m_dragging(false),
m_showElasticBand(false), m_showElasticBand(false),
m_elasticBandOrigin(), m_elasticBandOrigin(),
@ -357,20 +356,6 @@ 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 = false;
}
QTreeView::closeEvent(event);
}
void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting) void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
{ {
QHeaderView* headerView = header(); QHeaderView* headerView = header();
@ -497,27 +482,12 @@ void DolphinDetailsView::configureColumns(const QPoint& pos)
void DolphinDetailsView::updateColumnVisibility() void DolphinDetailsView::updateColumnVisibility()
{ {
KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo(); const KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
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.
list.clear();
list.append(KFileItemDelegate::Size);
list.append(KFileItemDelegate::ModificationTime);
m_controller->indicateAdditionalInfoChange(list);
m_clearAdditionalInfo = true;
}
for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) { for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
const KFileItemDelegate::Information info = infoForColumn(i); const KFileItemDelegate::Information info = infoForColumn(i);
const bool hide = !list.contains(info); const bool hide = !list.contains(info);
if (isColumnHidden(i) != hide) { if (isColumnHidden(i) != hide) {
setColumnHidden(i, hide); setColumnHidden(i, hide);
m_clearAdditionalInfo = false;
} }
} }

View file

@ -58,7 +58,6 @@ protected:
virtual void paintEvent(QPaintEvent* event); virtual void paintEvent(QPaintEvent* event);
virtual void keyPressEvent(QKeyEvent* event); virtual void keyPressEvent(QKeyEvent* event);
virtual void resizeEvent(QResizeEvent* event); virtual void resizeEvent(QResizeEvent* event);
virtual void closeEvent(QCloseEvent* event);
private slots: private slots:
/** /**
@ -149,8 +148,6 @@ private:
QFont m_font; QFont m_font;
QSize m_decorationSize; QSize m_decorationSize;
bool m_clearAdditionalInfo;
bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4 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 QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4

View file

@ -303,11 +303,6 @@ void DolphinIconsView::slotShowPreviewChanged()
void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info) void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info)
{ {
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
if (!settings->showAdditionalInfo()) {
return;
}
const bool showPreview = m_controller->dolphinView()->showPreview(); const bool showPreview = m_controller->dolphinView()->showPreview();
updateGridSize(showPreview, info.count()); updateGridSize(showPreview, info.count());
} }
@ -468,8 +463,7 @@ KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const
int DolphinIconsView::additionalInfoCount() const int DolphinIconsView::additionalInfoCount() const
{ {
const DolphinView* view = m_controller->dolphinView(); const DolphinView* view = m_controller->dolphinView();
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); return view->additionalInfo().count();
return settings->showAdditionalInfo() ? view->additionalInfo().count() : 0;
} }
#include "dolphiniconsview.moc" #include "dolphiniconsview.moc"

View file

@ -273,9 +273,8 @@ void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::Information
const DolphinView* view = m_activeViewContainer->view(); const DolphinView* view = m_activeViewContainer->view();
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
const bool enable = (view->mode() == DolphinView::DetailsView) || const bool enable = (view->mode() == DolphinView::DetailsView) ||
((view->mode() == DolphinView::IconsView) && settings->showAdditionalInfo()); (view->mode() == DolphinView::IconsView);
showSizeInfo->setEnabled(enable); showSizeInfo->setEnabled(enable);
showDateInfo->setEnabled(enable); showDateInfo->setEnabled(enable);

View file

@ -206,9 +206,6 @@ void DolphinView::setMode(Mode mode)
deleteView(); 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(); const KUrl viewPropsUrl = viewPropertiesUrl();
ViewProperties props(viewPropsUrl); ViewProperties props(viewPropsUrl);
props.setViewMode(m_mode); props.setViewMode(m_mode);

View file

@ -50,7 +50,6 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
m_textWidthBox(0), m_textWidthBox(0),
m_fontRequester(0), m_fontRequester(0),
m_textlinesCountBox(0), m_textlinesCountBox(0),
m_showAdditionalInfo(0),
m_arrangementBox(0), m_arrangementBox(0),
m_gridSpacingBox(0) m_gridSpacingBox(0)
{ {
@ -84,12 +83,7 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium")); m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large")); m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
m_showAdditionalInfo = new QCheckBox(i18nc("@option:check", QGridLayout* textGroupLayout = new QGridLayout(textGroup);
"Allow showing of additional information"), textGroup);
QVBoxLayout* textVBoxLayout = new QVBoxLayout(textGroup);
QGridLayout* textGroupLayout = new QGridLayout();
textGroupLayout->addWidget(fontLabel, 0, 0); textGroupLayout->addWidget(fontLabel, 0, 0);
textGroupLayout->addWidget(m_fontRequester, 0, 1); textGroupLayout->addWidget(m_fontRequester, 0, 1);
textGroupLayout->addWidget(textlinesCountLabel, 1, 0); textGroupLayout->addWidget(textlinesCountLabel, 1, 0);
@ -97,9 +91,6 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
textGroupLayout->addWidget(textWidthLabel, 2, 0); textGroupLayout->addWidget(textWidthLabel, 2, 0);
textGroupLayout->addWidget(m_textWidthBox, 2, 1); textGroupLayout->addWidget(m_textWidthBox, 2, 1);
textVBoxLayout->addLayout(textGroupLayout);
textVBoxLayout->addWidget(m_showAdditionalInfo);
// create the 'Grid' group for selecting the arrangement and the grid spacing // create the 'Grid' group for selecting the arrangement and the grid spacing
QGroupBox* gridGroup = new QGroupBox(i18nc("@title:group", "Grid"), this); QGroupBox* gridGroup = new QGroupBox(i18nc("@title:group", "Grid"), this);
gridGroup->setSizePolicy(sizePolicy); gridGroup->setSizePolicy(sizePolicy);
@ -171,8 +162,6 @@ void IconsViewSettingsPage::applySettings()
settings->setNumberOfTextlines(numberOfTextlines); settings->setNumberOfTextlines(numberOfTextlines);
settings->setShowAdditionalInfo(m_showAdditionalInfo->isChecked());
settings->setGridSpacing(GridSpacingBase + settings->setGridSpacing(GridSpacingBase +
m_gridSpacingBox->currentIndex() * GridSpacingInc); m_gridSpacingBox->currentIndex() * GridSpacingInc);
} }
@ -208,8 +197,6 @@ void IconsViewSettingsPage::loadSettings()
m_textlinesCountBox->setValue(settings->numberOfTextlines()); m_textlinesCountBox->setValue(settings->numberOfTextlines());
m_showAdditionalInfo->setChecked(settings->showAdditionalInfo());
const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight); const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight);
int textWidthIndex = 0; int textWidthIndex = 0;
const int remainingWidth = settings->itemWidth() - settings->iconSize(); const int remainingWidth = settings->itemWidth() - settings->iconSize();

View file

@ -88,7 +88,6 @@ private:
QComboBox* m_textWidthBox; QComboBox* m_textWidthBox;
KFontRequester* m_fontRequester; KFontRequester* m_fontRequester;
QSpinBox* m_textlinesCountBox; QSpinBox* m_textlinesCountBox;
QCheckBox* m_showAdditionalInfo;
QComboBox* m_arrangementBox; QComboBox* m_arrangementBox;
QComboBox* m_gridSpacingBox; QComboBox* m_gridSpacingBox;

View file

@ -226,15 +226,16 @@ void ViewProperties::setAdditionalInfo(KFileItemDelegate::InformationList list)
} }
} }
if (m_node->additionalInfo() != info) { const int encodedInfo = encodedAdditionalInfo(info);
m_node->setAdditionalInfo(info); if (m_node->additionalInfo() != encodedInfo) {
m_node->setAdditionalInfo(encodedInfo);
updateTimeStamp(); updateTimeStamp();
} }
} }
KFileItemDelegate::InformationList ViewProperties::additionalInfo() const KFileItemDelegate::InformationList ViewProperties::additionalInfo() const
{ {
const int info = m_node->additionalInfo(); const int info = decodedAdditionalInfo();
KFileItemDelegate::InformationList list; KFileItemDelegate::InformationList list;
if (info & SizeInfo) { if (info & SizeInfo) {
@ -307,3 +308,48 @@ QString ViewProperties::destinationDir(const QString& subDir) const
basePath.append("/view_properties/").append(subDir); basePath.append("/view_properties/").append(subDir);
return KStandardDirs::locateLocal("data", basePath); return KStandardDirs::locateLocal("data", basePath);
} }
int ViewProperties::encodedAdditionalInfo(int info) const
{
int encodedInfo = m_node->additionalInfo();
switch (viewMode()) {
case DolphinView::DetailsView:
encodedInfo = (encodedInfo & 0xFFFF00) | info;
break;
case DolphinView::IconsView:
encodedInfo = (encodedInfo & 0xFF00FF) | (info << 8);
break;
case DolphinView::ColumnView:
encodedInfo = (encodedInfo & 0x00FFFF) | (info << 16);
break;
default: break;
}
return encodedInfo;
}
int ViewProperties::decodedAdditionalInfo() const
{
int decodedInfo = m_node->additionalInfo();
switch (viewMode()) {
case DolphinView::DetailsView:
decodedInfo = decodedInfo & 0xFF;
if (decodedInfo == NoInfo) {
// a details view without any additional info makes no sense, hence
// provide at least a size-info and date-info as fallback
decodedInfo = SizeInfo | DateInfo;
}
break;
case DolphinView::IconsView:
decodedInfo = (decodedInfo >> 8) & 0xFF;
break;
case DolphinView::ColumnView:
decodedInfo = (decodedInfo >> 16) & 0xFF;
break;
default: break;
}
return decodedInfo;
}

View file

@ -71,7 +71,18 @@ public:
void setSortOrder(Qt::SortOrder sortOrder); void setSortOrder(Qt::SortOrder sortOrder);
Qt::SortOrder sortOrder() const; Qt::SortOrder sortOrder() const;
/**
* Sets the additional information for the current set view-mode.
* Note that the additional-info property is the only property where
* the value is dependent from another property (in this case the view-mode).
*/
void setAdditionalInfo(KFileItemDelegate::InformationList info); void setAdditionalInfo(KFileItemDelegate::InformationList info);
/**
* Returns the additional information for the current set view-mode.
* Note that the additional-info property is the only property where
* the value is dependent from another property (in this case the view-mode).
*/
KFileItemDelegate::InformationList additionalInfo() const; KFileItemDelegate::InformationList additionalInfo() const;
/** /**
@ -117,6 +128,26 @@ private:
*/ */
QString destinationDir(const QString& subDir) const; QString destinationDir(const QString& subDir) const;
/**
* Returns the encoded additional information that can be stored
* in the .directory file. See ViewProperties::decodedAdditionalInfo()
* for the coding format.
* @param info Additional information for the current view mode.
*/
int encodedAdditionalInfo(int info) const;
/**
* Returns the decoded additional information from the .directory
* file by respecting the current set view mode. The additional
* information from the .directory file is an integer value, where:
* - Byte 0 stores the additional info for the details view
* - Byte 1 stores the additional info for the icons view
* - Byte 2 stores the additional info for the column view
* The additional information property is the only property that is
* dependent from another property (in this case the view-mode).
*/
int decodedAdditionalInfo() const;
Q_DISABLE_COPY(ViewProperties) Q_DISABLE_COPY(ViewProperties)
private: private:

View file

@ -381,9 +381,8 @@ void ViewPropertiesDialog::loadSettings()
m_sortOrder->setCurrentIndex(sortOrderIndex); m_sortOrder->setCurrentIndex(sortOrderIndex);
m_sorting->setCurrentIndex(m_viewProps->sorting()); m_sorting->setCurrentIndex(m_viewProps->sorting());
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
const bool enabled = (index == DolphinView::DetailsView) || const bool enabled = (index == DolphinView::DetailsView) ||
((index == DolphinView::IconsView) && settings->showAdditionalInfo()); (index == DolphinView::IconsView);
m_additionalInfo->setEnabled(enabled); m_additionalInfo->setEnabled(enabled);
// load show preview, show in groups and show hidden files settings // load show preview, show in groups and show hidden files settings