summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index abf6511..ef16b46 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -2699,202 +2699,286 @@ void ZSafe::addCategory()
2699 { 2699 {
2700 // build the full path 2700 // build the full path
2701 fullIconPath = iconPath + icon; 2701 fullIconPath = iconPath + icon;
2702 pix = new QPixmap (fullIconPath); 2702 pix = new QPixmap (fullIconPath);
2703 // pix->resize(14, 14); 2703 // pix->resize(14, 14);
2704 if (pix) 2704 if (pix)
2705 { 2705 {
2706 // save the full pixmap name into the config file 2706 // save the full pixmap name into the config file
2707// #ifndef WIN32 2707// #ifndef WIN32
2708 conf->writeEntry(APP_KEY+category, icon); 2708 conf->writeEntry(APP_KEY+category, icon);
2709// #endif 2709// #endif
2710 saveConf(); 2710 saveConf();
2711 QImage img = pix->convertToImage(); 2711 QImage img = pix->convertToImage();
2712 pix->convertFromImage(img.smoothScale(14,14)); 2712 pix->convertFromImage(img.smoothScale(14,14));
2713 c1->setIcon (*pix); 2713 c1->setIcon (*pix);
2714 c1->setIconName(icon); 2714 c1->setIconName(icon);
2715 } 2715 }
2716 else 2716 else
2717 { 2717 {
2718 QPixmap folder( ( const char** ) general_data ); 2718 QPixmap folder( ( const char** ) general_data );
2719 c1->setIcon (folder); 2719 c1->setIcon (folder);
2720 } 2720 }
2721 } 2721 }
2722 else 2722 else
2723 { 2723 {
2724 c1->setIcon (*getPredefinedIcon(category)); 2724 c1->setIcon (*getPredefinedIcon(category));
2725 } 2725 }
2726 2726
2727 c1->setListItem (li); 2727 c1->setListItem (li);
2728 c1->initListItem(); 2728 c1->initListItem();
2729 categories.insert (c1->getCategoryName(), c1); 2729 categories.insert (c1->getCategoryName(), c1);
2730 2730
2731 saveCategoryDialogFields(dialog); 2731 saveCategoryDialogFields(dialog);
2732 } 2732 }
2733 else 2733 else
2734 { 2734 {
2735 // delete dialog; 2735 // delete dialog;
2736 dialog->hide(); 2736 dialog->hide();
2737 return; 2737 return;
2738 } 2738 }
2739 2739
2740 } 2740 }
2741 2741
2742} 2742}
2743 2743
2744void ZSafe::delCategory() 2744void ZSafe::delCategory()
2745{ 2745{
2746 if (!selectedItem) 2746 if (!selectedItem)
2747 return; 2747 return;
2748 if (isCategory(selectedItem)) 2748 if (isCategory(selectedItem))
2749 { 2749 {
2750 switch( QMessageBox::information( this, tr("ZSafe"), 2750 switch( QMessageBox::information( this, tr("ZSafe"),
2751 tr("Do you want to delete?"), 2751 tr("Do you want to delete?"),
2752 tr("&Delete"), tr("D&on't Delete"), 2752 tr("&Delete"), tr("D&on't Delete"),
2753 0 // Enter == button 0 2753 0 // Enter == button 0
2754 ) ) { // Escape == button 2 2754 ) ) { // Escape == button 2
2755 case 0: // Delete clicked, Alt-S or Enter pressed. 2755 case 0: // Delete clicked, Alt-S or Enter pressed.
2756 // Delete from the category list 2756 // Delete from the category list
2757 modified = true; 2757 modified = true;
2758 categories.remove (selectedItem->text(0)); 2758 categories.remove (selectedItem->text(0));
2759// #ifndef WIN32 2759// #ifndef WIN32
2760 conf->removeEntry (selectedItem->text(0)); 2760 conf->removeEntry (selectedItem->text(0));
2761// #endif 2761// #endif
2762 saveConf(); 2762 saveConf();
2763 2763
2764 // Delete the selected item and all subitems 2764 // Delete the selected item and all subitems
2765 // step through all subitems 2765 // step through all subitems
2766 QListViewItem *si; 2766 QListViewItem *si;
2767 for (si = selectedItem->firstChild(); 2767 for (si = selectedItem->firstChild();
2768 si != NULL; ) 2768 si != NULL; )
2769 { 2769 {
2770 QListViewItem *_si = si; 2770 QListViewItem *_si = si;
2771 si = si->nextSibling(); 2771 si = si->nextSibling();
2772 selectedItem->takeItem(_si); // remove from view list 2772 selectedItem->takeItem(_si); // remove from view list
2773 if (_si) delete _si; 2773 if (_si) delete _si;
2774 } 2774 }
2775 ListView->takeItem(selectedItem); 2775 ListView->takeItem(selectedItem);
2776 delete selectedItem; 2776 delete selectedItem;
2777 2777
2778 selectedItem = NULL; 2778 selectedItem = NULL;
2779 break; 2779 break;
2780 case 1: // Don't delete 2780 case 1: // Don't delete
2781 break; 2781 break;
2782 } 2782 }
2783 2783
2784 } 2784 }
2785} 2785}
2786 2786
2787void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) 2787void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
2788{ 2788{
2789 dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 2789 dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name")));
2790 dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 2790 dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username")));
2791 dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 2791 dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password")));
2792 dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 2792 dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
2793 dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); 2793 dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4")));
2794 dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); 2794 dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5")));
2795
2796 QString icon;
2797 Category *cat= categories.find (selectedItem->text(0));
2798 if (cat)
2799 {
2800 icon = cat->getIconName();
2801 }
2802
2803#ifdef DESKTOP
2804 QDir d(iconPath);
2805#else
2806 QDir d(QPEApplication::qpeDir() + "/pics/");
2807#endif
2808 d.setFilter( QDir::Files);
2809
2810 const QFileInfoList *list = d.entryInfoList();
2811 int i=0;
2812 QFileInfoListIterator it( *list ); // create list iterator
2813 QFileInfo *fi; // pointer for traversing
2814 if (icon.isEmpty() || icon.isNull())
2815 {
2816 dialog->IconField->setCurrentItem(0);
2817 }
2818 else
2819 {
2820 while ( (fi=it.current()) )
2821 { // for each file...
2822 QString fileName = fi->fileName();
2823 if(fileName.right(4) == ".png")
2824 {
2825 fileName = fileName.mid(0,fileName.length()-4);
2826
2827 if(fileName+".png"==icon)
2828 {
2829 dialog->IconField->setCurrentItem(i+1);
2830 break;
2831 }
2832 ++i;
2833 }
2834 ++it;
2835 }
2836 }
2795} 2837}
2796 2838
2797void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) 2839void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
2798{ 2840{
2799 dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); 2841 dialog->Field1->setText(getFieldLabel (category, "1", tr("Name")));
2800 dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); 2842 dialog->Field2->setText(getFieldLabel (category, "2", tr("Username")));
2801 dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); 2843 dialog->Field3->setText(getFieldLabel (category, "3", tr("Password")));
2802 dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); 2844 dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment")));
2803 dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); 2845 dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4")));
2804 dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); 2846 dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5")));
2847
2848 QString icon;
2849 Category *cat= categories.find (category);
2850 if (cat)
2851 {
2852 icon = cat->getIconName();
2853 }
2854
2855#ifdef DESKTOP
2856 QDir d(iconPath);
2857#else
2858 QDir d(QPEApplication::qpeDir() + "/pics/");
2859#endif
2860 d.setFilter( QDir::Files);
2861
2862 const QFileInfoList *list = d.entryInfoList();
2863 int i=0;
2864 QFileInfoListIterator it( *list ); // create list iterator
2865 QFileInfo *fi; // pointer for traversing
2866 if (icon.isEmpty() || icon.isNull())
2867 {
2868 dialog->IconField->setCurrentItem(0);
2869 }
2870 else
2871 {
2872 while ( (fi=it.current()) )
2873 { // for each file...
2874 QString fileName = fi->fileName();
2875 if(fileName.right(4) == ".png")
2876 {
2877 fileName = fileName.mid(0,fileName.length()-4);
2878
2879 if(fileName+".png"==icon)
2880 {
2881 dialog->IconField->setCurrentItem(i+1);
2882 break;
2883 }
2884 ++i;
2885 }
2886 ++it;
2887 }
2888 }
2805} 2889}
2806 2890
2807void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) 2891void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
2808{ 2892{
2809 QString app_key = APP_KEY; 2893 QString app_key = APP_KEY;
2810#ifndef DESKTOP 2894#ifndef DESKTOP
2811 conf->setGroup ("fieldDefs"); 2895 conf->setGroup ("fieldDefs");
2812#else 2896#else
2813#ifndef WIN32 2897#ifndef WIN32
2814 app_key += "/fieldDefs/"; 2898 app_key += "/fieldDefs/";
2815#endif 2899#endif
2816#endif 2900#endif
2817 QString category = dialog->CategoryField->currentText(); 2901 QString category = dialog->CategoryField->currentText();
2818// #ifndef WIN32 2902// #ifndef WIN32
2819 conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); 2903 conf->writeEntry(app_key+category+"-field1", dialog->Field1->text());
2820 conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); 2904 conf->writeEntry(app_key+category+"-field2", dialog->Field2->text());
2821 conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); 2905 conf->writeEntry(app_key+category+"-field3", dialog->Field3->text());
2822 conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); 2906 conf->writeEntry(app_key+category+"-field4", dialog->Field4->text());
2823 conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); 2907 conf->writeEntry(app_key+category+"-field5", dialog->Field5->text());
2824 conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); 2908 conf->writeEntry(app_key+category+"-field6", dialog->Field6->text());
2825// #endif 2909// #endif
2826 saveConf(); 2910 saveConf();
2827#ifndef DESKTOP 2911#ifndef DESKTOP
2828 conf->setGroup ("zsafe"); 2912 conf->setGroup ("zsafe");
2829#endif 2913#endif
2830} 2914}
2831 2915
2832void ZSafe::editCategory() 2916void ZSafe::editCategory()
2833{ 2917{
2834 if (!selectedItem) 2918 if (!selectedItem)
2835 return; 2919 return;
2836 if (isCategory(selectedItem)) 2920 if (isCategory(selectedItem))
2837 { 2921 {
2838 QString category = selectedItem->text(0); 2922 QString category = selectedItem->text(0);
2839 bool initIcons = false; 2923 bool initIcons = false;
2840 // open the 'Category' dialog 2924 // open the 'Category' dialog
2841 CategoryDialog *dialog; 2925 CategoryDialog *dialog;
2842 if (categoryDialog) 2926 if (categoryDialog)
2843 { 2927 {
2844 dialog = categoryDialog; 2928 dialog = categoryDialog;
2845 } 2929 }
2846 else 2930 else
2847 { 2931 {
2848 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); 2932 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
2849#ifdef WIN32 2933#ifdef WIN32
2850 categoryDialog->setCaption ("Qt " + tr("Category")); 2934 categoryDialog->setCaption ("Qt " + tr("Category"));
2851#endif 2935#endif
2852 dialog = categoryDialog; 2936 dialog = categoryDialog;
2853 connect( dialog->CategoryField, 2937 connect( dialog->CategoryField,
2854 SIGNAL( activated ( const QString &)), 2938 SIGNAL( activated ( const QString &)),
2855 this, SLOT( categoryFieldActivated( const QString & ) ) ); 2939 this, SLOT( categoryFieldActivated( const QString & ) ) );
2856 initIcons = true; 2940 initIcons = true;
2857 } 2941 }
2858 setCategoryDialogFields(dialog); 2942 setCategoryDialogFields(dialog);
2859 2943
2860#ifdef DESKTOP 2944#ifdef DESKTOP
2861#ifndef WIN32 2945#ifndef WIN32
2862 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); 2946 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
2863#else 2947#else
2864 // read all categories from the config file and store 2948 // read all categories from the config file and store
2865 // into a list 2949 // into a list
2866 QFile f (cfgFile); 2950 QFile f (cfgFile);
2867 QStringList list; 2951 QStringList list;
2868 if ( f.open(IO_ReadOnly) ) { // file opened successfully 2952 if ( f.open(IO_ReadOnly) ) { // file opened successfully
2869 QTextStream t( &f ); // use a text stream 2953 QTextStream t( &f ); // use a text stream
2870 QString s; 2954 QString s;
2871 int n = 1; 2955 int n = 1;
2872 while ( !t.eof() ) { // until end of file... 2956 while ( !t.eof() ) { // until end of file...
2873 s = t.readLine(); // line of text excluding '\n' 2957 s = t.readLine(); // line of text excluding '\n'
2874 list.append(s); 2958 list.append(s);
2875 } 2959 }
2876 f.close(); 2960 f.close();
2877 } 2961 }
2878#endif 2962#endif
2879#else 2963#else
2880 // read all categories from the config file and store 2964 // read all categories from the config file and store
2881 // into a list 2965 // into a list
2882 QFile f (cfgFile); 2966 QFile f (cfgFile);
2883 QStringList list; 2967 QStringList list;
2884 if ( f.open(IO_ReadOnly) ) { // file opened successfully 2968 if ( f.open(IO_ReadOnly) ) { // file opened successfully
2885 QTextStream t( &f ); // use a text stream 2969 QTextStream t( &f ); // use a text stream
2886 QString s; 2970 QString s;
2887 while ( !t.eof() ) { // until end of file... 2971 while ( !t.eof() ) { // until end of file...
2888 s = t.readLine(); // line of text excluding '\n' 2972 s = t.readLine(); // line of text excluding '\n'
2889 list.append(s); 2973 list.append(s);
2890 } 2974 }
2891 f.close(); 2975 f.close();
2892 } 2976 }
2893#endif 2977#endif
2894 QStringList::Iterator it = list.begin(); 2978 QStringList::Iterator it = list.begin();
2895 QString categ; 2979 QString categ;
2896 dialog->CategoryField->clear(); // remove all items 2980 dialog->CategoryField->clear(); // remove all items
2897 int i=0; 2981 int i=0;
2898 bool foundCategory = false; 2982 bool foundCategory = false;
2899 while( it != list.end() ) 2983 while( it != list.end() )
2900 { 2984 {