summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp
index 298581a..41b3008 100644
--- a/library/applnk.cpp
+++ b/library/applnk.cpp
@@ -50,70 +50,73 @@ int AppLnk::lastId = 5000;
50 50
51static int smallSize = 14; 51static int smallSize = 14;
52static int bigSize = 32; 52static int bigSize = 32;
53 53
54static QString safeFileName(const QString& n) 54static QString safeFileName(const QString& n)
55{ 55{
56 QString safename=n; 56 QString safename=n;
57 safename.replace(QRegExp("[^0-9A-Za-z.]"),"_"); 57 safename.replace(QRegExp("[^0-9A-Za-z.]"),"_");
58 safename.replace(QRegExp("^[^A-Za-z]*"),""); 58 safename.replace(QRegExp("^[^A-Za-z]*"),"");
59 if ( safename.isEmpty() ) 59 if ( safename.isEmpty() )
60 safename = "_"; 60 safename = "_";
61 return safename; 61 return safename;
62} 62}
63 63
64static bool prepareDirectories(const QString& lf) 64static bool prepareDirectories(const QString& lf)
65{ 65{
66 if ( !QFile::exists(lf) ) { 66 if ( !QFile::exists(lf) ) {
67 // May need to create directories 67 // May need to create directories
68 QFileInfo fi(lf); 68 QFileInfo fi(lf);
69 if ( system(("mkdir -p "+fi.dirPath(TRUE))) ) 69 if ( system(("mkdir -p "+fi.dirPath(TRUE))) )
70 return FALSE; 70 return FALSE;
71 } 71 }
72 return TRUE; 72 return TRUE;
73} 73}
74 74
75class AppLnkPrivate 75class AppLnkPrivate
76{ 76{
77public: 77public:
78 /* the size of the Pixmap */ 78 /* the size of the Pixmap */
79 enum Size {Normal = 0, Big }; 79 enum Size {Normal = 0, Big };
80 AppLnkPrivate() { 80 AppLnkPrivate() {
81 /* we want one normal and one big item */ 81 /* we want one normal and one big item */
82 mPixmaps = QArray<QPixmap>(2); 82
83 QPixmap pix;
84 mPixmaps.insert(0, pix );
85 mPixmaps.insert(1, pix);
83 } 86 }
84 87
85 QStringList mCatList; // always correct 88 QStringList mCatList; // always correct
86 QArray<int> mCat; // cached value; correct if not empty 89 QArray<int> mCat; // cached value; correct if not empty
87 QArray<QPixmap> mPixmaps; 90 QMap<int, QPixmap> mPixmaps;
88 91
89 void updateCatListFromArray() 92 void updateCatListFromArray()
90 { 93 {
91 Categories cat( 0 ); 94 Categories cat( 0 );
92 cat.load( categoryFileName() ); 95 cat.load( categoryFileName() );
93 mCatList = cat.labels("Document View",mCat); 96 mCatList = cat.labels("Document View",mCat);
94 } 97 }
95 98
96 void setCatArrayDirty() 99 void setCatArrayDirty()
97 { 100 {
98 mCat.resize(0); 101 mCat.resize(0);
99 } 102 }
100 103
101 void ensureCatArray() 104 void ensureCatArray()
102 { 105 {
103 if ( mCat.count() > 0 || mCatList.count()==0 ) 106 if ( mCat.count() > 0 || mCatList.count()==0 )
104 return; 107 return;
105 108
106 Categories cat( 0 ); 109 Categories cat( 0 );
107 cat.load( categoryFileName() ); 110 cat.load( categoryFileName() );
108 mCat.resize( mCatList.count() ); 111 mCat.resize( mCatList.count() );
109 int i; 112 int i;
110 QStringList::ConstIterator it; 113 QStringList::ConstIterator it;
111 for ( i = 0, it = mCatList.begin(); it != mCatList.end(); 114 for ( i = 0, it = mCatList.begin(); it != mCatList.end();
112 ++it, i++ ) { 115 ++it, i++ ) {
113 116
114 bool number; 117 bool number;
115 int id = (*it).toInt( &number ); 118 int id = (*it).toInt( &number );
116 if ( !number ) { 119 if ( !number ) {
117 id = cat.id( "Document View", *it ); 120 id = cat.id( "Document View", *it );
118 if ( id == 0 ) 121 if ( id == 0 )
119 id = cat.addCategory( "Document View", *it ); 122 id = cat.addCategory( "Document View", *it );