summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/pwmviewstyle.cpp
Side-by-side diff
Diffstat (limited to 'pwmanager/pwmanager/pwmviewstyle.cpp') (more/less context) (ignore 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 @@
#include "pwmviewstyle.h"
#include "pwmexception.h"
#include "pwmviewstyle_0.h"
#include "pwmviewstyle_1.h"
#include "listviewpwm.h"
#include "pwmview.h"
#include "commentbox.h"
#ifndef PWM_EMBEDDED
#include "configuration.h"
#else
#include "pwmprefs.h"
#endif
PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name)
: QWidget(parent, name)
{
curStyle = style_notset;
s0 = 0;
s1 = 0;
}
PwMViewStyle::~PwMViewStyle()
{
- //US ENH : load and store the size of the listviewcolumns
- lv->saveLayout(conf()->getConfig(), "listview");
- conf()->getConfig()->sync();
+ //US ENH : store the size of the listviewcolumns
+ switch (curStyle)
+ {
+ case style_0:
+ s0->saveSettings(PWMPrefs::instance());
+ break;
+ case style_1:
+ s1->saveSettings(PWMPrefs::instance());
+ break;
+ default:
+ BUG();
+ }
+
+
+ PWMPrefs::instance()->getConfig()->sync();
delete_ifnot_null(s0);
delete_ifnot_null(s1);
}
void PwMViewStyle::initStyle(style_t style)
{
printDebug(string("initializing style ") + tostr(style));
bool wasMaximized = v->isMaximized();
if (v->isVisible())
v->hide();
switch (style) {
case style_0:
delete_ifnot_null(s0);
delete_ifnot_null(s1);
s0 = new PwMViewStyle_0(v);
lv = s0->getLv();
commentBox = s0->getCommentBox();
break;
case style_1:
delete_ifnot_null(s0);
delete_ifnot_null(s1);
s1 = new PwMViewStyle_1(v);
lv = s1->getLv();
commentBox = s1->getCommentBox();
break;
default:
BUG();
return;
}
curStyle = style;
connect(lv, SIGNAL(pressed(QListViewItem *)),
v, SLOT(handleToggle(QListViewItem *)));
connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)),
v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int)));
connect(lv, SIGNAL(clicked(QListViewItem *)),
v, SLOT(refreshCommentTextEdit(QListViewItem *)));
lv->addColumn(i18n("Description"), 180);
lv->addColumn(i18n("Username"), 150);
lv->addColumn(i18n("Password"), 150);
lv->addColumn(i18n("URL"), 180);
lv->addColumn(i18n("Launcher"), 120);
v->tmpReEnableSort();
- //US ENH : load and store the size of the listviewcolumns
- lv->restoreLayout(conf()->getConfig(), "listview");
+ //US ENH : load the size of the listviewcolumns
+ switch (style)
+ {
+ case style_0:
+ s0->restoreSettings(PWMPrefs::instance());
+ break;
+ case style_1:
+ s1->restoreSettings(PWMPrefs::instance());
+ break;
+ default:
+ BUG();
+ }
resizeView(v->size());
v->updateView();
if (wasMaximized) {
v->showMaximized();
} else {
v->show();
}
connect(lv, SIGNAL(layoutChanged()),
v, SLOT(reorgLp()));
}
void PwMViewStyle::resizeView(const QSize &size)
{
switch (curStyle) {
case style_0:
PWM_ASSERT(s0);
s0->resize(size);
return;
case style_1:
PWM_ASSERT(s1);
s1->resize(size);
return;
default: