finished column resize functionality, fixed wrong qmake-project-file
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@51 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
d6ea6e8971
commit
09ab186b9d
|
@ -163,7 +163,7 @@ if(count > lst.size()){
|
||||||
for(int i=lst.size(); i<count; i++)
|
for(int i=lst.size(); i<count; i++)
|
||||||
values[i]=DEFAULT_INT_VAL;}
|
values[i]=DEFAULT_INT_VAL;}
|
||||||
|
|
||||||
memcpy(dst,values,count);
|
memcpy(dst,values,count*sizeof(int));
|
||||||
delete [] values;
|
delete [] values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QDragMoveEvent>
|
#include <QDragMoveEvent>
|
||||||
#include <QDragLeaveEvent>
|
#include <QDragLeaveEvent>
|
||||||
|
@ -32,14 +32,28 @@
|
||||||
|
|
||||||
|
|
||||||
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
|
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
|
||||||
|
AutoResizeColumns=true;
|
||||||
|
int sum=0;
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++)
|
||||||
|
sum+=config.ColumnSizes[i];
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++)
|
||||||
|
ColumnSizes << (float)config.ColumnSizes[i]/(float)sum;
|
||||||
|
|
||||||
CurrentGroup=0;
|
CurrentGroup=0;
|
||||||
updateColumns();
|
updateColumns();
|
||||||
header()->setResizeMode(QHeaderView::Interactive);
|
header()->setResizeMode(QHeaderView::Interactive);
|
||||||
header()->setStretchLastSection(false);
|
header()->setStretchLastSection(false);
|
||||||
|
connect(header(),SIGNAL(sectionResized(int,int,int)),this,SLOT(OnColumnResized(int,int,int)));
|
||||||
ContextMenu=new QMenu(this);
|
ContextMenu=new QMenu(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeepassEntryView::~KeepassEntryView(){
|
||||||
|
for(int i=0;i<ColumnSizes.size();i++){
|
||||||
|
config.ColumnSizes[i]=round(ColumnSizes[i]*10000.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
|
void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
|
||||||
if(itemAt(e->pos())){
|
if(itemAt(e->pos())){
|
||||||
|
@ -69,7 +83,7 @@ ContextMenu->popup(e->globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::resizeEvent(QResizeEvent* e){
|
void KeepassEntryView::resizeEvent(QResizeEvent* e){
|
||||||
|
resizeColumns();
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +212,81 @@ if(config.Columns[8]){
|
||||||
if(config.Columns[9]){
|
if(config.Columns[9]){
|
||||||
cols << trUtf8("Anhang");}
|
cols << trUtf8("Anhang");}
|
||||||
setHeaderLabels(cols);
|
setHeaderLabels(cols);
|
||||||
|
resizeColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeepassEntryView::resizeColumns(){
|
||||||
|
|
||||||
|
AutoResizeColumns=false;
|
||||||
|
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++)
|
||||||
|
if(!config.Columns[i])ColumnSizes[i]=0;
|
||||||
|
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++)
|
||||||
|
if(config.Columns[i] && ColumnSizes[i]==0)ColumnSizes[i]=0.1f;
|
||||||
|
|
||||||
|
float sum=0;
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++)
|
||||||
|
sum+=ColumnSizes[i];
|
||||||
|
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++)
|
||||||
|
ColumnSizes[i]/=sum;
|
||||||
|
|
||||||
|
int w=viewport()->width();
|
||||||
|
int wx=0; int j=0;
|
||||||
|
|
||||||
|
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++){
|
||||||
|
if(!config.Columns[i])continue;
|
||||||
|
int NewWidth=round(ColumnSizes[i]*(float)w);
|
||||||
|
wx+=NewWidth;
|
||||||
|
header()->resizeSection(j++,NewWidth);
|
||||||
|
//add rounding difference (w-wx) to the last column
|
||||||
|
if(j==header()->count()){
|
||||||
|
header()->resizeSection(j-1,header()->sectionSize(j-1)+(w-wx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoResizeColumns=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KeepassEntryView::OnColumnResized(int index,int Old, int New){
|
||||||
|
if(!AutoResizeColumns)return;
|
||||||
|
|
||||||
|
int i=0; int c=-1;
|
||||||
|
for(i;i<ColumnSizes.size();i++){
|
||||||
|
if(config.Columns[i])c++;
|
||||||
|
if(c==index)break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int j=0; c=-1; bool IsLastColumn=true;
|
||||||
|
for(j;j<ColumnSizes.size();j++){
|
||||||
|
if(config.Columns[j])c++;
|
||||||
|
if(c==(index+1)){IsLastColumn=false; break;}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IsLastColumn){
|
||||||
|
j=0; c=-1;
|
||||||
|
for(j;j<ColumnSizes.size();j++){
|
||||||
|
if(config.Columns[j])c++;
|
||||||
|
if(c==(index-1))break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int w=viewport()->width();
|
||||||
|
float div=(float)(New-Old)/(float)w;
|
||||||
|
|
||||||
|
if(((ColumnSizes[j]-div)*w > 2)){
|
||||||
|
ColumnSizes[j]-=div;
|
||||||
|
ColumnSizes[i]+=div;
|
||||||
|
}
|
||||||
|
resizeColumns();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void KeepassEntryView::paintEvent(QPaintEvent * event){
|
void KeepassEntryView::paintEvent(QPaintEvent * event){
|
||||||
QTreeWidget::paintEvent(event);
|
QTreeWidget::paintEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,19 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
|
#include <QHeaderView>
|
||||||
#include "../PwManager.h"
|
#include "../PwManager.h"
|
||||||
|
|
||||||
|
#define NUM_COLUMNS 10
|
||||||
|
|
||||||
class EntryViewItem;
|
class EntryViewItem;
|
||||||
|
|
||||||
|
|
||||||
class KeepassEntryView:public QTreeWidget{
|
class KeepassEntryView:public QTreeWidget{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
KeepassEntryView(QWidget* parent=0);
|
KeepassEntryView(QWidget* parent=0);
|
||||||
|
~KeepassEntryView();
|
||||||
void updateItems(unsigned int group);
|
void updateItems(unsigned int group);
|
||||||
void refreshItems();
|
void refreshItems();
|
||||||
void updateColumns();
|
void updateColumns();
|
||||||
|
@ -41,10 +47,14 @@ private:
|
||||||
void setEntry(CEntry* entry);
|
void setEntry(CEntry* entry);
|
||||||
int CurrentGroup;
|
int CurrentGroup;
|
||||||
QList<float>ColumnSizes;
|
QList<float>ColumnSizes;
|
||||||
|
void resizeColumns();
|
||||||
|
bool AutoResizeColumns;
|
||||||
protected:
|
protected:
|
||||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||||
virtual void paintEvent(QPaintEvent* event);
|
virtual void paintEvent(QPaintEvent* event);
|
||||||
virtual void resizeEvent(QResizeEvent* event);
|
virtual void resizeEvent(QResizeEvent* event);
|
||||||
|
public slots:
|
||||||
|
void OnColumnResized(int index,int OldSize, int NewSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ SecString::generateSessionKey();
|
||||||
KeepassMainWindow *mainWin = new KeepassMainWindow();
|
KeepassMainWindow *mainWin = new KeepassMainWindow();
|
||||||
mainWin->show();
|
mainWin->show();
|
||||||
int r=app->exec();
|
int r=app->exec();
|
||||||
|
delete mainWin;
|
||||||
if(!config.saveToIni(IniFilename))
|
if(!config.saveToIni(IniFilename))
|
||||||
QMessageBox::warning(NULL,QObject::tr("Warnung"),QObject::trUtf8("Die Konfigurationsdatei konnte nicht gespeichert werden.Stellen Sie sicher, dass\nSie Schreibrechte im Verzeichnis ~/.keepass besitzen."),QObject::tr("OK"),"","",0.0);
|
QMessageBox::warning(NULL,QObject::tr("Warnung"),QObject::trUtf8("Die Konfigurationsdatei konnte nicht gespeichert werden.Stellen Sie sicher, dass\nSie Schreibrechte im Verzeichnis ~/.keepass besitzen."),QObject::tr("OK"),"","",0.0);
|
||||||
delete app;
|
delete app;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QStatusBar>
|
||||||
|
|
||||||
#include "lib/random.h"
|
#include "lib/random.h"
|
||||||
#include "lib/IniReader.h"
|
#include "lib/IniReader.h"
|
||||||
|
@ -71,6 +72,11 @@ KeepassMainWindow::KeepassMainWindow(QWidget *parent, Qt::WFlags flags):QMainWin
|
||||||
setupConnections();
|
setupConnections();
|
||||||
FileOpen=false;
|
FileOpen=false;
|
||||||
Clipboard=QApplication::clipboard();
|
Clipboard=QApplication::clipboard();
|
||||||
|
setStatusBar(new QStatusBar(this));
|
||||||
|
StatusBarGeneral=new QLabel(tr("Bereit"),statusBar());
|
||||||
|
StatusBarSelection=new QLabel(statusBar());
|
||||||
|
statusBar()->addWidget(StatusBarGeneral,30);
|
||||||
|
statusBar()->addWidget(StatusBarSelection,70);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassMainWindow::setupConnections(){
|
void KeepassMainWindow::setupConnections(){
|
||||||
|
|
|
@ -113,6 +113,8 @@ private:
|
||||||
inline CGroup* currentGroup();
|
inline CGroup* currentGroup();
|
||||||
inline CEntry* currentEntry();
|
inline CEntry* currentEntry();
|
||||||
QLineEdit* QuickSearchEdit;
|
QLineEdit* QuickSearchEdit;
|
||||||
|
QLabel* StatusBarGeneral;
|
||||||
|
QLabel* StatusBarSelection;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
|
|
219
src/src.pro
219
src/src.pro
|
@ -1,110 +1,109 @@
|
||||||
# Diese Datei wurde mit dem qmake-Manager von KDevelop erstellt.
|
# Diese Datei wurde mit dem qmake-Manager von KDevelop erstellt.
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Unterordner relativ zum Projektordner: ./src
|
# Unterordner relativ zum Projektordner: ./src
|
||||||
# Das Target ist eine Anwendung: ../bin/keepass
|
# Das Target ist eine Anwendung: ../bin/keepass
|
||||||
|
|
||||||
INSTALLS += Share
|
INSTALLS += target \
|
||||||
Share.files += ../share/keepass/*
|
Share
|
||||||
FORMS += forms/EditGroupDlg.ui \
|
Share.files += ../share/keepass/*
|
||||||
forms/SearchDlg.ui \
|
unix{ target.path = /usr/local/bin
|
||||||
forms/AboutDlg.ui \
|
Share.path = /usr/local/share/keepass
|
||||||
forms/LanguageDlg.ui \
|
}
|
||||||
forms/SettingsDlg.ui \
|
macx{ target.path = /Applications
|
||||||
forms/ChangeKeyDlg.ui \
|
Share.path = /Applications/keepass.app/Contents/share/keepass
|
||||||
forms/MainWindow.ui \
|
}
|
||||||
forms/SimplePasswordDlg.ui \
|
FORMS += forms/EditGroupDlg.ui \
|
||||||
forms/DatabaseSettingsDlg.ui \
|
forms/SearchDlg.ui \
|
||||||
forms/PasswordDlg.ui \
|
forms/AboutDlg.ui \
|
||||||
forms/EditEntryDlg.ui \
|
forms/LanguageDlg.ui \
|
||||||
forms/PasswordGenDlg.ui
|
forms/SettingsDlg.ui \
|
||||||
TRANSLATIONS += translations/english.ts \
|
forms/ChangeKeyDlg.ui \
|
||||||
translations/russian.ts
|
forms/MainWindow.ui \
|
||||||
HEADERS += lib/IniReader.h \
|
forms/SimplePasswordDlg.ui \
|
||||||
lib/UrlLabel.h \
|
forms/DatabaseSettingsDlg.ui \
|
||||||
mainwindow.h \
|
forms/PasswordDlg.ui \
|
||||||
PwManager.h \
|
forms/EditEntryDlg.ui \
|
||||||
crypto/rijndael.h \
|
forms/PasswordGenDlg.ui
|
||||||
lib/SecString.h \
|
TRANSLATIONS += translations/english.ts \
|
||||||
crypto/sha256.h \
|
translations/russian.ts
|
||||||
crypto/twoclass.h \
|
HEADERS += lib/IniReader.h \
|
||||||
crypto/twofish.h \
|
lib/UrlLabel.h \
|
||||||
import/Import_PwManager.h \
|
mainwindow.h \
|
||||||
crypto/blowfish.h \
|
PwManager.h \
|
||||||
crypto/sha1.h \
|
crypto/rijndael.h \
|
||||||
import/Import_KWalletXml.h \
|
lib/SecString.h \
|
||||||
PwmConfig.h \
|
crypto/sha256.h \
|
||||||
dialogs/AboutDlg.h \
|
crypto/twoclass.h \
|
||||||
dialogs/EditGroupDlg.h \
|
crypto/twofish.h \
|
||||||
dialogs/SearchDlg.h \
|
import/Import_PwManager.h \
|
||||||
dialogs/ChangeKeyDlg.h \
|
crypto/blowfish.h \
|
||||||
dialogs/LanguageDlg.h \
|
crypto/sha1.h \
|
||||||
dialogs/SettingsDlg.h \
|
import/Import_KWalletXml.h \
|
||||||
dialogs/DatabaseSettingsDlg.h \
|
PwmConfig.h \
|
||||||
dialogs/PasswordDlg.h \
|
dialogs/AboutDlg.h \
|
||||||
dialogs/SimplePasswordDlg.h \
|
dialogs/EditGroupDlg.h \
|
||||||
dialogs/EditEntryDlg.h \
|
dialogs/SearchDlg.h \
|
||||||
dialogs/PasswordGenDlg.h \
|
dialogs/ChangeKeyDlg.h \
|
||||||
lib/random.h \
|
dialogs/LanguageDlg.h \
|
||||||
Database.h \
|
dialogs/SettingsDlg.h \
|
||||||
lib/KdePlugin.h \
|
dialogs/DatabaseSettingsDlg.h \
|
||||||
global.h \
|
dialogs/PasswordDlg.h \
|
||||||
main.h \
|
dialogs/SimplePasswordDlg.h \
|
||||||
lib/GroupView.h \
|
dialogs/EditEntryDlg.h \
|
||||||
lib/EntryView.h \
|
dialogs/PasswordGenDlg.h \
|
||||||
crypto/arcfour.h \
|
lib/random.h \
|
||||||
lib/KpFileIconProvider.h
|
Database.h \
|
||||||
SOURCES += lib/IniReader.cpp \
|
lib/KdePlugin.h \
|
||||||
lib/UrlLabel.cpp \
|
global.h \
|
||||||
main.cpp \
|
main.h \
|
||||||
mainwindow.cpp \
|
lib/GroupView.h \
|
||||||
PwManager.cpp \
|
lib/EntryView.h \
|
||||||
crypto/rijndael.cpp \
|
crypto/arcfour.h \
|
||||||
lib/SecString.cpp \
|
lib/KpFileIconProvider.h
|
||||||
crypto/sha256.c \
|
SOURCES += lib/IniReader.cpp \
|
||||||
crypto/twoclass.cpp \
|
lib/UrlLabel.cpp \
|
||||||
crypto/twofish.cpp \
|
main.cpp \
|
||||||
import/Import_PwManager.cpp \
|
mainwindow.cpp \
|
||||||
crypto/blowfish.cpp \
|
PwManager.cpp \
|
||||||
crypto/sha1.cpp \
|
crypto/rijndael.cpp \
|
||||||
import/Import_KWalletXml.cpp \
|
lib/SecString.cpp \
|
||||||
PwmConfig.cpp \
|
crypto/sha256.c \
|
||||||
dialogs/AboutDlg.cpp \
|
crypto/twoclass.cpp \
|
||||||
dialogs/EditGroupDlg.cpp \
|
crypto/twofish.cpp \
|
||||||
dialogs/SearchDlg.cpp \
|
import/Import_PwManager.cpp \
|
||||||
dialogs/ChangeKeyDlg.cpp \
|
crypto/blowfish.cpp \
|
||||||
dialogs/LanguageDlg.cpp \
|
crypto/sha1.cpp \
|
||||||
dialogs/SettingsDlg.cpp \
|
import/Import_KWalletXml.cpp \
|
||||||
dialogs/DatabaseSettingsDlg.cpp \
|
PwmConfig.cpp \
|
||||||
dialogs/PasswordDlg.cpp \
|
dialogs/AboutDlg.cpp \
|
||||||
dialogs/SimplePasswordDlg.cpp \
|
dialogs/EditGroupDlg.cpp \
|
||||||
dialogs/EditEntryDlg.cpp \
|
dialogs/SearchDlg.cpp \
|
||||||
dialogs/PasswordGenDlg.cpp \
|
dialogs/ChangeKeyDlg.cpp \
|
||||||
lib/random.cpp \
|
dialogs/LanguageDlg.cpp \
|
||||||
Database.cpp \
|
dialogs/SettingsDlg.cpp \
|
||||||
lib/KdePlugin.cpp \
|
dialogs/DatabaseSettingsDlg.cpp \
|
||||||
lib/GroupView.cpp \
|
dialogs/PasswordDlg.cpp \
|
||||||
lib/EntryView.cpp \
|
dialogs/SimplePasswordDlg.cpp \
|
||||||
crypto/arcfour.cpp \
|
dialogs/EditEntryDlg.cpp \
|
||||||
lib/KpFileIconProvider.cpp
|
dialogs/PasswordGenDlg.cpp \
|
||||||
QT += xml \
|
lib/random.cpp \
|
||||||
qt3support
|
Database.cpp \
|
||||||
MOC_DIR = ../build/moc
|
lib/KdePlugin.cpp \
|
||||||
UI_DIR = ../build/ui
|
lib/GroupView.cpp \
|
||||||
OBJECTS_DIR = ../build/
|
lib/EntryView.cpp \
|
||||||
TARGET = ../bin/keepass
|
crypto/arcfour.cpp \
|
||||||
INCLUDEPATH += ./
|
lib/KpFileIconProvider.cpp
|
||||||
CONFIG += debug \
|
QT += xml \
|
||||||
warn_off \
|
qt3support
|
||||||
qt \
|
MOC_DIR = ../build/moc
|
||||||
thread \
|
UI_DIR = ../build/ui
|
||||||
exceptions \
|
OBJECTS_DIR = ../build/
|
||||||
stl
|
TARGET = ../bin/keepass
|
||||||
TEMPLATE = app
|
INCLUDEPATH += ./
|
||||||
unix{
|
CONFIG += debug \
|
||||||
target.path = /usr/local/bin
|
warn_off \
|
||||||
Share.path = /usr/local/share/keepass
|
qt \
|
||||||
}
|
thread \
|
||||||
macx{
|
exceptions \
|
||||||
target.path = /Applications
|
stl
|
||||||
Share.path = /Applications/keepass.app/Contents/share/keepass
|
TEMPLATE = app
|
||||||
}
|
|
Loading…
Reference in New Issue