summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-29 04:49:32 (UTC)
committer ulf69 <ulf69>2004-10-29 04:49:32 (UTC)
commit08a4582f8e5184b8abb7d97781c4fc37ee7edf90 (patch) (side-by-side diff)
tree5131fbfb3992196cf9f4108f7d81b37365104a7d
parentf8dd437160acec2959c462dd43d87f2a0920c0b9 (diff)
downloadkdepimpi-08a4582f8e5184b8abb7d97781c4fc37ee7edf90.zip
kdepimpi-08a4582f8e5184b8abb7d97781c4fc37ee7edf90.tar.gz
kdepimpi-08a4582f8e5184b8abb7d97781c4fc37ee7edf90.tar.bz2
added category edit feature
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/editcategory.cpp188
-rw-r--r--pwmanager/pwmanager/editcategory.h77
-rw-r--r--pwmanager/pwmanager/pwm.cpp69
-rw-r--r--pwmanager/pwmanager/pwm.h1
-rw-r--r--pwmanager/pwmanager/pwmanager.pro2
-rw-r--r--pwmanager/pwmanager/pwmanagerE.pro2
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp5
-rw-r--r--pwmanager/pwmanager/pwmdoc.h14
-rw-r--r--pwmanager/pwmanager/pwmview.cpp10
-rw-r--r--pwmanager/pwmanager/serializer.cpp44
10 files changed, 411 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/editcategory.cpp b/pwmanager/pwmanager/editcategory.cpp
new file mode 100644
index 0000000..4e55de8
--- a/dev/null
+++ b/pwmanager/pwmanager/editcategory.cpp
@@ -0,0 +1,188 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+#include "editcategory.h"
+#include "pwmdoc.h"
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <klocale.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+#include <qpushbutton.h>
+
+
+/*
+ * Constructs a addEntryWnd as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+editCategoryWnd::editCategoryWnd( PwMDoc* d, QWidget* parent, const char* name)
+ : KDialogBase( KDialogBase::Plain, i18n( "edit category descriptions" ),
+ Apply | User2 | Ok,
+ Ok, parent, name, true ),
+ doc(d)
+{
+ findButton( Ok )->setText (i18n("Close" )) ;
+ findButton( User2 )->setText (i18n("Cancel" )) ;
+ connect(this,SIGNAL(user2Clicked()), SLOT(cancel_slot()));
+ enableButton( KDialogBase::Apply, false );
+
+
+ QWidget *page = plainPage();
+ QGridLayout *layout = new QGridLayout( page, 3, 1 );
+ layout->setMargin( KDialogBase::marginHint() );
+ layout->setSpacing( KDialogBase::spacingHint() );
+
+ int i = 0;
+ categoryComboBox = new KComboBox( page );
+ QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), page );
+ layout->addWidget( label, i, 0 );
+ layout->addWidget( categoryComboBox, i, 1 );
+ i++;
+ categoryComboBox->setEditable( FALSE );
+ categoryComboBox->setSizeLimit( 100 );
+ connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&)));
+
+
+ descLineEdit = new KLineEdit( page, "descLineEdit" );
+ label = new QLabel( descLineEdit, i18n("Text1 (Description):"), page );
+ layout->addWidget( label, i, 0 );
+ layout->addWidget( descLineEdit, i, 1 );
+ connect( descLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
+ i++;
+
+ usernameLineEdit = new KLineEdit( page, "usernameLineEdit" );
+ label = new QLabel( usernameLineEdit, i18n("Text2 (Username):"), page );
+ layout->addWidget( label, i, 0 );
+ layout->addWidget( usernameLineEdit, i, 1 );
+ connect( usernameLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
+ i++;
+
+ pwLineEdit = new KLineEdit( page, "pwLineEdit" );
+ label = new QLabel( pwLineEdit, i18n("Text3 (Password):"), page );
+ layout->addWidget( label, i, 0 );
+ layout->addWidget( pwLineEdit, i, 1 );
+ connect( pwLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
+ i++;
+
+ unsigned int count = doc->numCategories();
+
+ for (unsigned int i = 0; i < count; ++i) {
+ categoryComboBox->insertItem(doc->getCategory(i)->c_str());
+ }
+
+ // PwMCategoryItem* getCategoryEntry(unsigned int index)
+ // { return &(dti.dta[index]); }
+
+
+
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+editCategoryWnd::~editCategoryWnd()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void editCategoryWnd::slotOk()
+{
+ // qDebug( "addEntryWnd::slotOk(): Not implemented yet" );
+ slotApply();
+ accept();
+}
+
+void editCategoryWnd::slotApply()
+{
+ QString cat = categoryComboBox->currentText();
+
+ unsigned int idx;
+ bool found = doc->findCategory(cat, &idx);
+
+ if (found == true)
+ {
+ PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
+
+ catitem->desc_text = descLineEdit->text().latin1();
+ catitem->name_text = usernameLineEdit->text().latin1();
+ catitem->pw_text = pwLineEdit->text().latin1();
+ enableButton( KDialogBase::Apply, false );
+ return;
+ }
+
+ BUG();
+
+}
+
+void editCategoryWnd::cancel_slot()
+{
+ QString cat = categoryComboBox->currentText();
+ categorySelected ( cat );
+}
+
+void editCategoryWnd::setCurrCategory(const QString &cat)
+{
+ int i, count = categoryComboBox->count();
+
+ for (i = 0; i < count; ++i) {
+ if (categoryComboBox->text(i) == cat) {
+ categoryComboBox->setCurrentItem(i);
+ categorySelected ( cat );
+ return;
+ }
+ }
+ BUG();
+}
+
+void editCategoryWnd::categorySelected ( const QString & string )
+{
+ unsigned int idx;
+ bool found = doc->findCategory(string, &idx);
+
+ if (found == true)
+ {
+ PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
+
+ descLineEdit->setText(catitem->desc_text.c_str());
+ usernameLineEdit->setText(catitem->name_text.c_str());
+ pwLineEdit->setText(catitem->pw_text.c_str());
+ enableButton( KDialogBase::Apply, false );
+ return;
+ }
+
+ BUG();
+
+}
+
+void editCategoryWnd::widgetModified(const QString &)
+{
+ enableButton( KDialogBase::Apply, true );
+}
+
diff --git a/pwmanager/pwmanager/editcategory.h b/pwmanager/pwmanager/editcategory.h
new file mode 100644
index 0000000..90b685b
--- a/dev/null
+++ b/pwmanager/pwmanager/editcategory.h
@@ -0,0 +1,77 @@
+/*
+ This file is part of PwManager/Platform independent.
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+$Id$
+*/
+
+#ifndef EDITCATEGORY_H
+#define EDITCATEGORY_H
+
+#include <qvariant.h>
+#include <kdialogbase.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QSpacerItem;
+class KLineEdit;
+class QPushButton;
+class KComboBox;
+class QLabel;
+class QGroupBox;
+class QMultiLineEdit;
+class PwMDoc;
+
+class editCategoryWnd : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ editCategoryWnd( PwMDoc* doc, QWidget* parent = 0, const char* name = 0);
+ ~editCategoryWnd();
+
+ void setCurrCategory(const QString &cat);
+
+ KComboBox* categoryComboBox;
+ KLineEdit* descLineEdit;
+ KLineEdit* usernameLineEdit;
+ KLineEdit* pwLineEdit;
+
+ //public slots:
+ // virtual void revealButton_slot();
+ // virtual void generateButton_slot();
+ // virtual void advancedCommentButton_slot(bool on);
+
+ protected slots:
+ virtual void slotOk();
+ virtual void slotApply();
+ virtual void cancel_slot();
+
+ virtual void categorySelected ( const QString & string );
+ virtual void widgetModified(const QString &);
+
+ private:
+ PwMDoc* doc;
+
+};
+
+#endif // EDITCATEGORY_H
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 6ae6e28..bd98d72 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -37,12 +37,13 @@
#include <qmessagebox.h>
#include <pwmprefs.h>
#include <kpimglobalprefs.h>
#include <kcmconfigs/kcmpwmconfig.h>
#include <kcmconfigs/kcmkdepimconfig.h>
#include <kcmultidialog.h>
+#include "editcategory.h"
#endif
#ifndef DESKTOP_VERSION
#include <qpe/global.h>
#endif
@@ -114,12 +115,15 @@ enum {
BUTTON_POPUP_VIEW_DEEPLOCK,
BUTTON_POPUP_VIEW_UNLOCK
};
// Button IDs for "options" popup menu
enum {
BUTTON_POPUP_OPTIONS_CONFIG = 0
+#ifdef PWM_EMBEDDED
+ ,BUTTON_POPUP_OPTIONS_CATEGORY
+#endif
};
// Button IDs for "export" popup menu (in "file" popup menu)
enum {
BUTTON_POPUP_EXPORT_TEXT = 0,
BUTTON_POPUP_EXPORT_GPASMAN,
BUTTON_POPUP_EXPORT_CSV
@@ -357,12 +361,18 @@ void PwM::initMenubar()
BUTTON_POPUP_OPTIONS_CONFIG);
menuBar()->insertItem(i18n("&Options"), optionsPopup);
// "help" popup menu
#ifndef PWM_EMBEDDED
helpPopup = helpMenu(QString::null, false);
#else
+ optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
+ i18n("C&ategories..."), this,
+ SLOT(category_slot()),
+ BUTTON_POPUP_OPTIONS_CATEGORY);
+
+
menuBar()->insertItem(i18n("&Sync"), syncPopup);
@@ -1388,12 +1398,71 @@ void PwM::focusInEvent(QFocusEvent *e)
}
}
#ifdef PWM_EMBEDDED
+void PwM::category_slot()
+{
+ PwMDoc *doc = curDoc();
+ PWM_ASSERT(doc);
+ doc->timer()->getLock(DocTimer::id_autoLockTimer);
+
+ editCategoryWnd w(doc, this, "editcategory");
+/*
+ vector<string> catList;
+ doc->getCategoryList(&catList);
+ unsigned i, size = catList.size();
+ for (i = 0; i < size; ++i) {
+ w.addCategory(catList[i].c_str());
+ }
+ w.setCurrCategory(view->getCurrentCategory());
+ if (pw)
+ w.pwLineEdit->setText(*pw);
+*/
+ w.setCurrCategory(view->getCurrentCategory());
+
+ tryAgain:
+ if (w.exec() == 1)
+ {
+ PwMDataItem d;
+
+ //US BUG: to initialize all values of curEntr with meaningfulldata,
+ // we call clear on it. Reason: Metadata will be uninitialized otherwise.
+ // another option would be to create a constructor for PwMDataItem
+ d.clear(true);
+ /*
+ d.desc = w.getDescription().latin1();
+ d.name = w.getUsername().latin1();
+ d.pw = w.getPassword().latin1();
+ d.comment = w.getComment().latin1();
+ d.url = w.getUrl().latin1();
+ d.launcher = w.getLauncher().latin1();
+ PwMerror ret = doc->addEntry(w.getCategory(), &d);
+ if (ret == e_entryExists) {
+ KMessageBox::error(this,
+ i18n
+ ("An entry with this \"Description\",\n"
+ "does already exist.\n"
+ "Please select another description."),
+ i18n("entry already exists."));
+ goto tryAgain;
+ } else if (ret == e_maxAllowedEntr) {
+ KMessageBox::error(this, i18n("The maximum possible number of\nentries"
+ "has been reached.\nYou can't add more entries."),
+ i18n("maximum number of entries"));
+ doc->timer()->putLock(DocTimer::id_autoLockTimer);
+ return;
+ }
+ */
+ }
+ setVirgin(false);
+ doc->timer()->putLock(DocTimer::id_autoLockTimer);
+}
+
+
void PwM::whatsnew_slot()
{
KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
}
void PwM::showLicense_slot()
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index fb34bca..9fa9edc 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -176,12 +176,13 @@ public slots:
/** make backup image of the current card */
void makeCardBackup_slot();
/** write backup image to current card */
void replayCardBackup_slot();
#ifdef PWM_EMBEDDED
+ void category_slot();
void whatsnew_slot();
void showLicense_slot();
void faq_slot();
void createAboutData_slot();
void syncHowTo_slot();
#endif
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro
index fbc0554..7efe45c 100644
--- a/pwmanager/pwmanager/pwmanager.pro
+++ b/pwmanager/pwmanager/pwmanager.pro
@@ -64,12 +64,13 @@ base64.h \
binentrygen.h \
blowfish.h \
commentbox.h \
compiler.h \
compressgzip.h \
csv.h \
+editcategory.h \
findwnd_emb.h \
findwndimpl.h \
genpasswd.h \
getkeycardwnd.h \
getmasterpwwnd_emb.h \
getmasterpwwndimpl.h \
@@ -130,12 +131,13 @@ addentrywndimpl.cpp \
base64.cpp \
binentrygen.cpp \
blowfish.cpp \
commentbox.cpp \
compressgzip.cpp \
csv.cpp \
+editcategory.cpp \
findwnd_emb.cpp \
findwndimpl.cpp \
genpasswd.cpp \
getkeycardwnd.cpp \
getmasterpwwnd_emb.cpp \
getmasterpwwndimpl.cpp \
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro
index e195178..6b68514 100644
--- a/pwmanager/pwmanager/pwmanagerE.pro
+++ b/pwmanager/pwmanager/pwmanagerE.pro
@@ -62,12 +62,13 @@ base64.h \
binentrygen.h \
blowfish.h \
commentbox.h \
compiler.h \
compressgzip.h \
csv.h \
+editcategory.h \
findwnd_emb.h \
findwndimpl.h \
genpasswd.h \
getkeycardwnd.h \
getmasterpwwnd_emb.h \
getmasterpwwndimpl.h \
@@ -128,12 +129,13 @@ addentrywndimpl.cpp \
base64.cpp \
binentrygen.cpp \
blowfish.cpp \
commentbox.cpp \
compressgzip.cpp \
csv.cpp \
+editcategory.cpp \
findwnd_emb.cpp \
findwndimpl.cpp \
genpasswd.cpp \
getkeycardwnd.cpp \
getmasterpwwnd_emb.cpp \
getmasterpwwndimpl.cpp \
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 9043acc..ddbf4f2 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -1049,12 +1049,15 @@ PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryInde
}
if (checkIfExist) {
if (findCategory(category, categoryIndex))
return e_categoryExists;
}
PwMCategoryItem item;
+ //US ENH: clear item to initialize with default values, or create a constructor
+ item.clear();
+
item.name = category.latin1();
dti.dta.push_back(item);
if (categoryIndex)
*categoryIndex = dti.dta.size() - 1;
return e_success;
}
@@ -1877,12 +1880,14 @@ void PwMDoc::_deepUnlock()
}
void PwMDoc::clearDoc()
{
dti.clear();
PwMCategoryItem d;
+ //US ENH: to initialize all members with meaningfull data.
+ d.clear();
d.name = DEFAULT_CATEGORY.latin1();
dti.dta.push_back(d);
currentPw = "";
unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW);
}
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 09923ab..ef81dfc 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -250,16 +250,25 @@ struct PwMCategoryItem
{
/** all PwMDataItems (all passwords) within this category */
vector<PwMDataItem> d;
/** category name/description */
string name;
+ //US ENH: enhancements of the filestructure
+ /* each category stores the text for description,name and password */
+ string desc_text;
+ string name_text;
+ string pw_text;
+
void clear()
{
d.clear();
name = "";
+ desc_text = "Description";
+ name_text = "Username";
+ pw_text = "Password";
}
};
struct PwMSyncItem
{
string syncName;
@@ -782,12 +791,17 @@ protected:
//the following methods are the overwritten callbackmethods from the syncinterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
virtual void removeSyncInfo( QString syncProfile);
#endif
+ //US ENH: helpermethods to return a whole category entry
+ /** returns a pointer to the categoryitem */
+ PwMCategoryItem* getCategoryEntry(unsigned int index)
+ { return &(dti.dta[index]); }
+
private:
//US ENH: helpermethods to access the sync data for a certain syncname.
// It returns the syncdatas index
bool findSyncData(const QString &syncname, unsigned int *index);
/** add new syncdataentry */
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index 5aaf66e..7733028 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -257,12 +257,22 @@ void PwMView::shiftToView()
tmpSorted[currItem.listViewPos] = currItem;
}
// shift tempoary data to ListView.
tmpDisableSort();
lv->clear();
+
+ //US ENH: adjust the headers of the table according the category texts
+ {
+ PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex);
+ // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str());
+ lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str());
+ lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str());
+ lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str());
+ }
+
QCheckListItem *newItem;
vector<PwMDataItem>::iterator it = tmpSorted.begin(),
end = tmpSorted.end();
while (it != end) {
newItem = new ListViewItemPwM(lv);
newItem->setText(COLUMN_DESC, (*it).desc.c_str());
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 5753c1d..507fa30 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -36,13 +36,13 @@
#define META_CREATE_DATE "c"
#define META_VALID_DATE "v"
#define META_EXPIRE_DATE "e"
#define META_UPDATE_DATE "u"
#define META_UPDATE_INT "i"
-//US ENH : uniqueid
+//US ENH : uniqueid and sync information
#define META_UNIQUEID "n"
#define SYNC_ROOT "s"
#define SYNC_TARGET_PREFIX "t"
#define SYNC_TARGET_NAME "n"
@@ -53,12 +53,15 @@
#define ROOT_MAGIC_OLD "PwM-xml-dat"
#define VER_STR_OLD "ver"
#define COMPAT_VER_OLD "0x02"
#define CAT_ROOT_OLD "categories"
#define CAT_PREFIX_OLD "cat_"
#define CAT_NAME_OLD "name"
+//US ENH : optional text for categories
+#define CAT_TEXT_OLD "text"
+
#define ENTRY_PREFIX_OLD "entry_"
#define ENTRY_DESC_OLD "desc"
#define ENTRY_NAME_OLD "name"
#define ENTRY_PW_OLD "pw"
#define ENTRY_COMMENT_OLD "comment"
#define ENTRY_URL_OLD "url"
@@ -70,12 +73,15 @@
#define ROOT_MAGIC_NEW "P"
#define VER_STR_NEW "v"
#define COMPAT_VER_NEW "2"
#define CAT_ROOT_NEW "c"
#define CAT_PREFIX_NEW "c"
#define CAT_NAME_NEW "n"
+//US ENH : optional text for categories
+#define CAT_TEXT_NEW "t"
+
#define ENTRY_PREFIX_NEW "e"
#define ENTRY_DESC_NEW "d"
#define ENTRY_NAME_NEW "n"
#define ENTRY_PW_NEW "p"
#define ENTRY_COMMENT_NEW "c"
#define ENTRY_URL_NEW "u"
@@ -88,12 +94,16 @@
# define ROOT_MAGIC_WR ROOT_MAGIC_OLD
# define VER_STR_WR VER_STR_OLD
# define COMPAT_VER_WR COMPAT_VER_OLD
# define CAT_ROOT_WR CAT_ROOT_OLD
# define CAT_PREFIX_WR CAT_PREFIX_OLD
# define CAT_NAME_WR CAT_NAME_OLD
+
+//US ENH : optional text for categories
+# define CAT_TEXT_WR CAT_TEXT_OLD
+
# define ENTRY_PREFIX_WR ENTRY_PREFIX_OLD
# define ENTRY_DESC_WR ENTRY_DESC_OLD
# define ENTRY_NAME_WR ENTRY_NAME_OLD
# define ENTRY_PW_WR ENTRY_PW_OLD
# define ENTRY_COMMENT_WR ENTRY_COMMENT_OLD
# define ENTRY_URL_WR ENTRY_URL_OLD
@@ -105,12 +115,16 @@
# define ROOT_MAGIC_WR ROOT_MAGIC_NEW
# define VER_STR_WR VER_STR_NEW
# define COMPAT_VER_WR COMPAT_VER_NEW
# define CAT_ROOT_WR CAT_ROOT_NEW
# define CAT_PREFIX_WR CAT_PREFIX_NEW
# define CAT_NAME_WR CAT_NAME_NEW
+
+//US ENH : optional text for categories
+# define CAT_TEXT_WR CAT_TEXT_NEW
+
# define ENTRY_PREFIX_WR ENTRY_PREFIX_NEW
# define ENTRY_DESC_WR ENTRY_DESC_NEW
# define ENTRY_NAME_WR ENTRY_NAME_NEW
# define ENTRY_PW_WR ENTRY_PW_NEW
# define ENTRY_COMMENT_WR ENTRY_COMMENT_NEW
# define ENTRY_URL_WR ENTRY_URL_NEW
@@ -268,12 +282,13 @@ bool Serializer::deSerialize(PwMItem *dta)
bool Serializer::readCategories(const QDomNode &n,
vector<PwMCategoryItem> *dta)
{
QDomNodeList nl(n.childNodes());
QDomNode cur;
QString name;
+ QString text;
unsigned int numCat = nl.count(), i;
PwMCategoryItem curCat;
vector<PwMDataItem> curEntr;
if (!numCat) {
printDebug("Serializer::readCategories(): empty");
@@ -287,12 +302,29 @@ bool Serializer::readCategories(const QDomNode &n,
if (name == QString::null)
name = cur.toElement().attribute(CAT_NAME_OLD);
PWM_ASSERT(name != QString::null);
PWM_ASSERT(name != "");
curCat.clear();
curCat.name = name.latin1();
+
+ //US ENH: new version might include text for description, name and pw
+ text = cur.toElement().attribute(CAT_TEXT_NEW);
+ if (text == QString::null)
+ text = cur.toElement().attribute(CAT_TEXT_OLD);
+ if (text != QString::null)
+ {
+ QStringList textlist = QStringList::split(";", text, true);
+ unsigned int num = textlist.count();
+ if (num > 0)
+ curCat.desc_text = textlist[0].latin1();
+ if (num > 1)
+ curCat.name_text = textlist[1].latin1();
+ if (num > 2)
+ curCat.pw_text = textlist[2].latin1();
+ }
+
if (!readEntries(cur, &curEntr)) {
dta->clear();
return false;
}
curCat.d = curEntr;
dta->push_back(curCat);
@@ -498,12 +530,22 @@ bool Serializer::addCategories(QDomElement *e,
for (i = 0; i < numCat; ++i) {
curId = CAT_PREFIX_WR;
curId += tostr(i).c_str();
curName = dta[i].name.c_str();
curCat = domDoc->createElement(curId);
curCat.setAttribute(CAT_NAME_WR, curName);
+
+ //US ENH: new version includes text for description, name and pw
+ QStringList curTextList;
+ curTextList << dta[i].desc_text.c_str();
+ curTextList << dta[i].name_text.c_str();
+ curTextList << dta[i].pw_text.c_str();
+ QString text = curTextList.join(";");
+ curCat.setAttribute(CAT_TEXT_WR, text);
+
+
if (!addEntries(&curCat, dta[i].d)) {
return false;
}
e->appendChild(curCat);
}
return true;