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++)
|
||||
values[i]=DEFAULT_INT_VAL;}
|
||||
|
||||
memcpy(dst,values,count);
|
||||
memcpy(dst,values,count*sizeof(int));
|
||||
delete [] values;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDragMoveEvent>
|
||||
#include <QDragLeaveEvent>
|
||||
|
@ -32,14 +32,28 @@
|
|||
|
||||
|
||||
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;
|
||||
updateColumns();
|
||||
header()->setResizeMode(QHeaderView::Interactive);
|
||||
header()->setStretchLastSection(false);
|
||||
connect(header(),SIGNAL(sectionResized(int,int,int)),this,SLOT(OnColumnResized(int,int,int)));
|
||||
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){
|
||||
if(itemAt(e->pos())){
|
||||
|
@ -69,7 +83,7 @@ ContextMenu->popup(e->globalPos());
|
|||
}
|
||||
|
||||
void KeepassEntryView::resizeEvent(QResizeEvent* e){
|
||||
|
||||
resizeColumns();
|
||||
e->accept();
|
||||
}
|
||||
|
||||
|
@ -198,8 +212,81 @@ if(config.Columns[8]){
|
|||
if(config.Columns[9]){
|
||||
cols << trUtf8("Anhang");}
|
||||
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){
|
||||
QTreeWidget::paintEvent(event);
|
||||
}
|
||||
|
|
|
@ -23,13 +23,19 @@
|
|||
#include <QMenu>
|
||||
#include <QTreeWidget>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QHeaderView>
|
||||
#include "../PwManager.h"
|
||||
|
||||
#define NUM_COLUMNS 10
|
||||
|
||||
class EntryViewItem;
|
||||
|
||||
|
||||
class KeepassEntryView:public QTreeWidget{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KeepassEntryView(QWidget* parent=0);
|
||||
~KeepassEntryView();
|
||||
void updateItems(unsigned int group);
|
||||
void refreshItems();
|
||||
void updateColumns();
|
||||
|
@ -41,10 +47,14 @@ private:
|
|||
void setEntry(CEntry* entry);
|
||||
int CurrentGroup;
|
||||
QList<float>ColumnSizes;
|
||||
void resizeColumns();
|
||||
bool AutoResizeColumns;
|
||||
protected:
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
virtual void paintEvent(QPaintEvent* 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();
|
||||
mainWin->show();
|
||||
int r=app->exec();
|
||||
delete mainWin;
|
||||
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);
|
||||
delete app;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <QShowEvent>
|
||||
#include <QWidget>
|
||||
#include <QFileDialog>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "lib/random.h"
|
||||
#include "lib/IniReader.h"
|
||||
|
@ -71,6 +72,11 @@ KeepassMainWindow::KeepassMainWindow(QWidget *parent, Qt::WFlags flags):QMainWin
|
|||
setupConnections();
|
||||
FileOpen=false;
|
||||
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(){
|
||||
|
|
|
@ -113,6 +113,8 @@ private:
|
|||
inline CGroup* currentGroup();
|
||||
inline CEntry* currentEntry();
|
||||
QLineEdit* QuickSearchEdit;
|
||||
QLabel* StatusBarGeneral;
|
||||
QLabel* StatusBarSelection;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
|
17
src/src.pro
17
src/src.pro
|
@ -3,8 +3,15 @@
|
|||
# Unterordner relativ zum Projektordner: ./src
|
||||
# Das Target ist eine Anwendung: ../bin/keepass
|
||||
|
||||
INSTALLS += Share
|
||||
INSTALLS += target \
|
||||
Share
|
||||
Share.files += ../share/keepass/*
|
||||
unix{ target.path = /usr/local/bin
|
||||
Share.path = /usr/local/share/keepass
|
||||
}
|
||||
macx{ target.path = /Applications
|
||||
Share.path = /Applications/keepass.app/Contents/share/keepass
|
||||
}
|
||||
FORMS += forms/EditGroupDlg.ui \
|
||||
forms/SearchDlg.ui \
|
||||
forms/AboutDlg.ui \
|
||||
|
@ -100,11 +107,3 @@ thread \
|
|||
exceptions \
|
||||
stl
|
||||
TEMPLATE = app
|
||||
unix{
|
||||
target.path = /usr/local/bin
|
||||
Share.path = /usr/local/share/keepass
|
||||
}
|
||||
macx{
|
||||
target.path = /Applications
|
||||
Share.path = /Applications/keepass.app/Contents/share/keepass
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue