Add Entry (qt4)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@24 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent aeeba6a916
commit aa615d2ed6
  1. 2
      src/Database.cpp
  2. 9
      src/PwManager.cpp
  3. 1
      src/PwManager.h
  4. 3
      src/lib/EntryView.cpp
  5. 2
      src/lib/GroupView.cpp
  6. 20
      src/mainwindow.cpp
  7. 2
      src/mainwindow.h

@ -27,7 +27,7 @@ GroupID=0;
Creation=QDateTime::currentDateTime();
LastMod=QDateTime::currentDateTime();
LastAccess=QDateTime::currentDateTime();
Expire=QDateTime(QDate(2999,12,28),QTime(23,59,59));
Expire=QDateTime(QDate(2999,12,28),QTime(23,59,59)); //Never
BinaryDataLength=0;
pBinaryData=NULL;
}

@ -309,6 +309,12 @@ return true;
}
void PwDatabase::addEntry(CEntry* NewEntry){
CEntry *entry=addEntry();
*entry=*NewEntry;
}
CEntry* PwDatabase::addEntry(){
CEntry NewEntry;
if(Entries.size()==0){
@ -316,7 +322,7 @@ if(Entries.size()==0){
getRandomBytes(&NewEntry.ID,16,1,false);
}
else {
NewEntry.sID=(*(Entries.end()-1)).sID+1;
NewEntry.sID=Entries.back().sID+1;
while(1){
bool used=false;
getRandomBytes(&NewEntry.ID,16,1,false);
@ -846,7 +852,6 @@ for(i=GroupIndex+1; i<Groups.size(); i++){
if(Groups[i].Level<=group->Level)break;
}
NumChilds=i-GroupIndex-1;
qDebug("NUMCHILDS=%i\n",NumChilds);
//delete entries
for(i=GroupIndex; i<=GroupIndex+NumChilds; i++){
for(int j=0; j<Entries.size();){

@ -66,6 +66,7 @@ public:
void deleteEntry(CEntry* pEntry);
void moveEntry(CEntry* pEntry,CGroup* pDstGroup);
CEntry* addEntry();
void addEntry(CEntry* NewEntry);
void merge(PwDatabase* db2);
bool isParentGroup(CGroup* Group,CGroup* PotenialParent);
QString getError(); //get first error

@ -36,6 +36,7 @@ header()->setResizeMode(QHeaderView::Stretch);
void KeepassEntryView::updateItems(){
clear();
Items.clear();
if(!db)return;
EntryViewItem *tmp=NULL;
for(int i=0;i<db->Entries.size();i++){
@ -72,9 +73,11 @@ for(int i=0;i<db->Entries.size();i++){
tmp->setText(j++,entry->BinaryDesc);}
Items.back()->setIcon(0,EntryIcons[entry->ImageID]);
}
setCurrentGroup(CurrentGroup);
}
void KeepassEntryView::setCurrentGroup(uint id){
CurrentGroup=id;
for(int i=0; i<Items.size();i++){
setItemHidden(Items[i],(Items[i]->pEntry->GroupID != id));

@ -164,8 +164,6 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
drag->setMimeData(mimeData);
drag->setPixmap(DragPixmap);
drag->start();
}
void KeepassGroupView::updateItems(){

@ -82,6 +82,7 @@ void KeepassMainWindow::setupConnections(){
connect(EditNewGroupAction, SIGNAL(triggered()), this, SLOT(OnEditNewGroup()));
connect(EditEditGroupAction, SIGNAL(triggered()), this, SLOT(OnEditEditGroup()));
connect(EditDeleteGroupAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteGroup()));
connect(EditNewEntryAction, SIGNAL(triggered()), this, SLOT(OnEditNewEntry()));
connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this,
SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
@ -265,7 +266,7 @@ default: Q_ASSERT(false);
}
void KeepassMainWindow::setStateEntrySelected(SelectionState s){
EntrySelection=NONE;
EntrySelection=s;
switch(EntrySelection){
case NONE:
EditPasswordToClipboardAction->setEnabled(false);
@ -414,3 +415,20 @@ db->deleteGroup(pGroup);
GroupView->updateItems();
setStateFileModified(true);
}
void KeepassMainWindow::OnEditNewEntry(){
CEntry NewEntry;
NewEntry.GroupID=currentGroup()->ID;
CEditEntryDlg dlg(db,&NewEntry,this,"EditEntryDialog",true);
if(dlg.exec()){
db->addEntry(&NewEntry);
EntryView->updateItems();
setStateFileModified(true);
}
}
CGroup* KeepassMainWindow::currentGroup(){
Q_ASSERT(GroupView->selectedItems().size());
return static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup;
}

@ -64,6 +64,7 @@ private slots:
void OnEditNewGroup();
void OnEditEditGroup();
void OnEditDeleteGroup();
void OnEditNewEntry();
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column);
void OnEntrySelectionChanged();
@ -84,6 +85,7 @@ private:
void openDatabase(QString filename);
bool closeDatabase();
void editEntry(CEntry* pEntry);
inline CGroup* currentGroup();