diff --git a/changelog b/changelog index 93135d1..0407969 100644 --- a/changelog +++ b/changelog @@ -4,6 +4,9 @@ -fixed crash when parsing config file under Win32 -fixed loss of entry icons when saving a database which was not created with KeePassX (no KPX_CUSTOM_ICONS metastream) +-removed all old Qt3 support dependecies +-implemented correct UUID management for entries +-fixed drawing errors when performing drag and drop operations in group view -when there is no translation installed for the system's country preference but one for the same language the program will now use it -when canceling the file dialog for the opening of an existing database a already diff --git a/src/Database.cpp b/src/Database.cpp index ec04738..4007e9b 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -22,9 +22,12 @@ #include "lib/random.h" KpxUuid::KpxUuid(){ - generate(); + Data.fill(0,16); } +KpxUuid::KpxUuid(const void* src){ + fromRaw(src); +} void KpxUuid::generate(){ char uuid[16]; @@ -54,11 +57,11 @@ QString KpxUuid::toString()const{ .arg(hex.mid(20,12)); } -void KpxUuid::toRaw(void* dst){ +void KpxUuid::toRaw(void* dst)const{ memcpy(dst,Data.data(),16); } -void KpxUuid::fromRaw(void* src){ +void KpxUuid::fromRaw(const void* src){ Data=QByteArray((char*)src,16); } diff --git a/src/Database.h b/src/Database.h index 5d5ea9c..c1584b2 100644 --- a/src/Database.h +++ b/src/Database.h @@ -33,15 +33,16 @@ extern const QDateTime Date_Never; class KpxUuid{ public: KpxUuid(); - bool operator==(const KpxUuid&) const; - bool operator!=(const KpxUuid&) const; + KpxUuid(const void* src); + void generate(); QString toString() const; const unsigned char* data()const {return (const unsigned char*) Data.data();} - void toRaw(void* dst); - void fromRaw(void* src); + void toRaw(void* dst)const; + void fromRaw(const void* src); + bool operator==(const KpxUuid&) const; + bool operator!=(const KpxUuid&) const; private: - void generate(); QByteArray Data; }; @@ -59,7 +60,7 @@ class CEntry{ public: CEntry(); ~CEntry(); -quint8 ID[16]; +KpxUuid Uuid; quint32 sID; quint32 GroupID; quint32 ImageID; diff --git a/src/PwManager.cpp b/src/PwManager.cpp index 3f70471..de1177f 100755 --- a/src/PwManager.cpp +++ b/src/PwManager.cpp @@ -483,20 +483,13 @@ return true; CEntry* PwDatabase::addEntry(CEntry* NewEntry){ if(Entries.size()==0){ - NewEntry->sID=0; - getRandomBytes(&NewEntry->ID,16,1,false); - } - else { - NewEntry->sID=Entries.back().sID+1; - while(1){ - bool used=false; - getRandomBytes(&NewEntry->ID,16,1,false); - for(int j=0;jID[k])k=0;break;} - if(k==15)used=true;} - if(used==false)break; - }} + NewEntry->sID=0; + NewEntry->Uuid.generate(); +} +else{ + NewEntry->sID=Entries.back().sID+1; + NewEntry->Uuid.generate(); +} Entries.push_back(*NewEntry); return &Entries.back(); } @@ -505,20 +498,13 @@ return &Entries.back(); CEntry* PwDatabase::addEntry(){ CEntry NewEntry; if(Entries.size()==0){ - NewEntry.sID=0; - getRandomBytes(&NewEntry.ID,16,1,false); - } - else { - NewEntry.sID=Entries.back().sID+1; - while(1){ - bool used=false; - getRandomBytes(&NewEntry.ID,16,1,false); - for(int j=0;jGroupID=dst->ID; CEntry* PwDatabase::cloneEntry(CEntry* entry){ CEntry *Dolly=addEntry(); -quint8 ID[16]; quint32 sid=Dolly->sID; -memcpy(ID,Dolly->ID,16); *Dolly=*entry; Dolly->sID=sid; -memcpy(Dolly->ID,ID,16); +Dolly->Uuid.generate(); return Dolly; } @@ -685,7 +669,7 @@ switch(FieldType) // Ignore field break; case 0x0001: - memcpy(ID, pData, 16); + Uuid=KpxUuid(pData); break; case 0x0002: memcpyFromLEnd32(&GroupID, (char*)pData); @@ -894,7 +878,7 @@ for(int i = 0; i < Entries.size(); i++){ FieldType = 0x0001; FieldSize = 16; memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; - memcpy(buffer+pos, &Entries[i].ID, 16); pos += 16; + Entries[i].Uuid.toRaw(buffer+pos); pos += 16; FieldType = 0x0002; FieldSize = 4; memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; @@ -982,7 +966,7 @@ for(int i = 0; i < MetaStreams.size(); i++){ FieldType = 0x0001; FieldSize = 16; memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; - memcpy(buffer+pos, &MetaStreams[i]->ID, 16); pos += 16; + MetaStreams[i]->Uuid.toRaw(buffer+pos); pos += 16; FieldType = 0x0002; FieldSize = 4; memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; @@ -1528,8 +1512,8 @@ void assertGroupsEq(KPTestResults& results, CGroup* left, CGroup* right){ void assertEntriesEq(KPTestResults& results, CEntry* left, CEntry* right){ unsigned long size = 0; - kp_assert(results, memcmp(left->ID, right->ID, sizeof(left->ID)) == 0); - size += sizeof(left->ID); + kp_assert(results, left->Uuid==right->Uuid); + size += sizeof(left->Uuid); kp_assert(results, left->sID == right->sID); size += sizeof(left->sID); diff --git a/src/lib/GroupView.cpp b/src/lib/GroupView.cpp index a76d68a..be1d128 100644 --- a/src/lib/GroupView.cpp +++ b/src/lib/GroupView.cpp @@ -74,6 +74,7 @@ if(LastHoverItem){ LastHoverItem->setFont(0,f); } +QLine LastMarker=InsertionMarker; InsertionMarker=QLine(); if(isSearchResultGroup(item)) event->setAccepted(false); @@ -117,7 +118,15 @@ else{ LastHoverItem=NULL; } } - +if(!LastMarker.isNull()){ + ///@FIXME + //this is a very dirty work-around to force a redraw of items at the last marker position + //should be replaced!!! + GroupViewItem* i=(GroupViewItem*)itemAt(0,LastMarker.y1()); + if(i)i->setFont(0,i->font(0)); + i=(GroupViewItem*)itemAt(0,LastMarker.y1()-1); + if(i)i->setFont(0,i->font(0)); +} update(); } @@ -268,8 +277,9 @@ QPen pen(QColor(100,100,100)); pen.setWidth(2); pen.setStyle(Qt::DotLine); painter.setPen(pen); +qDebug("UPDATE: (%i,%i) %ix%i",event->rect().x(),event->rect().y(),event->rect().width(),event->rect().height()); if(!InsertionMarker.isNull()){ -painter.drawLine(InsertionMarker); + painter.drawLine(InsertionMarker); } } diff --git a/src/main.cpp b/src/main.cpp index b504011..d7413a8 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,7 +35,6 @@ #include "PwmConfig.h" #include "PwManager.h" #include "mainwindow.h" -#include "Database.h" using namespace std; #ifdef Q_WS_X11 @@ -83,13 +82,6 @@ bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& Locale int main(int argc, char **argv) { -for(int i=0;i<100;i++){ - KpxUuid id; - cout << (const char*)id.toString().toAscii() << endl; -} - - - QApplication* app=new QApplication(argc,argv); QString ArgFile,ArgCfg,ArgLang,IniFilename; parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);