event handler for MainWindow X-Button

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@39 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent 61d445475a
commit 69c3c401dd
  1. 2
      src/lib/GroupView.cpp
  2. 9
      src/lib/GroupView.h
  3. 14
      src/mainwindow.cpp
  4. 3
      src/mainwindow.h

@ -111,13 +111,13 @@ update();
void KeepassGroupView::dropEvent( QDropEvent * event ){
emit fileModified();
InsertionMarker=QLine();
if(LastHoverItem){
QFont f=LastHoverItem->font(0);
f.setBold(false);
LastHoverItem->setFont(0,f);
LastHoverItem=NULL;
}
GroupViewItem* item=(GroupViewItem*)itemAt(event->pos());
if(item){

@ -21,12 +21,14 @@
#define _GROUP_VIEW_H_
#include <QTreeWidget>
#include <QLine>
#include "../PwManager.h"
class GroupViewItem;
typedef vector<GroupViewItem*>::iterator GroupItemItr;
class KeepassGroupView:public QTreeWidget{
Q_OBJECT
public:
KeepassGroupView(QWidget* parent=0);
void updateItems();
@ -35,6 +37,10 @@ public:
PwDatabase *db;
bool ShowSearchGroup; //needs a "updateItems()" after a change!
vector<GroupViewItem*>Items;
signals:
void fileModified();
protected:
virtual void dragEnterEvent ( QDragEnterEvent * event );
virtual void dragMoveEvent ( QDragMoveEvent * event );
@ -44,15 +50,12 @@ protected:
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void paintEvent ( QPaintEvent * event );
private:
QLine InsertionMarker;
QPoint DragStartPos;
QPixmap DragPixmap;
GroupViewItem* DragItem;
GroupViewItem* LastHoverItem;
GroupViewItem* getLastSameLevelItem(int level);
};

@ -148,6 +148,7 @@ void KeepassMainWindow::setupConnections(){
SLOT(OnEntryItemDoubleClicked(QTreeWidgetItem*,int)));
connect(EntryView,SIGNAL(itemSelectionChanged()), this, SLOT(OnEntrySelectionChanged()));
connect(GroupView,SIGNAL(itemSelectionChanged()), this, SLOT(OnGroupSelectionChanged()));
connect(GroupView,SIGNAL(fileModified()),this,SLOT(OnFileModified()));
connect(QuickSearchEdit,SIGNAL(returnPressed()), this, SLOT(OnQuickSearch()));
}
@ -231,7 +232,7 @@ Q_ASSERT(FileOpen);
Q_ASSERT(db!=NULL);
if(ModFlag){
int r=QMessageBox::question(this,trUtf8("Geänderte Datei speichern?"),
trUtf8("Die aktuell geöffnete Datei wurde verändert. Sollen die Änderungen vor dem Schließen gespeichert werden?"),tr("Ja"),tr("Nein"),tr("Abbrechen"),2,2);
trUtf8("Die aktuell geöffnete Datei wurde verändert. Sollen die Änderungen\nvor dem Schließen gespeichert werden?"),tr("Ja"),tr("Nein"),tr("Abbrechen"),2,2);
if(r==2)return false; //Abbrechen
if(r==0) //Ja (Datei speichern)
if(!OnFileSave())return false;
@ -697,3 +698,14 @@ EntryView->updateItems();
void KeepassMainWindow::OnFileModified(){
setStateFileModified(true);
}
void KeepassMainWindow::closeEvent(QCloseEvent* e){
if(FileOpen){
if(!closeDatabase())
e->ignore();
else
e->accept();
}
else
e->accept();
}

@ -110,7 +110,8 @@ private:
inline CEntry* currentEntry();
QLineEdit* QuickSearchEdit;
protected:
void closeEvent(QCloseEvent* event);