Edit/Clone/Delete Entries (qt4)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@25 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent aa615d2ed6
commit 77524c5b93
  1. 11
      src/PwManager.cpp
  2. 1
      src/PwManager.h
  3. 41
      src/lib/EntryView.cpp
  4. 1
      src/lib/EntryView.h
  5. 2
      src/main.cpp
  6. 28
      src/mainwindow.cpp
  7. 3
      src/mainwindow.h

@ -420,6 +420,17 @@ entry->GroupID=dst->ID;
}
CEntry* PwDatabase::cloneEntry(CEntry* entry){
CEntry *Dolly=addEntry();
Q_UINT8 ID[16];
Q_UINT32 sid=Dolly->sID;
memcpy(ID,Dolly->ID,16);
*Dolly=*entry;
Dolly->sID=sid;
memcpy(Dolly->ID,ID,16);
return Dolly;
}
bool CGroup::ReadGroupField(Q_UINT16 FieldType, Q_UINT32 FieldSize, Q_UINT8 *pData)
{

@ -63,6 +63,7 @@ public:
int getGroupIndex(unsigned long ID);
int getNumberOfChilds(CGroup* pGroup);
CEntry* cloneEntry(CEntry* pEntry);
void deleteEntry(CEntry* pEntry);
void moveEntry(CEntry* pEntry,CGroup* pDstGroup);
CEntry* addEntry();

@ -84,6 +84,47 @@ for(int i=0; i<Items.size();i++){
}
}
void KeepassEntryView::refreshVisibleItems(){
EntryViewItem *tmp=NULL;
for(int i=0;i<Items.size();i++){
tmp=Items[i];
CEntry* entry=tmp->pEntry;
if(entry->GroupID==CurrentGroup){
int j=0;
if(config.Columns[0]){
tmp->setText(j++,entry->Title);}
if(config.Columns[1]){
if(config.ListView_HideUsernames)
tmp->setText(j++,"******");
else
tmp->setText(j++,entry->UserName);}
if(config.Columns[2]){
tmp->setText(j++,entry->URL);}
if(config.Columns[3]){
if(config.ListView_HidePasswords)
tmp->setText(j++,"******");
else{
tmp->setText(j++,entry->Password.getString());
entry->Password.delRef();}}
if(config.Columns[4]){
tmp->setText(j++,entry->Additional.section('\n',0,0));}
if(config.Columns[5]){
tmp->setText(j++,entry->Expire.toString(DateTimeFormat));}
if(config.Columns[6]){
tmp->setText(j++,entry->Creation.toString(DateTimeFormat));}
if(config.Columns[7]){
tmp->setText(j++,entry->LastMod.toString(DateTimeFormat));}
if(config.Columns[8]){
tmp->setText(j++,entry->LastAccess.toString(DateTimeFormat));}
if(config.Columns[9]){
tmp->setText(j++,entry->BinaryDesc);}
tmp->setIcon(0,EntryIcons[entry->ImageID]);
}
}
}
void KeepassEntryView::updateColumns(){
QStringList cols;
if(config.Columns[0]){

@ -29,6 +29,7 @@ class KeepassEntryView:public QTreeWidget{
public:
KeepassEntryView(QWidget* parent=0);
void updateItems();
void refreshVisibleItems();
void setCurrentGroup(uint GroupID);
void updateColumns();
PwDatabase* db;

@ -269,7 +269,7 @@ int i=1;
i++; }
for(i; i<argc;i++){
if(QString(argv[i])=="-h"){
cout << "Keepass 0.1.3 (Alpha)" << endl;
cout << "Keepass 0.2.0" << endl;
cout << "Usage: keepass [Filename] [Options]" << endl;
cout << " -h This Help" << endl;
cout << " -cfg ConfigFile Use specified configuration" << endl;

@ -83,6 +83,9 @@ void KeepassMainWindow::setupConnections(){
connect(EditEditGroupAction, SIGNAL(triggered()), this, SLOT(OnEditEditGroup()));
connect(EditDeleteGroupAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteGroup()));
connect(EditNewEntryAction, SIGNAL(triggered()), this, SLOT(OnEditNewEntry()));
connect(EditEditEntryAction, SIGNAL(triggered()), this, SLOT(OnEditEditEntry()));
connect(EditCloneEntryAction, SIGNAL(triggered()), this, SLOT(OnEditCloneEntry()));
connect(EditDeleteEntryAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteEntry()));
connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this,
SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
@ -235,6 +238,7 @@ else{
void KeepassMainWindow::editEntry(CEntry* pEntry){
CEditEntryDlg dlg(db,pEntry,this,"EditEntryDialog",true);
dlg.exec();
EntryView->refreshVisibleItems();
if(dlg.ModFlag)setStateFileModified(true);
}
@ -425,7 +429,31 @@ if(dlg.exec()){
EntryView->updateItems();
setStateFileModified(true);
}
}
void KeepassMainWindow::OnEditEditEntry(){
Q_ASSERT(EntryView->selectedItems().size()==1);
editEntry(static_cast<EntryViewItem*>(EntryView->selectedItems()[0])->pEntry);
}
void KeepassMainWindow::OnEditCloneEntry(){
Q_ASSERT(EntryView->selectedItems().size()>0);
QList<QTreeWidgetItem*> entries=EntryView->selectedItems();
for(int i=0; i<entries.size();i++){
db->cloneEntry(((EntryViewItem*)entries[i])->pEntry);
}
setStateFileModified(true);
EntryView->updateItems();
}
void KeepassMainWindow::OnEditDeleteEntry(){
Q_ASSERT(EntryView->selectedItems().size()>0);
QList<QTreeWidgetItem*> entries=EntryView->selectedItems();
for(int i=0; i<entries.size();i++){
db->deleteEntry(((EntryViewItem*)entries[i])->pEntry);
}
setStateFileModified(true);
EntryView->updateItems();
}
CGroup* KeepassMainWindow::currentGroup(){

@ -65,6 +65,9 @@ private slots:
void OnEditEditGroup();
void OnEditDeleteGroup();
void OnEditNewEntry();
void OnEditEditEntry();
void OnEditCloneEntry();
void OnEditDeleteEntry();
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column);
void OnEntrySelectionChanged();