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