author | ulf69 <ulf69> | 2004-09-29 06:21:37 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-29 06:21:37 (UTC) |
commit | 53c2eac6f60a37f9ac8fc10b86460eb9c7347b51 (patch) (side-by-side diff) | |
tree | 1f2fb8a996c9e97465df770364777eacaecefa34 | |
parent | 72b990edf0191c2e86204308ce2cac07120284bf (diff) | |
download | kdepimpi-53c2eac6f60a37f9ac8fc10b86460eb9c7347b51.zip kdepimpi-53c2eac6f60a37f9ac8fc10b86460eb9c7347b51.tar.gz kdepimpi-53c2eac6f60a37f9ac8fc10b86460eb9c7347b51.tar.bz2 |
*** empty log message ***
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 15 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmprefs.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmprefs.h | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle.cpp | 32 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_0.cpp | 21 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_0.h | 6 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_1.cpp | 20 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_1.h | 5 | ||||
-rw-r--r-- | pwmanager/pwmanager/serializer.cpp | 34 |
9 files changed, 107 insertions, 31 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 9fe4809..c167c2c 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp @@ -31,37 +31,39 @@ #ifndef PWM_EMBEDDED //US #include "libgryptif.h" #else #include "pwmprefs.h" #include "kglobal.h" #endif #ifdef CONFIG_KWALLETIF # include "kwalletemu.h" #endif // CONFIG_KWALLETIF #include <qdatetime.h> #include <qsize.h> #include <qfileinfo.h> #include <qfile.h> +#define __USE_GNU +#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> -#include <iostream> +//US#include <iostream> #include <algorithm> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdint.h> //TODO: reset to its normal value. #define META_CHECK_TIMER_INTERVAL 10/*300*/ /* sek */ using namespace std; void PwMDocList::add(PwMDoc *doc, const string &id) { #ifdef PWM_DEBUG // check for existance of object in debug mode only. @@ -1141,40 +1143,51 @@ unsigned int PwMDoc::numEntries(const QString &category) bool PwMDoc::serializeDta(string *d) { PWM_ASSERT(d); Serializer ser; if (!ser.serialize(dta)) return false; d->assign(ser.getXml()); if (!d->size()) return false; return true; } bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked) { PWM_ASSERT(d); +#ifndef PWM_EMBEDDED try { + Serializer ser(d->c_str()); ser.setDefaultLockStat(entriesLocked); if (!ser.deSerialize(&dta)) return false; } catch (PwMException) { return false; } +#else + Serializer ser(d->c_str()); + ser.setDefaultLockStat(entriesLocked); + if (!ser.deSerialize(&dta)) + return false; + else + return false; +#endif + emitDataChanged(this); return true; } bool PwMDoc::getEntry(const QString &category, unsigned int index, PwMDataItem * d, bool unlockIfLocked) { PWM_ASSERT(d); unsigned int cat = 0; if (!findCategory(category, &cat)) { BUG(); return false; } return getEntry(cat, index, d, unlockIfLocked); diff --git a/pwmanager/pwmanager/pwmprefs.cpp b/pwmanager/pwmanager/pwmprefs.cpp index 5779ecc..d3847f6 100644 --- a/pwmanager/pwmanager/pwmprefs.cpp +++ b/pwmanager/pwmanager/pwmprefs.cpp @@ -48,32 +48,33 @@ PWMPrefs::PWMPrefs() addItemInt( "filePermissions", &mFilePermissions, CONF_DEFAULT_FILEPERMISSIONS ); addItemInt( "minimizeLock", &mMinimizeLock, CONF_DEFAULT_MINIMIZELOCK ); addItemBool( "unlockOnOpen", &mUnlockOnOpen, CONF_DEFAULT_UNLOCKONOPEN ); addItemBool( "tray", &mTray, CONF_DEFAULT_TRAY ); addItemBool( "makeFileBackup", &mMakeFileBackup, CONF_DEFAULT_MAKEFILEBACKUP ); addItemBool( "autostartDeepLocked", &mAutostartDeeplocked, CONF_DEFAULT_AUTOSTART_DEEPL ); addItemBool( "autoDeepLock", &mAutoDeeplock, CONF_DEFAULT_AUTODEEPLOCK ); addItemBool( "kwalletEmu", &mKWalletEmu, CONF_DEFAULT_KWALLETEMU ); addItemBool( "newEntrLockStat", &mNewEntrLockStat, CONF_DEFAULT_NEWENTRLOCKSTAT ); KPrefs::setCurrentGroup( "Wnd" ); addItemSize( "MainWndSize", &mMainWndSize); addItemInt( "MainViewStyle", &mMainViewStyle, CONF_DEFAULT_MAINVIEWSTYLE ); addItemBool( "autoMinimizeOnStart", &mAutoMinimizeOnStart, CONF_DEFAULT_AUTOMINIMIZE ); addItemBool( "close", &mClose, CONF_DEFAULT_WNDCLOSE ); + addItemIntList( "CommentSplitter", &mCommentSplitter ); } PWMPrefs::~PWMPrefs() { } PWMPrefs *PWMPrefs::instance() { if ( !sInstance ) { #ifdef PWM_EMBEDDED sInstance = staticDeleter.setObject( new PWMPrefs() ); #else //PWM_EMBEDDED //US the following line has changed ???. Why staticDeleter.setObject( sInstance, new PWMPrefs() ); #endif //KAB_EMBEDDED sInstance->readConfig(); diff --git a/pwmanager/pwmanager/pwmprefs.h b/pwmanager/pwmanager/pwmprefs.h index bf7d8b1..6a89d10 100644 --- a/pwmanager/pwmanager/pwmprefs.h +++ b/pwmanager/pwmanager/pwmprefs.h @@ -121,26 +121,30 @@ public: int mLockTimeout; int mCompression; int mFilePermissions; int mMinimizeLock; bool mUnlockOnOpen; bool mTray; bool mMakeFileBackup; bool mAutostartDeeplocked; bool mAutoDeeplock; bool mKWalletEmu; bool mNewEntrLockStat; QSize mMainWndSize; int mMainViewStyle; bool mAutoMinimizeOnStart; bool mClose; + //US ENH + QValueList<int> mCommentSplitter; + + // US introduce a nonconst way to return the config object. KConfig* getConfig(); private: PWMPrefs(); static PWMPrefs *sInstance; }; #endif 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 @@ -28,35 +28,47 @@ #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); @@ -75,34 +87,44 @@ void PwMViewStyle::initStyle(style_t style) 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: diff --git a/pwmanager/pwmanager/pwmviewstyle_0.cpp b/pwmanager/pwmanager/pwmviewstyle_0.cpp index 6d46ac6..7262684 100644 --- a/pwmanager/pwmanager/pwmviewstyle_0.cpp +++ b/pwmanager/pwmanager/pwmviewstyle_0.cpp @@ -10,33 +10,33 @@ ***************************************************************************/ /*************************************************************************** * 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_0.h" #include "pwmview.h" #include "listviewpwm.h" #include "commentbox.h" #include <klocale.h> - +#include "pwmprefs.h" PwMViewStyle_0::PwMViewStyle_0(PwMView *view) : QObject() { vbox1 = new QVBox(view); vbox1->setSpacing(3); hbox1 = new QHBox(vbox1); hbox1->setSpacing(10); categoriesTitle = new QLabel(hbox1); categoriesTitle->setText(i18n("Categories:")); categoriesCombo = new QComboBox(hbox1); renCatButton = new QPushButton(i18n("&Rename"), hbox1); delCatButton = new QPushButton(i18n("&Delete"), hbox1); #ifndef PWM_EMBEDDED splitter1 = new QSplitter(vbox1); splitter1->setOrientation(Qt::Vertical); @@ -78,16 +78,35 @@ void PwMViewStyle_0::delCategory(const QString &cat) BUG(); } void PwMViewStyle_0::selectCategory(const QString &cat) { PWM_ASSERT(categoriesCombo); int i, count = categoriesCombo->count(); for (i = 0; i < count; ++i) { if (categoriesCombo->text(i) == cat) { categoriesCombo->setCurrentItem(i); return; } } // fall back to 0 categoriesCombo->setCurrentItem(0); } + + +//US ENH: I need a place to load the view dependend settings. Eg. splittersize +void PwMViewStyle_0::restoreSettings(PWMPrefs* prefs) +{ + //load and store the size of the listviewcolumns + lv->restoreLayout(prefs->getConfig(), "listview"); + splitter1->setSizes( prefs->mCommentSplitter ); + +} + +//US ENH: I need a place to load the view dependend settings. Eg. splittersize +void PwMViewStyle_0::saveSettings(PWMPrefs* prefs) +{ + //store the size of the listviewcolumns + lv->saveLayout(prefs->getConfig(), "listview"); + prefs->mCommentSplitter = splitter1->sizes(); + +} diff --git a/pwmanager/pwmanager/pwmviewstyle_0.h b/pwmanager/pwmanager/pwmviewstyle_0.h index cc564c3..bd93c06 100644 --- a/pwmanager/pwmanager/pwmviewstyle_0.h +++ b/pwmanager/pwmanager/pwmviewstyle_0.h @@ -23,32 +23,33 @@ #include <qhbox.h> #include <qvbox.h> #include <qpushbutton.h> #ifndef PWM_EMBEDDED #include <qtextedit.h> #include <qsplitter.h> #else #include <qmultilineedit.h> #include <KDGanttMinimizeSplitter.h> #endif #include <qlabel.h> #include <qcombobox.h> class PwMView; class ListViewPwM; class CommentBox; +class PWMPrefs; class PwMViewStyle_0 : public QObject { public: PwMViewStyle_0(PwMView *view); ~PwMViewStyle_0(); ListViewPwM * getLv() { return lv; } CommentBox * getCommentBox() { return commentBox; } /** returns the currently selected category */ QString getCurrentCategory() { return categoriesCombo->currentText(); } /** add Category to the view */ @@ -58,32 +59,37 @@ public: void delCategory(const QString &cat); /** delete all categories from view */ void delAllCategories() { categoriesCombo->clear(); } /** select the specified category */ void selectCategory(const QString &cat); /** returns the number of categories in this view. * This value dosn't say anything about the number of * categories in the document. */ int numCategories() { return categoriesCombo->count(); } /** resize the view */ void resize(const QSize &size) { vbox1->resize(size); } + //US ENH: I need a place to load the view dependend settings. Eg. splittersize + void restoreSettings(PWMPrefs* prefs); + void saveSettings(PWMPrefs* prefs); + + protected: /** main list view */ ListViewPwM *lv; /** categories combo-box */ QComboBox *categoriesCombo; /** title string for the categories combo or list box */ QLabel *categoriesTitle; /** hbox1 for widget style */ QHBox *hbox1; /** vbox1 for widget style */ QVBox *vbox1; /** splitter for commentTextEdit */ #ifndef PWM_EMBEDDED QSplitter *splitter1; #else KDGanttMinimizeSplitter * splitter1; diff --git a/pwmanager/pwmanager/pwmviewstyle_1.cpp b/pwmanager/pwmanager/pwmviewstyle_1.cpp index 4c24bc4..8b2d6d3 100644 --- a/pwmanager/pwmanager/pwmviewstyle_1.cpp +++ b/pwmanager/pwmanager/pwmviewstyle_1.cpp @@ -10,32 +10,33 @@ ***************************************************************************/ /*************************************************************************** * 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_1.h" #include "pwmview.h" #include "listviewpwm.h" #include "commentbox.h" #include <klocale.h> +#include "pwmprefs.h" #define INITIAL_CATEGORIES_WIDTH 100 PwMViewStyle_1::PwMViewStyle_1(PwMView *view) : QObject() { #ifndef PWM_EMBEDDED splitter = new QSplitter(view); #else splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view); splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); //US topLayout->addWidget(mMiniSplitter ); #endif vbox1 = new QVBox(splitter); @@ -112,19 +113,38 @@ void PwMViewStyle_1::delCategory(const QString &cat) } void PwMViewStyle_1::selectCategory(const QString &cat) { PWM_ASSERT(categoriesList); int i, count = categoriesList->count(); for (i = 0; i < count; ++i) { if (categoriesList->text(i) == cat) { categoriesList->setCurrentItem(i); return; } } // fall back to 0 categoriesList->setCurrentItem(0); } +//US ENH: I need a place to load the view dependend settings. Eg. splittersize +void PwMViewStyle_1::restoreSettings(PWMPrefs* prefs) +{ + //load and store the size of the listviewcolumns + lv->restoreLayout(prefs->getConfig(), "listview"); + splitter2->setSizes( prefs->mCommentSplitter ); + +} + +//US ENH: I need a place to load the view dependend settings. Eg. splittersize +void PwMViewStyle_1::saveSettings(PWMPrefs* prefs) +{ + //store the size of the listviewcolumns + lv->saveLayout(prefs->getConfig(), "listview"); + prefs->mCommentSplitter = splitter2->sizes(); + +} + + #ifndef PWM_EMBEDDED #include "pwmviewstyle_1.moc" #endif diff --git a/pwmanager/pwmanager/pwmviewstyle_1.h b/pwmanager/pwmanager/pwmviewstyle_1.h index a50f587..a7f100c 100644 --- a/pwmanager/pwmanager/pwmviewstyle_1.h +++ b/pwmanager/pwmanager/pwmviewstyle_1.h @@ -24,32 +24,33 @@ #ifndef PWM_EMBEDDED #include <qtextedit.h> #include <qsplitter.h> #else #include <qmultilineedit.h> #include <KDGanttMinimizeSplitter.h> #endif #include <qlabel.h> #include <qlistbox.h> #include <qpopupmenu.h> class PwMView; class ListViewPwM; class CommentBox; +class PWMPrefs; class PwMViewStyle_1 : public QObject { Q_OBJECT public: PwMViewStyle_1(PwMView *view); ~PwMViewStyle_1(); ListViewPwM * getLv() { return lv; } CommentBox * getCommentBox() { return commentBox; } /** returns the currently selected category */ QString getCurrentCategory() { return categoriesList->currentText(); } @@ -60,32 +61,36 @@ public: void delCategory(const QString &cat); /** delete all categories from view */ void delAllCategories() { categoriesList->clear(); } /** select the specified category */ void selectCategory(const QString &cat); /** returns the number of categories in this view. * This value dosn't say anything about the number of * categories in the document. */ int numCategories() { return categoriesList->count(); } /** resize the view */ void resize(const QSize &size) { splitter->resize(size); } + //US ENH: I need a place to load the view dependend settings. Eg. splittersize + void restoreSettings(PWMPrefs* prefs); + void saveSettings(PWMPrefs* prefs); + protected slots: /** user clicked right button in category list */ void catRightClick(QListBoxItem *item, const QPoint &point); protected: /** main list view */ ListViewPwM *lv; #ifndef PWM_EMBEDDED /** main splitter widget */ QSplitter *splitter; /** commentTextEdit splitter */ QSplitter *splitter2; #else /** main splitter widget */ KDGanttMinimizeSplitter *splitter; /** commentTextEdit splitter */ diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp index 9377e3d..a54ba8a 100644 --- a/pwmanager/pwmanager/serializer.cpp +++ b/pwmanager/pwmanager/serializer.cpp @@ -391,70 +391,56 @@ bool Serializer::extractMeta(const QDomNode &n, } else if (name == META_VALID_DATE) { dta->valid = QDateTime::fromString(val, Qt::ISODate); } else if (name == META_EXPIRE_DATE) { dta->expire = QDateTime::fromString(val, Qt::ISODate); } else if (name == META_UPDATE_DATE) { dta->update = QDateTime::fromString(val, Qt::ISODate); } else if (name == META_UPDATE_INT) { dta->updateInt = strtoul(val.latin1(), 0, 10); } else if (name == META_UNIQUEID) { dta->uniqueid = unescapeEntryData(val).latin1(); } else { printDebug(string("extractMeta(): invalid: ") + name.latin1()); } #else - QDateTime m_dt; - - if ((name == META_CREATE_DATE) || - (name == META_VALID_DATE) || - (name == META_EXPIRE_DATE) || - (name == META_UPDATE_DATE)) - { - int pos = val.find("T"); - QString date = val.left(pos); - QString time = val.mid(pos+1); - qDebug("Serializer::extractMeta from %s to date=%s ,time=%s",val.latin1(), date.latin1(), time.latin1() ); - bool ok1, ok2; - - QDate m_date = KGlobal::locale()->readDate(date, &ok1); - QTime m_time = KGlobal::locale()->readTime(time, &ok2); - if ((ok1 == false) || (ok2 == false)) - qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); - m_dt.setDate(m_date); - m_dt.setTime(m_time); - } + bool ok = true; if (name == META_CREATE_DATE) { - dta->create = m_dt; + dta->create = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); } else if (name == META_VALID_DATE) { - dta->valid = m_dt; + dta->valid = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); } else if (name == META_EXPIRE_DATE) { - dta->expire = m_dt; + dta->expire = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); } else if (name == META_UPDATE_DATE) { - dta->update = m_dt; + dta->update = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); } else if (name == META_UPDATE_INT) { dta->updateInt = strtoul(val.latin1(), 0, 10); } else if (name == META_UNIQUEID) { dta->uniqueid = unescapeEntryData(val).latin1(); } else { printDebug(string("extractMeta(): invalid: ") + name.latin1()); } + + if (ok == false) + qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); + + #endif cur = cur.nextSibling(); } return true; } bool Serializer::checkValid() { PWM_ASSERT(domDoc); QDomElement root(domDoc->documentElement()); if (root.nodeName() != ROOT_MAGIC_NEW && root.nodeName() != ROOT_MAGIC_OLD) { printDebug("Serializer: wrong magic"); return false; } if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW && |