summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2004-08-07 10:17:12 (UTC)
committer zautrix <zautrix>2004-08-07 10:17:12 (UTC)
commit55ad0e5d505055016a0e5032bcc8f9355dfff210 (patch) (unidiff)
treebcc301581fe1ba78fc7fe48a1c3b4302d8756c43 /microkde
parent6f6b27941ae0ba9436660c5ac757d21c63c677fc (diff)
downloadkdepimpi-55ad0e5d505055016a0e5032bcc8f9355dfff210.zip
kdepimpi-55ad0e5d505055016a0e5032bcc8f9355dfff210.tar.gz
kdepimpi-55ad0e5d505055016a0e5032bcc8f9355dfff210.tar.bz2
idmanager implemented
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kidmanager.cpp130
-rw-r--r--microkde/kidmanager.h7
2 files changed, 134 insertions, 3 deletions
diff --git a/microkde/kidmanager.cpp b/microkde/kidmanager.cpp
index ce6184a..d24a41f 100644
--- a/microkde/kidmanager.cpp
+++ b/microkde/kidmanager.cpp
@@ -1,10 +1,136 @@
1#include "kidmanager.h" 1#include "kidmanager.h"
2 2
3KIdManager::KIdManager() 3KIdManager::KIdManager()
4{ 4{
5 5
6} 6}
7QString KIdManager::addId (const QString& idString,const QString& id,const QString& idvalue ) 7// :profilename;12;id_withLen12;123456:
8// 123456 is the csum
9QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue )
8{ 10{
9 11 int startProf;
12 int startIDnum;
13 int startIDnumlen;
14 int startID;
15 int lenID;
16 int startCsum;
17 int lenCsum;
18 int endall;
19 QString newIDString;
20 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) {
21 newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum );
22 } else {
23 newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:";
24 }
25 qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() );
26 return newIDString;
27}
28QString KIdManager::getId (const QString& idString,const QString& prof )
29{
30 int startProf;
31 int startIDnum;
32 int startIDnumlen;
33 int startID;
34 int lenID;
35 int startCsum;
36 int lenCsum;
37 int endall;
38 QString idval = "";
39 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) )
40 idval = idString.mid( startID, lenID );
41
42 qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() );
43 return idval;
44
45}
46
47QString KIdManager::removeId (const QString& idString,const QString& prof )
48{
49 int startProf;
50 int startIDnum;
51 int startIDnumlen;
52 int startID;
53 int lenID;
54 int startCsum;
55 int lenCsum;
56 int endall;
57 QString newIDString;
58 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) {
59 newIDString = idString.left(startProf) + idString.mid( endall );
60 } else {
61 newIDString = idString;
62 }
63 qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() );
64 return newIDString;
65}
66
67QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum )
68{
69 int startProf;
70 int startIDnum;
71 int startIDnumlen;
72 int startID;
73 int lenID;
74 int startCsum;
75 int lenCsum;
76 int endall;
77 QString newIDString;
78 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) {
79 newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1);
80 } else {
81 newIDString = idString + prof + ";3;_u_;"+ idCsum + ":";
82 }
83 qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() );
84 return newIDString;
85}
86QString KIdManager::getCsum (const QString& idString,const QString& prof )
87{
88 int startProf;
89 int startIDnum;
90 int startIDnumlen;
91 int startID;
92 int lenID;
93 int startCsum;
94 int lenCsum;
95 int endall;
96 QString idval = "";
97 if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) )
98 idval = idString.mid( startCsum, lenCsum );
99
100 qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() );
101 return idval;
102}
103// :profilename;12;id_withLen12;123456:
104bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall)
105{
106 startProf = idString.find( ":"+prof+";" );
107 if ( startProf >= 0 ) {
108 startIDnum = prof.length()+2+startProf;
109 startID = idString.find( ";", startIDnum ) +1;
110 startIDnumlen = startID - startIDnum - 1;
111 if ( startIDnum > 0 ) {
112 bool ok;
113 lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok );
114 if (ok) {
115 startCsum = startID+lenID+1;
116 endall = idString.find( ":", startCsum )-1;
117 if ( endall < 0 ) {
118 qDebug("Error getNumbers: andall not found ");
119 return false;
120 }
121 lenCsum = endall-startCsum+1;
122 }
123 else {
124 qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).toInt( &ok ));
125 return false;
126 }
127 } else {
128 qDebug("Error in KIdManager::getNumbers.startIDnum <= 0");
129 return false;
130 }
131 } else {
132 qDebug("getnumbers: profile not found *%s* ",prof.latin1() );
133 return false;
134 }
135 return true;
10} 136}
diff --git a/microkde/kidmanager.h b/microkde/kidmanager.h
index 9d79b2b..00580a0 100644
--- a/microkde/kidmanager.h
+++ b/microkde/kidmanager.h
@@ -6,13 +6,18 @@
6#include <qobject.h> 6#include <qobject.h>
7class KIdManager : public QObject 7class KIdManager : public QObject
8{ 8{
9Q_OBJECT 9Q_OBJECT
10 public: 10 public:
11 KIdManager( ); 11 KIdManager( );
12 static QString addId (const QString& idString,const QString& id,const QString& idvalue ) ; 12 static QString setId (const QString& idString,const QString& id,const QString& idvalue ) ;
13 static QString getId (const QString& idString,const QString& id ) ;
14 static QString removeId (const QString& idString,const QString& id ) ;
15 static QString setCsum (const QString& idString,const QString& id,const QString& idvalue ) ;
16 static QString getCsum (const QString& idString,const QString& id ) ;
17 static bool getNumbers (const QString& idString,const QString& id, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) ;
13 private: 18 private:
14 19
15private slots: 20private slots:
16}; 21};
17 22
18 23