#include "dolphinmodel.h"
#include "dolphincontroller.h"
#include "dolphinfileitemdelegate.h"
-#include "dolphinsettings.h"
+#include "settings/dolphinsettings.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinviewautoscroller.h"
#include "draganddrophelper.h"
m_controller(controller),
m_selectionManager(0),
m_autoScroller(0),
+ m_expandableFoldersAction(0),
m_font(),
m_decorationSize(),
m_band()
this, SLOT(synchronizeSortingState(int)));
headerView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
- this, SLOT(configureColumns(const QPoint&)));
+ this, SLOT(configureSettings(const QPoint&)));
connect(headerView, SIGNAL(sectionResized(int, int, int)),
this, SLOT(slotHeaderSectionResized(int, int, int)));
connect(headerView, SIGNAL(sectionHandleDoubleClicked(int)),
setFocus();
viewport()->installEventFilter(this);
- connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
- this, SLOT(updateFont()));
+ connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
+ this, SLOT(slotGlobalSettingsChanged(int)));
m_useDefaultIndexAt = false;
+
+ m_expandableFoldersAction = new QAction(i18nc("@option:check", "Expandable Folders"), this);
+ m_expandableFoldersAction->setCheckable(true);
+ connect(m_expandableFoldersAction, SIGNAL(toggled(bool)),
+ this, SLOT(setFoldersExpandable(bool)));
}
DolphinDetailsView::~DolphinDetailsView()
void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
{
QTreeView::contextMenuEvent(event);
- m_controller->triggerContextMenuRequest(event->pos());
+
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ m_expandableFoldersAction->setChecked(settings->expandableFolders());
+ m_controller->triggerContextMenuRequest(event->pos(),
+ QList<QAction*>() << m_expandableFoldersAction);
}
void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
updateDecorationSize(view->showPreview());
}
-void DolphinDetailsView::configureColumns(const QPoint& pos)
+void DolphinDetailsView::configureSettings(const QPoint& pos)
{
KMenu popup(this);
popup.addTitle(i18nc("@title:menu", "Columns"));
+ // add checkbox items for each column
QHeaderView* headerView = header();
for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
const int logicalIndex = headerView->logicalIndex(i);
action->setChecked(!headerView->isSectionHidden(logicalIndex));
action->setData(i);
}
+ popup.addSeparator();
QAction* activatedAction = popup.exec(header()->mapToGlobal(pos));
if (activatedAction != 0) {
m_controller->requestActivation();
}
-void DolphinDetailsView::updateFont()
+void DolphinDetailsView::slotGlobalSettingsChanged(int category)
{
+ Q_UNUSED(category);
+
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
Q_ASSERT(settings != 0);
-
if (settings->useSystemFont()) {
m_font = KGlobalSettings::generalFont();
}
+ //Disconnect then reconnect, since the settings have been changed, the connection requirements may have also.
+ disconnect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ if (KGlobalSettings::singleClick()) {
+ connect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ } else {
+ connect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ }
}
void DolphinDetailsView::updateElasticBandSelection()
m_band.ignoreOldInfo = false;
}
+void DolphinDetailsView::setFoldersExpandable(bool expandable)
+{
+ if (!expandable) {
+ // collapse all expanded folders, as QTreeView::setItemsExpandable(false)
+ // does not do this task
+ const int rowCount = model()->rowCount();
+ for (int row = 0; row < rowCount; ++row) {
+ setExpanded(model()->index(row, 0), false);
+ }
+ }
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ settings->setExpandableFolders(expandable);
+ setRootIsDecorated(expandable);
+ setItemsExpandable(expandable);
+}
+
void DolphinDetailsView::updateDecorationSize(bool showPreview)
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
// reasons the exact necessary width for full visible names is
// only checked for up to 200 items:
const int rowCount = model()->rowCount();
- if (rowCount < 200) {
+ if (rowCount > 0 && rowCount < 200) {
const int nameWidth = sizeHintForColumn(DolphinModel::Name);
if (nameWidth + requiredWidth <= viewport()->width()) {
columnWidth[KDirModel::Name] = viewport()->width() - requiredWidth;