summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/pwmviewstyle.cpp
Unidiff
Diffstat (limited to 'pwmanager/pwmanager/pwmviewstyle.cpp') (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmviewstyle.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp
index 51d8f6c..9704615 100644
--- a/pwmanager/pwmanager/pwmviewstyle.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle.cpp
@@ -20,97 +20,119 @@
20 20
21#include "pwmviewstyle.h" 21#include "pwmviewstyle.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23#include "pwmviewstyle_0.h" 23#include "pwmviewstyle_0.h"
24#include "pwmviewstyle_1.h" 24#include "pwmviewstyle_1.h"
25#include "listviewpwm.h" 25#include "listviewpwm.h"
26#include "pwmview.h" 26#include "pwmview.h"
27#include "commentbox.h" 27#include "commentbox.h"
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include "configuration.h" 29#include "configuration.h"
30#else 30#else
31#include "pwmprefs.h" 31#include "pwmprefs.h"
32#endif 32#endif
33 33
34PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) 34PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name)
35 : QWidget(parent, name) 35 : QWidget(parent, name)
36{ 36{
37 curStyle = style_notset; 37 curStyle = style_notset;
38 s0 = 0; 38 s0 = 0;
39 s1 = 0; 39 s1 = 0;
40} 40}
41 41
42PwMViewStyle::~PwMViewStyle() 42PwMViewStyle::~PwMViewStyle()
43{ 43{
44 //US ENH : load and store the size of the listviewcolumns 44 //US ENH : store the size of the listviewcolumns
45 lv->saveLayout(conf()->getConfig(), "listview"); 45 switch (curStyle)
46 conf()->getConfig()->sync(); 46 {
47 case style_0:
48 s0->saveSettings(PWMPrefs::instance());
49 break;
50 case style_1:
51 s1->saveSettings(PWMPrefs::instance());
52 break;
53 default:
54 BUG();
55 }
56
57
58 PWMPrefs::instance()->getConfig()->sync();
47 59
48 delete_ifnot_null(s0); 60 delete_ifnot_null(s0);
49 delete_ifnot_null(s1); 61 delete_ifnot_null(s1);
50} 62}
51 63
52void PwMViewStyle::initStyle(style_t style) 64void PwMViewStyle::initStyle(style_t style)
53{ 65{
54 printDebug(string("initializing style ") + tostr(style)); 66 printDebug(string("initializing style ") + tostr(style));
55 bool wasMaximized = v->isMaximized(); 67 bool wasMaximized = v->isMaximized();
56 if (v->isVisible()) 68 if (v->isVisible())
57 v->hide(); 69 v->hide();
58 switch (style) { 70 switch (style) {
59 case style_0: 71 case style_0:
60 delete_ifnot_null(s0); 72 delete_ifnot_null(s0);
61 delete_ifnot_null(s1); 73 delete_ifnot_null(s1);
62 s0 = new PwMViewStyle_0(v); 74 s0 = new PwMViewStyle_0(v);
63 lv = s0->getLv(); 75 lv = s0->getLv();
64 commentBox = s0->getCommentBox(); 76 commentBox = s0->getCommentBox();
65 break; 77 break;
66 case style_1: 78 case style_1:
67 delete_ifnot_null(s0); 79 delete_ifnot_null(s0);
68 delete_ifnot_null(s1); 80 delete_ifnot_null(s1);
69 s1 = new PwMViewStyle_1(v); 81 s1 = new PwMViewStyle_1(v);
70 lv = s1->getLv(); 82 lv = s1->getLv();
71 commentBox = s1->getCommentBox(); 83 commentBox = s1->getCommentBox();
72 break; 84 break;
73 default: 85 default:
74 BUG(); 86 BUG();
75 return; 87 return;
76 } 88 }
77 curStyle = style; 89 curStyle = style;
78 connect(lv, SIGNAL(pressed(QListViewItem *)), 90 connect(lv, SIGNAL(pressed(QListViewItem *)),
79 v, SLOT(handleToggle(QListViewItem *))); 91 v, SLOT(handleToggle(QListViewItem *)));
80 connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)), 92 connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)),
81 v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int))); 93 v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int)));
82 connect(lv, SIGNAL(clicked(QListViewItem *)), 94 connect(lv, SIGNAL(clicked(QListViewItem *)),
83 v, SLOT(refreshCommentTextEdit(QListViewItem *))); 95 v, SLOT(refreshCommentTextEdit(QListViewItem *)));
84 lv->addColumn(i18n("Description"), 180); 96 lv->addColumn(i18n("Description"), 180);
85 lv->addColumn(i18n("Username"), 150); 97 lv->addColumn(i18n("Username"), 150);
86 lv->addColumn(i18n("Password"), 150); 98 lv->addColumn(i18n("Password"), 150);
87 lv->addColumn(i18n("URL"), 180); 99 lv->addColumn(i18n("URL"), 180);
88 lv->addColumn(i18n("Launcher"), 120); 100 lv->addColumn(i18n("Launcher"), 120);
89 v->tmpReEnableSort(); 101 v->tmpReEnableSort();
90 102
91 //US ENH : load and store the size of the listviewcolumns 103 //US ENH : load the size of the listviewcolumns
92 lv->restoreLayout(conf()->getConfig(), "listview"); 104 switch (style)
105 {
106 case style_0:
107 s0->restoreSettings(PWMPrefs::instance());
108 break;
109 case style_1:
110 s1->restoreSettings(PWMPrefs::instance());
111 break;
112 default:
113 BUG();
114 }
93 115
94 resizeView(v->size()); 116 resizeView(v->size());
95 v->updateView(); 117 v->updateView();
96 if (wasMaximized) { 118 if (wasMaximized) {
97 v->showMaximized(); 119 v->showMaximized();
98 } else { 120 } else {
99 v->show(); 121 v->show();
100 } 122 }
101 connect(lv, SIGNAL(layoutChanged()), 123 connect(lv, SIGNAL(layoutChanged()),
102 v, SLOT(reorgLp())); 124 v, SLOT(reorgLp()));
103} 125}
104 126
105void PwMViewStyle::resizeView(const QSize &size) 127void PwMViewStyle::resizeView(const QSize &size)
106{ 128{
107 switch (curStyle) { 129 switch (curStyle) {
108 case style_0: 130 case style_0:
109 PWM_ASSERT(s0); 131 PWM_ASSERT(s0);
110 s0->resize(size); 132 s0->resize(size);
111 return; 133 return;
112 case style_1: 134 case style_1:
113 PWM_ASSERT(s1); 135 PWM_ASSERT(s1);
114 s1->resize(size); 136 s1->resize(size);
115 return; 137 return;
116 default: 138 default: