summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp44
1 files changed, 34 insertions, 10 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index ef16b46..e86b3d2 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -2584,60 +2584,66 @@ void ZSafe::addCategory()
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
QStringList::Iterator it = list.begin();
QString categ;
+ QString firstCategory;
dialog->CategoryField->clear(); // remove all items
while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
{
#ifdef DESKTOP
#ifndef WIN32
categ = cat->section ("-field1", 0, 0);
#else
int pos = cat->find ("-field1");
categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
categ = *cat;
#endif
if (!categ.isEmpty())
{
dialog->CategoryField->insertItem (categ, -1);
+ if (firstCategory.isEmpty())
+ firstCategory = categ;
}
}
++it;
}
- setCategoryDialogFields(dialog);
+ if (firstCategory.isEmpty())
+ setCategoryDialogFields(dialog);
+ else
+ setCategoryDialogFields(dialog, firstCategory);
// CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE);
if (initIcons)
{
Wait waitDialog(this, tr("Wait dialog"));
waitDialog.waitLabel->setText(tr("Gathering icons..."));
waitDialog.show();
qApp->processEvents();
#ifdef DESKTOP
QDir d(iconPath);
#else
QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
d.setFilter( QDir::Files);
@@ -2773,44 +2779,59 @@ void ZSafe::delCategory()
if (_si) delete _si;
}
ListView->takeItem(selectedItem);
delete selectedItem;
selectedItem = NULL;
break;
case 1: // Don't delete
break;
}
}
}
void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
{
- dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name")));
- dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username")));
- dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password")));
- dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
- dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4")));
- dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5")));
+ if (!dialog)
+ return;
QString icon;
- Category *cat= categories.find (selectedItem->text(0));
- if (cat)
+ if (selectedItem)
{
- icon = cat->getIconName();
+ dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name")));
+ dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username")));
+ dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password")));
+ dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
+ dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4")));
+ dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5")));
+
+ Category *cat= categories.find (selectedItem->text(0));
+ if (cat)
+ {
+ icon = cat->getIconName();
+ }
+ }
+ else
+ {
+ dialog->Field1->setText(tr("Name"));
+ dialog->Field2->setText(tr("Username"));
+ dialog->Field3->setText(tr("Password"));
+ dialog->Field4->setText(tr("Comment"));
+ dialog->Field5->setText(tr("Field 4"));
+ dialog->Field6->setText(tr("Field 5"));
}
#ifdef DESKTOP
QDir d(iconPath);
#else
QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
d.setFilter( QDir::Files);
const QFileInfoList *list = d.entryInfoList();
int i=0;
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
@@ -2825,32 +2846,35 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
fileName = fileName.mid(0,fileName.length()-4);
if(fileName+".png"==icon)
{
dialog->IconField->setCurrentItem(i+1);
break;
}
++i;
}
++it;
}
}
}
void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
{
+ if (!dialog)
+ return;
+
dialog->Field1->setText(getFieldLabel (category, "1", tr("Name")));
dialog->Field2->setText(getFieldLabel (category, "2", tr("Username")));
dialog->Field3->setText(getFieldLabel (category, "3", tr("Password")));
dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment")));
dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4")));
dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5")));
QString icon;
Category *cat= categories.find (category);
if (cat)
{
icon = cat->getIconName();
}
#ifdef DESKTOP
QDir d(iconPath);