author | ulf69 <ulf69> | 2004-09-15 17:53:22 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-15 17:53:22 (UTC) |
commit | d3925ba5bd25224bc4a60d3d6a107c464994a1ea (patch) (side-by-side diff) | |
tree | 60f69da1d2b79ee3081e7ef5c09a46470ca6eda0 /pwmanager/pwmanager/pwmviewstyle.cpp | |
parent | ce83a3479d23b9e8a59c745ccd0a0b14f64ef4e8 (diff) | |
download | kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.zip kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.gz kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.bz2 |
initial revision
Diffstat (limited to 'pwmanager/pwmanager/pwmviewstyle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle.cpp | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp new file mode 100644 index 0000000..67b5197 --- a/dev/null +++ b/pwmanager/pwmanager/pwmviewstyle.cpp @@ -0,0 +1,205 @@ +/*************************************************************************** + * * + * copyright (C) 2004 by Michael Buesch * + * email: mbuesch@freenet.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License version 2 * + * as published by the Free Software Foundation. * + * * + ***************************************************************************/ + + +/*************************************************************************** + * copyright (C) 2004 by Ulf Schenk + * This file is originaly based on version 1.0.1 of pwmanager + * and was modified to run on embedded devices that run microkde + * + * $Id$ + **************************************************************************/ + +#include "pwmviewstyle.h" +#include "pwmexception.h" +#include "pwmviewstyle_0.h" +#include "pwmviewstyle_1.h" +#include "listviewpwm.h" +#include "pwmview.h" +#include "commentbox.h" + + +PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) + : QWidget(parent, name) +{ + curStyle = style_notset; + s0 = 0; + s1 = 0; +} + +PwMViewStyle::~PwMViewStyle() +{ + 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(); + 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: + BUG(); + } +} + +QString PwMViewStyle::getCurrentCategory() +{ + switch (curStyle) { + case style_0: + PWM_ASSERT(s0); + return s0->getCurrentCategory(); + case style_1: + PWM_ASSERT(s1); + return s1->getCurrentCategory(); + default: + BUG(); + } + return ""; +} + +void PwMViewStyle::addCategory(const QString &cat) +{ + switch (curStyle) { + case style_0: + PWM_ASSERT(s0); + s0->addCategory(cat); + return; + case style_1: + PWM_ASSERT(s1); + s1->addCategory(cat); + return; + default: + BUG(); + } +} + +void PwMViewStyle::delCategory(const QString &cat) +{ + switch (curStyle) { + case style_0: + PWM_ASSERT(s0); + s0->delCategory(cat); + return; + case style_1: + PWM_ASSERT(s1); + s1->delCategory(cat); + return; + default: + BUG(); + } +} + +void PwMViewStyle::delAllCategories() +{ + switch (curStyle) { + case style_0: + PWM_ASSERT(s0); + s0->delAllCategories(); + return; + case style_1: + PWM_ASSERT(s1); + s1->delAllCategories(); + return; + default: + BUG(); + } +} + +void PwMViewStyle::selectCategory(const QString &cat) +{ + switch (curStyle) { + case style_0: + PWM_ASSERT(s0); + s0->selectCategory(cat); + return; + case style_1: + PWM_ASSERT(s1); + s1->selectCategory(cat); + return; + default: + BUG(); + } +} + +int PwMViewStyle::numCategories() +{ + switch (curStyle) { + case style_0: + PWM_ASSERT(s0); + return s0->numCategories(); + case style_1: + PWM_ASSERT(s1); + return s1->numCategories(); + default: + BUG(); + } + return 0; +} + +#ifndef PWM_EMBEDDED +#include "pwmviewstyle.moc" +#endif |