- Get rid of methods which are not used anymore due to moving to KDirModel.
- Respect GeneralSettings::globalViewProps() setting when storing view properties.
svn path=/trunk/playground/utils/dolphin/; revision=615255
void DolphinMainWindow::togglePreview()
{
+ clearStatusBar();
+
+ const KToggleAction* showPreviewAction =
+ static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
+ const bool show = showPreviewAction->isChecked();
+ m_activeView->setShowPreview(show);
}
void DolphinMainWindow::toggleShowHiddenFiles()
return m_mode;
}
+void DolphinView::setShowPreview(bool show)
+{
+ ViewProperties props(m_urlNavigator->url());
+ props.setShowPreview(show);
+
+ // TODO: wait until previews are possible with KFileItemDelegate
+
+ emit showPreviewChanged();
+}
+
+bool DolphinView::showPreview() const
+{
+ // TODO: wait until previews are possible with KFileItemDelegate
+ return true;
+}
+
void DolphinView::setShowHiddenFiles(bool show)
{
if (m_dirLister->showingDotFiles() == show) {
return m_dirLister->showingDotFiles();
}
-void DolphinView::setViewProperties(const ViewProperties& props)
-{
- setMode(props.viewMode());
- setSorting(props.sorting());
- setSortOrder(props.sortOrder());
- setShowHiddenFiles(props.showHiddenFiles());
-}
-
void DolphinView::renameSelectedItems()
{
const KUrl::List urls = selectedUrls();
void DolphinView::loadDirectory(const KUrl& url)
{
const ViewProperties props(url);
- setMode(props.viewMode());
+
+ const Mode mode = props.viewMode();
+ if (m_mode != mode) {
+ m_mode = mode;
+ applyModeToView();
+ emit modeChanged();
+ }
const bool showHiddenFiles = props.showHiddenFiles();
- setShowHiddenFiles(showHiddenFiles);
- m_dirLister->setShowingDotFiles(showHiddenFiles);
+ if (showHiddenFiles != m_dirLister->showingDotFiles()) {
+ m_dirLister->setShowingDotFiles(showHiddenFiles);
+ emit showHiddenFilesChanged();
+ }
- setSorting(props.sorting());
- setSortOrder(props.sortOrder());
+ const DolphinView::Sorting sorting = props.sorting();
+ if (sorting != m_proxyModel->sorting()) {
+ m_proxyModel->setSorting(sorting);
+ emit sortingChanged(sorting);
+ }
+
+ const Qt::SortOrder sortOrder = props.sortOrder();
+ if (sortOrder != m_proxyModel->sortOrder()) {
+ m_proxyModel->setSortOrder(sortOrder);
+ emit sortOrderChanged(sortOrder);
+ }
+
+ // TODO: handle previews (props.showPreview())
startDirLister(url);
emit urlChanged(url);
}
-void DolphinView::triggerIconsViewItem(Q3IconViewItem* item)
-{
- /* KDE4-TODO:
- const Qt::ButtonState keyboardState = KApplication::keyboardMouseState();
- const bool isSelectionActive = ((keyboardState & Qt::ShiftModifier) > 0) ||
- ((keyboardState & Qt::ControlModifier) > 0);*/
- const bool isSelectionActive = false;
- if ((item != 0) && !isSelectionActive) {
- // Updating the Url must be done outside the scope of this slot,
- // as iconview items will get deleted.
- QTimer::singleShot(0, this, SLOT(updateUrl()));
- mainWindow()->setActiveView(this);
- }
-}
-
void DolphinView::triggerItem(const QModelIndex& index)
{
KFileItem* item = m_dirModel->itemForIndex(index);
}
}
-void DolphinView::updateUrl()
-{
- //KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
- // static_cast<KFileView*>(m_iconsView);
-
- KFileItem* fileItem = 0; // TODO: fileView->currentFileItem();
- if (fileItem == 0) {
- return;
- }
-
- if (fileItem->isDir()) {
- // Prefer the local path over the Url. This assures that the
- // volume space information is correct. Assuming that the Url is media:/sda1,
- // and the local path is /windows/C: For the Url the space info is related
- // to the root partition (and hence wrong) and for the local path the space
- // info is related to the windows partition (-> correct).
- const QString localPath(fileItem->localPath());
- if (localPath.isEmpty()) {
- setUrl(fileItem->url());
- }
- else {
- setUrl(KUrl(localPath));
- }
- }
- else {
- fileItem->run();
- }
-}
-
void DolphinView::slotPercent(int percent)
{
if (m_showProgress) {
void requestActivation();
bool isActive() const;
+ /**
+ * Changes the view mode for the current directory to \a mode.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * changed view mode will be be stored automatically.
+ */
void setMode(Mode mode);
Mode mode() const;
+
+ /**
+ * Turns on the file preview for the all files of the current directory,
+ * if \a show is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * preview setting will be be stored automatically.
+ */
+ void setShowPreview(bool show);
+ bool showPreview() const;
+
+ /**
+ * Shows all hidden files of the current directory,
+ * if \a show is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * show hidden file setting will be be stored automatically.
+ */
void setShowHiddenFiles(bool show);
bool showHiddenFiles() const;
- void setViewProperties(const ViewProperties& props);
-
/**
* Triggers the renaming of the currently selected items, where
* the user must input a new name for the items.
*/
void modeChanged();
+ /** Is emitted if the 'show preview' property has been changed. */
+ void showPreviewChanged();
+
/** Is emitted if the 'show hidden files' property has been changed. */
void showHiddenFilesChanged();
private slots:
void loadDirectory(const KUrl& kurl);
- void triggerIconsViewItem(Q3IconViewItem *item);
void triggerItem(const QModelIndex& index);
- void updateUrl();
void slotPercent(int percent);
void slotClear();
#include <assert.h>
-#include <qdatetime.h>
-#include <qdir.h>
-#include <qfile.h>
+#include <QDateTime>
+#include <QFile>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kinstance.h>
#include "viewproperties.h"
-
#include "dolphinsettings.h"
+#include "generalsettings.h"
#define FILE_NAME "/.directory"
void ViewProperties::save()
{
- KStandardDirs::makeDir(m_filepath);
- m_node->writeConfig();
- m_changedProps = false;
+ const bool rememberSettings = !DolphinSettings::instance().generalSettings()->globalViewProps();
+ if (rememberSettings) {
+ KStandardDirs::makeDir(m_filepath);
+ m_node->writeConfig();
+ m_changedProps = false;
+ }
}
ViewProperties::ViewProperties(const ViewProperties& props)
void setSortOrder(Qt::SortOrder sortOrder);
Qt::SortOrder sortOrder() const;
+ /**
+ * If \a autoSave is true, the properties are automatically
+ * saved when the destructor is called. Per default autosaving
+ * is enabled.
+ */
void setAutoSaveEnabled(bool autoSave);
bool isAutoSaveEnabled() const;
void updateTimeStamp();
+
+ /**
+ * Saves the view properties for the directory specified
+ * in the constructor. The method is automatically
+ * invoked in the destructor, if
+ * ViewProperties::isAutoSaveEnabled() returns true.
+ *
+ * Note that the saving of the properties will be ignored
+ * if GeneralSettings::globalViewProps() returns true: in
+ * this case view properties may not be remembered for
+ * each directory.
+ */
void save();
private:
#include "viewpropertiesdialog.h"
#include "viewpropsprogressinfo.h"
+#include "dolphinview.h"
+#include "dolphinsettings.h"
+#include "generalsettings.h"
+#include "viewproperties.h"
#include <klocale.h>
#include <kiconloader.h>
#include <QRadioButton>
#include <QVBoxLayout>
-#include "viewproperties.h"
-#include "dolphinview.h"
-
ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
KDialog(dolphinView),
m_isDirty(false),
propsBoxLayout->addWidget(m_showPreview, 3, 0);
propsBoxLayout->addWidget(m_showHiddenFiles, 4, 0);
- m_applyToSubFolders = new QCheckBox(i18n("Apply changes to all sub folders"), main);
- m_useAsDefault = new QCheckBox(i18n("Use as default"), main);
-
topLayout->addWidget(propsBox);
- topLayout->addWidget(m_applyToSubFolders);
- topLayout->addWidget(m_useAsDefault);
connect(m_viewMode, SIGNAL(activated(int)),
this, SLOT(slotViewModeChanged(int)));
connect(m_showHiddenFiles, SIGNAL(clicked()),
this, SLOT(slotShowHiddenFilesChanged()));
- connect(m_applyToSubFolders, SIGNAL(clicked()),
- this, SLOT(markAsDirty()));
- connect(m_applyToSubFolders, SIGNAL(clicked()),
- this, SLOT(markAsDirty()));
-
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
+ // Only show the following settings if the view properties are remembered
+ // for each directory:
+ if (!DolphinSettings::instance().generalSettings()->globalViewProps()) {
+ m_applyToSubFolders = new QCheckBox(i18n("Apply changes to all sub folders"), main);
+ m_useAsDefault = new QCheckBox(i18n("Use as default"), main);
+ topLayout->addWidget(m_applyToSubFolders);
+ topLayout->addWidget(m_useAsDefault);
+
+ connect(m_applyToSubFolders, SIGNAL(clicked()),
+ this, SLOT(markAsDirty()));
+ connect(m_useAsDefault, SIGNAL(clicked()),
+ this, SLOT(markAsDirty()));
+ }
+
main->setLayout(topLayout);
setMainWidget(main);
}
void ViewPropertiesDialog::applyViewProperties()
{
- if (m_applyToSubFolders->isChecked() && m_isDirty) {
+ const bool applyToSubFolders = m_isDirty &&
+ (m_applyToSubFolders != 0) &&
+ m_applyToSubFolders->isChecked();
+ if (applyToSubFolders) {
const QString text(i18n("The view properties of all sub folders will be changed. Do you want to continue?"));
if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
return;
}
m_viewProps->save();
- m_dolphinView->setViewProperties(*m_viewProps);
+
+ m_dolphinView->setMode(m_viewProps->viewMode());
+ m_dolphinView->setSorting(m_viewProps->sorting());
+ m_dolphinView->setSortOrder(m_viewProps->sortOrder());
+ m_dolphinView->setShowPreview(m_viewProps->showPreview());
+ m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles());
+
m_isDirty = false;
// TODO: handle m_useAsDefault setting