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 ){ void KeepassGroupView::dropEvent( QDropEvent * event ){
emit fileModified();
InsertionMarker=QLine(); InsertionMarker=QLine();
if(LastHoverItem){ if(LastHoverItem){
QFont f=LastHoverItem->font(0); QFont f=LastHoverItem->font(0);
f.setBold(false); f.setBold(false);
LastHoverItem->setFont(0,f); LastHoverItem->setFont(0,f);
LastHoverItem=NULL; LastHoverItem=NULL;
} }
GroupViewItem* item=(GroupViewItem*)itemAt(event->pos()); GroupViewItem* item=(GroupViewItem*)itemAt(event->pos());
if(item){ if(item){

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

@ -148,6 +148,7 @@ void KeepassMainWindow::setupConnections(){
SLOT(OnEntryItemDoubleClicked(QTreeWidgetItem*,int))); SLOT(OnEntryItemDoubleClicked(QTreeWidgetItem*,int)));
connect(EntryView,SIGNAL(itemSelectionChanged()), this, SLOT(OnEntrySelectionChanged())); connect(EntryView,SIGNAL(itemSelectionChanged()), this, SLOT(OnEntrySelectionChanged()));
connect(GroupView,SIGNAL(itemSelectionChanged()), this, SLOT(OnGroupSelectionChanged())); connect(GroupView,SIGNAL(itemSelectionChanged()), this, SLOT(OnGroupSelectionChanged()));
connect(GroupView,SIGNAL(fileModified()),this,SLOT(OnFileModified()));
connect(QuickSearchEdit,SIGNAL(returnPressed()), this, SLOT(OnQuickSearch())); connect(QuickSearchEdit,SIGNAL(returnPressed()), this, SLOT(OnQuickSearch()));
} }
@ -231,7 +232,7 @@ Q_ASSERT(FileOpen);
Q_ASSERT(db!=NULL); Q_ASSERT(db!=NULL);
if(ModFlag){ if(ModFlag){
int r=QMessageBox::question(this,trUtf8("Geänderte Datei speichern?"), 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==2)return false; //Abbrechen
if(r==0) //Ja (Datei speichern) if(r==0) //Ja (Datei speichern)
if(!OnFileSave())return false; if(!OnFileSave())return false;
@ -697,3 +698,14 @@ EntryView->updateItems();
void KeepassMainWindow::OnFileModified(){ void KeepassMainWindow::OnFileModified(){
setStateFileModified(true); 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(); inline CEntry* currentEntry();
QLineEdit* QuickSearchEdit; QLineEdit* QuickSearchEdit;
protected:
void closeEvent(QCloseEvent* event);