Edit/Clone/Delete Entries (qt4)
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@25 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
		
							parent
							
								
									aa615d2ed6
								
							
						
					
					
						commit
						77524c5b93
					
				|  | @ -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) | bool CGroup::ReadGroupField(Q_UINT16 FieldType, Q_UINT32 FieldSize, Q_UINT8 *pData) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -63,6 +63,7 @@ public: | ||||||
|  int       getGroupIndex(unsigned long ID); |  int       getGroupIndex(unsigned long ID); | ||||||
|  int	   getNumberOfChilds(CGroup* pGroup); |  int	   getNumberOfChilds(CGroup* pGroup); | ||||||
| 
 | 
 | ||||||
|  |  CEntry*   cloneEntry(CEntry* pEntry); | ||||||
|  void      deleteEntry(CEntry* pEntry); |  void      deleteEntry(CEntry* pEntry); | ||||||
|  void      moveEntry(CEntry* pEntry,CGroup* pDstGroup); |  void      moveEntry(CEntry* pEntry,CGroup* pDstGroup); | ||||||
|  CEntry*   addEntry(); |  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(){ | void KeepassEntryView::updateColumns(){ | ||||||
| QStringList cols; | QStringList cols; | ||||||
| if(config.Columns[0]){ | if(config.Columns[0]){ | ||||||
|  |  | ||||||
|  | @ -29,6 +29,7 @@ class KeepassEntryView:public QTreeWidget{ | ||||||
| public: | public: | ||||||
|  KeepassEntryView(QWidget* parent=0); |  KeepassEntryView(QWidget* parent=0); | ||||||
|  void updateItems(); |  void updateItems(); | ||||||
|  |  void refreshVisibleItems(); | ||||||
|  void setCurrentGroup(uint GroupID); |  void setCurrentGroup(uint GroupID); | ||||||
|  void updateColumns(); |  void updateColumns(); | ||||||
|  PwDatabase* db; |  PwDatabase* db; | ||||||
|  |  | ||||||
|  | @ -269,7 +269,7 @@ int i=1; | ||||||
| 		i++; } | 		i++; } | ||||||
| 	for(i; i<argc;i++){ | 	for(i; i<argc;i++){ | ||||||
| 		if(QString(argv[i])=="-h"){ | 		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 << "Usage: keepass [Filename] [Options]" << endl; | ||||||
| 			cout << "  -h This Help" << endl; | 			cout << "  -h This Help" << endl; | ||||||
| 			cout << "  -cfg ConfigFile Use specified configuration" << endl; | 			cout << "  -cfg ConfigFile Use specified configuration" << endl; | ||||||
|  |  | ||||||
|  | @ -83,6 +83,9 @@ void KeepassMainWindow::setupConnections(){ | ||||||
|    connect(EditEditGroupAction, SIGNAL(triggered()), this, SLOT(OnEditEditGroup())); |    connect(EditEditGroupAction, SIGNAL(triggered()), this, SLOT(OnEditEditGroup())); | ||||||
|    connect(EditDeleteGroupAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteGroup())); |    connect(EditDeleteGroupAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteGroup())); | ||||||
|    connect(EditNewEntryAction, SIGNAL(triggered()), this, SLOT(OnEditNewEntry())); |    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, |    connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this, | ||||||
| 		   SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*))); | 		   SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*))); | ||||||
|  | @ -235,6 +238,7 @@ else{ | ||||||
| void KeepassMainWindow::editEntry(CEntry* pEntry){ | void KeepassMainWindow::editEntry(CEntry* pEntry){ | ||||||
| CEditEntryDlg dlg(db,pEntry,this,"EditEntryDialog",true); | CEditEntryDlg dlg(db,pEntry,this,"EditEntryDialog",true); | ||||||
| dlg.exec(); | dlg.exec(); | ||||||
|  | EntryView->refreshVisibleItems(); | ||||||
| if(dlg.ModFlag)setStateFileModified(true); | if(dlg.ModFlag)setStateFileModified(true); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -425,7 +429,31 @@ if(dlg.exec()){ | ||||||
|  EntryView->updateItems(); |  EntryView->updateItems(); | ||||||
|  setStateFileModified(true); |  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(){ | CGroup* KeepassMainWindow::currentGroup(){ | ||||||
|  |  | ||||||
|  | @ -65,6 +65,9 @@ private slots: | ||||||
|    void OnEditEditGroup(); |    void OnEditEditGroup(); | ||||||
|    void OnEditDeleteGroup(); |    void OnEditDeleteGroup(); | ||||||
|    void OnEditNewEntry(); |    void OnEditNewEntry(); | ||||||
|  |    void OnEditEditEntry(); | ||||||
|  |    void OnEditCloneEntry(); | ||||||
|  |    void OnEditDeleteEntry(); | ||||||
|    void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*); |    void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*); | ||||||
|    void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column); |    void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column); | ||||||
|    void OnEntrySelectionChanged(); |    void OnEntrySelectionChanged(); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 tariq
						tariq