summaryrefslogtreecommitdiffstats
path: root/fileview.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-04-05 17:01:57 +0200
committerArno <am@disconnect.de>2013-04-05 17:01:57 +0200
commit0f4f0d5860e4a261f37ae6f294c154c3009c4562 (patch)
tree3cce6fb18017c6f01190af9e83c70ad0fc65db1a /fileview.cpp
parent1bcbb69e31090cf71e913419299b52dd4d094bef (diff)
downloadSheMov-0f4f0d5860e4a261f37ae6f294c154c3009c4562.tar.gz
SheMov-0f4f0d5860e4a261f37ae6f294c154c3009c4562.tar.bz2
SheMov-0f4f0d5860e4a261f37ae6f294c154c3009c4562.zip
Make FilesystemWidget headers configurable
Save headerView on exit, create a Menu for selecting headers and read headerConfig on startup.
Diffstat (limited to 'fileview.cpp')
-rw-r--r--fileview.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/fileview.cpp b/fileview.cpp
index 7797d73..489338b 100644
--- a/fileview.cpp
+++ b/fileview.cpp
@@ -26,6 +26,7 @@
#include <QtWidgets/QInputDialog>
#include <QPalette>
#include <QTimer>
+#include <QHeaderView>
#include "fileview.h"
#include "hoverwindow.h"
@@ -41,7 +42,6 @@ FileView::FileView(QWidget *parent) : QTreeView(parent), mDeleteA(0) {
mHoverWin = new HoverWindow(this);
QSize curSize = SmGlobals::instance()->cursorSize();
mHoverWin->setHoverOffset(QPoint(curSize.width() + 30, 0));
- readConfig();
SmGlobals::instance()->treeWidgets().append(this);
}
@@ -109,6 +109,11 @@ void FileView::readConfig(){
mWhen = s.value("ui/grabframe", "00:00:00").toString();
mHoverWin->setWindowOpacity(s.value("ui/hoveropacity", 10).toFloat() / 10.0);
mCursorOffset = s.value("ui/cursoroffset").toInt();
+ readHeaderConfig();
+}
+
+void FileView::writeConfig(){
+ writeHeaderConfig();
}
void FileView::resizeColumns(int columns) {
@@ -259,6 +264,38 @@ void FileView::restoreSelection(){
}
}
+void FileView::readHeaderConfig(){
+ QSettings s;
+ QByteArray headerPos = s.value("ui/fsheaderpos").toByteArray();
+ if(!headerPos.isEmpty()){
+ header()->restoreState(headerPos);
+ }
+ QHeaderView *hv = header();
+ QHash<int, QAction*> headerActions;
+ foreach(QAction *a, mHeaderGroup->actions()){
+ headerActions.insert(a->data().toInt(), a);
+ }
+ for(int i = 0; i < hv->count(); ++i){
+ if(!hv->isSectionHidden(i)){
+ headerActions.value(i)->setChecked(true);
+ }
+ }
+}
+
+void FileView::writeHeaderConfig(){
+ QSettings s;
+ s.setValue("ui/fsheaderpos", header()->saveState());
+}
+
+
+void FileView::toggleHeader(QObject *action){
+ QAction *a = qobject_cast<QAction*>(action);
+ Q_ASSERT(a);
+ int logicalIndex = a->data().toInt();
+ QHeaderView *hv = header();
+ hv->setSectionHidden(logicalIndex, !a->isChecked());
+}
+
bool FileView::exitHover(bool exitVal){
mHoverWin->setVisible(false);
mCurHover = QModelIndex();