add/edit/delete group (qt4-reimplementation)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@11 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent 8642ccfe94
commit b2ae2d1d17
  1. 8
      src/dialogs/EditGroupDlg.cpp
  2. 1
      src/dialogs/EditGroupDlg.h
  3. 2
      src/lib/GroupView.cpp
  4. 44
      src/mainwindow.cpp
  5. 3
      src/mainwindow.h

@ -32,6 +32,8 @@ CEditGroupDialog::CEditGroupDialog(QWidget* parent, const char* name, bool modal
{
setupUi(this);
IconID=0;
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
}
CEditGroupDialog::~CEditGroupDialog()
@ -51,14 +53,12 @@ void CEditGroupDialog::OnOK()
{
GroupName=EditTitle->text();
IconID=ComboIconPicker->currentItem();
OK=true;
close();
done(1);
}
void CEditGroupDialog::OnCancel()
{
OK=false;
close();
done(0);
}

@ -45,7 +45,6 @@ protected slots:
public:
int IconID;
QString GroupName;
bool OK;
public slots:

@ -104,6 +104,8 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
}
void KeepassGroupView::updateItems(){
clear();
Items.clear();
for(GroupItr i=db->Groups.begin();i!=db->Groups.end();i++){
if((*i).Level==0){
if(Items.size()) Items.push_back(new GroupViewItem(this,getLastSameLevelItem(0)));

@ -78,6 +78,11 @@ void KeepassMainWindow::setupConnections(){
connect(FileExitAction, SIGNAL(triggered()), this, SLOT(OnFileExit()));
connect(FileImpPwmAction, SIGNAL(triggered()), this, SLOT(OnImportFromPwm()));
connect(FileImpKWalletXmlAction, SIGNAL(triggered()), this,SLOT(OnImportFromKWalletXml()));
connect(EditNewGroupAction, SIGNAL(triggered()), this, SLOT(OnEditNewGroup()));
connect(EditEditGroupAction, SIGNAL(triggered()), this, SLOT(OnEditEditGroup()));
connect(EditDeleteGroupAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteGroup()));
connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this,
SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
connect(EntryView,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,
@ -368,4 +373,43 @@ if(GroupView->selectedItems().size()==0)
if(GroupView->selectedItems().size()==1)
setStateGroupSelected(SINGLE);
Q_ASSERT(GroupView->selectedItems().size()<=1);
}
void KeepassMainWindow::OnEditNewGroup(){
CGroup *pNew=NULL;
if(GroupView->selectedItems().size())
pNew=db->addGroup(static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup);
else
pNew=db->addGroup(NULL);
CEditGroupDialog dlg(this,"EditGroupDlg",true);
if(!dlg.exec()){
db->deleteGroup(pNew);
return;
}
pNew->Name=dlg.GroupName;
pNew->ImageID=dlg.IconID;
setStateFileModified(true);
GroupView->updateItems();
}
void KeepassMainWindow::OnEditEditGroup(){
Q_ASSERT(GroupView->selectedItems().size());
CGroup *pGroup=static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup;
CEditGroupDialog dlg(this,"EditGroupDlg",true);
dlg.GroupName=pGroup->Name;
dlg.IconID=pGroup->ImageID;
if(!dlg.exec())return;
if((pGroup->Name != dlg.GroupName) || (pGroup->ImageID != dlg.IconID)){
setStateFileModified(true);
pGroup->Name = dlg.GroupName;
pGroup->ImageID = dlg.IconID;
GroupView->updateItems();
}
}
void KeepassMainWindow::OnEditDeleteGroup(){
Q_ASSERT(GroupView->selectedItems().size());
CGroup *pGroup=static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup;
db->deleteGroup(pGroup);
GroupView->updateItems();
}

@ -61,6 +61,9 @@ private slots:
void OnFileExit();
void OnImportFromPwm();
void OnImportFromKWalletXml();
void OnEditNewGroup();
void OnEditEditGroup();
void OnEditDeleteGroup();
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column);
void OnEntrySelectionChanged();