fixed d'n'd drawing errors in group view (dirty work-around),
implemented correct UUIDs for entries git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@97 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
9b6f3c8fce
commit
c980d277f2
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;j<Entries.size();j++){
|
||||
int k;
|
||||
for(k=0;k<16;k++){if(Entries[j].ID[k]!=NewEntry->ID[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;j<Entries.size();j++){
|
||||
int k;
|
||||
for(k=0;k<16;k++){if(Entries[j].ID[k]!=NewEntry.ID[k])k=0;break;}
|
||||
if(k==15)used=true;}
|
||||
if(used==false)break;
|
||||
}}
|
||||
NewEntry.sID=0;
|
||||
NewEntry.Uuid.generate();
|
||||
}
|
||||
else{
|
||||
NewEntry.Uuid.generate();
|
||||
NewEntry.sID=Entries.back().sID+1;
|
||||
}
|
||||
Entries.push_back(NewEntry);
|
||||
return &Entries.back();
|
||||
}
|
||||
|
@ -612,12 +598,10 @@ entry->GroupID=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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue