EntryView and DetailView now also show "never" for entries which don't expire,

EntryView now calls updateItems() when column config is changed,
Added {TAB} template for Auto-Type,
"Custom Icon" feature is not longer touching the ImageID value within the database,
Fixed SegFault when enabling a new column (not in 0.2.0, only svn)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@79 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent 17f2e85420
commit 74c7b86a89
  1. 12
      src/Database.cpp
  2. 22
      src/Database.h
  3. 10
      src/PwManager.cpp
  4. 2
      src/PwManager.h
  5. 20
      src/dialogs/EditEntryDlg.cpp
  6. 1
      src/dialogs/EditEntryDlg.h
  7. 2
      src/dialogs/EditGroupDlg.cpp
  8. 1
      src/dialogs/EditGroupDlg.h
  9. 6
      src/dialogs/SelectIconDlg.cpp
  10. 2
      src/dialogs/SelectIconDlg.h
  11. 2
      src/forms/EditEntryDlg.ui
  12. 133
      src/lib/AutoType.cpp
  13. 27
      src/lib/EntryView.cpp
  14. 6
      src/mainwindow.cpp

@ -20,9 +20,20 @@
#include "Database.h"
QString KpxDateTime::toString(Qt::DateFormat format) const{
if(*this==Date_Never)return QObject::tr("Never");
else return QDateTime::toString(format);
}
QString KpxDateTime::dateToString(Qt::DateFormat format) const{
if(*this==Date_Never)return QObject::tr("Never");
else return date().toString(format);
}
CEntry::CEntry(){
ImageID=0;
OldImgID=0;
GroupID=0;
Creation=QDateTime::currentDateTime();
LastMod=QDateTime::currentDateTime();
@ -50,6 +61,7 @@ LastMod=QDateTime::currentDateTime();
Expire=QDateTime(QDate(2999,12,28),QTime(23,59,59));
Level=0;
ImageID=0;
OldImgID=0;
Name="<Group>";
UI_ItemIsExpanded=UI_ExpandByDefault;
}

@ -27,6 +27,17 @@
#include "lib/SecString.h"
using namespace std;
extern const QDateTime Date_Never;
class KpxDateTime:public QDateTime{
public:
KpxDateTime(){};
KpxDateTime ( const QDate & date ):QDateTime(date){};
KpxDateTime ( const QDate & date, const QTime & time, Qt::TimeSpec spec = Qt::LocalTime):QDateTime(date,time,spec){};
KpxDateTime ( const QDateTime & other ):QDateTime(other){};
virtual QString toString(Qt::DateFormat format = Qt::TextDate ) const;
QString dateToString(Qt::DateFormat format = Qt::TextDate)const;
};
class CEntry{
public:
CEntry();
@ -35,16 +46,17 @@ Q_UINT8 ID[16];
Q_UINT32 sID;
Q_UINT32 GroupID;
Q_UINT32 ImageID;
quint32 OldImgID;
QString Title;
QString URL;
QString UserName;
SecString Password;
QString Additional;
QString BinaryDesc;
QDateTime Creation;
QDateTime LastMod;
QDateTime LastAccess;
QDateTime Expire;
KpxDateTime Creation;
KpxDateTime LastMod;
KpxDateTime LastAccess;
KpxDateTime Expire;
QByteArray BinaryData;
/*Q_UINT32 PasswordLength;*/
bool ReadEntryField(Q_UINT16 FieldType, Q_UINT32 FieldSize, Q_UINT8 *pData);
@ -58,7 +70,7 @@ CGroup();
~CGroup();
Q_UINT32 ID;
Q_UINT32 ImageID;
/*Q_UINT32 NumEntries;*/
quint32 OldImgID;
QString Name;
QDateTime Creation;
QDateTime LastMod;

@ -280,6 +280,7 @@ for(int i=0;i<NumEntries;i++){
offset+=4;
memcpyFromLEnd32(&Icon,dta.data()+offset);
offset+=4;
Entries[Entry].OldImgID=Entries[Entry].ImageID;
Entries[Entry].ImageID=Icon;
}
for(int i=0;i<NumGroups;i++){
@ -288,6 +289,7 @@ for(int i=0;i<NumGroups;i++){
offset+=4;
memcpyFromLEnd32(&Icon,dta.data()+offset);
offset+=4;
Groups[Group].OldImgID=Groups[Group].ImageID;
Groups[Group].ImageID=Icon;
}
return true;
@ -848,9 +850,7 @@ for(int i=0; i < Groups.size(); i++){
FieldType = 0x0007; FieldSize = 4;
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2;
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4;
Q_UINT32 ImgID=Groups[i].ImageID;
if(ImgID>=BUILTIN_ICONS)ImgID=0;
memcpyToLEnd32(buffer+pos, &ImgID); pos += 4;
memcpyToLEnd32(buffer+pos, &Groups[i].OldImgID); pos += 4;
FieldType = 0x0008; FieldSize = 2;
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2;
@ -881,9 +881,7 @@ for(int i = 0; i < Entries.size(); i++){
FieldType = 0x0003; FieldSize = 4;
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2;
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4;
Q_UINT32 ImgID=Entries[i].ImageID;
if(ImgID>=BUILTIN_ICONS)ImgID=0;
memcpyToLEnd32(buffer+pos,&ImgID); pos += 4;
memcpyToLEnd32(buffer+pos,&Entries[i].OldImgID); pos += 4;
FieldType = 0x0004;

@ -109,7 +109,7 @@ void modified();
};
extern const QDateTime Date_Never;
void memcpyFromLEnd32(Q_UINT32* dst,const char* src);
void memcpyFromLEnd16(Q_UINT16* dst,const char* src);
void memcpyToLEnd32(char* src,const Q_UINT32* dst);

@ -38,7 +38,7 @@
//Added by qt3to4:
#include <QShowEvent>
#include "SelectIconDlg.h"
#include "PasswordGenDlg.h"
#include "EditEntryDlg.h"
@ -65,6 +65,7 @@ connect(ButtonSaveAttachment, SIGNAL(clicked()), this, SLOT( OnSaveAttachment())
connect(ButtonGenPw, SIGNAL(clicked()), this, SLOT( OnButtonGenPw()));
connect(ButtonOK, SIGNAL(clicked()),this,SLOT(OnButtonOK()));
connect(CheckBox_ExpiresNever,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxExpiresNeverChanged(int)));
connect(Button_CustomIcons,SIGNAL(clicked()),this,SLOT(OnCustomIcons()));
ButtonOpenAttachment->setIcon(*Icon_FileOpen);
ButtonDeleteAttachment->setIcon(*Icon_EditDelete);
@ -74,7 +75,7 @@ if(entry->BinaryData.isNull()){
ButtonSaveAttachment->setDisabled(true);
ButtonDeleteAttachment->setDisabled(true);}
setCaption(entry->Title);
setIcon(EntryIcons[entry->ImageID]);
setIcon(db->icon(entry->ImageID));
Edit_Title->setText(entry->Title);
Edit_UserName->setText(entry->UserName);
Edit_URL->setText(entry->URL);
@ -194,6 +195,8 @@ if(Combo_Group->currentItem()!=db->getGroupIndex(entry->GroupID)){
db->moveEntry(entry,&db->group(Combo_Group->currentItem()));
EntryMoved=true; ModFlag=true;
}
if(entry->ImageID<BUILTIN_ICONS && Combo_IconPicker->currentItem()>=BUILTIN_ICONS)
entry->OldImgID=entry->ImageID;
entry->ImageID=Combo_IconPicker->currentItem();
if(ModFlag&&EntryMoved)done(2);
@ -359,8 +362,17 @@ else
}
}
void CEditEntryDlg::OnCustomIcons(){
CSelectIconDlg dlg(db,Combo_IconPicker->currentItem(),this);
int r=dlg.exec();
if(dlg.ModFlag)ModFlag=true;
if(r!=-1){
Combo_IconPicker->clear();
for(int i=0;i<db->numIcons();i++)
Combo_IconPicker->insertItem(db->icon(i),"",i);
Combo_IconPicker->setCurrentItem(r);
}
}

@ -70,6 +70,7 @@ public slots:
void OnSaveAttachment();
void OnButtonGenPw();
void OnCheckBoxExpiresNeverChanged(int state);
void OnCustomIcons();
};

@ -36,6 +36,7 @@ IconID=0;
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
connect( Button_Icon, SIGNAL( clicked() ), this, SLOT( OnIconDlg() ));
ModFlag=false;
}
CEditGroupDialog::~CEditGroupDialog()
@ -68,6 +69,7 @@ done(0);
void CEditGroupDialog::OnIconDlg(){
CSelectIconDlg dlg(db,IconID,this);
int r=dlg.exec();
if(dlg.ModFlag)ModFlag=true;
if(r!=-1){
ComboIconPicker->clear();
for(int i=0;i<db->numIcons();i++)

@ -33,6 +33,7 @@ class CEditGroupDialog : public QDialog, public Ui_EditGroupDialog
public:
CEditGroupDialog(Database*,QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
~CEditGroupDialog();
bool ModFlag;
virtual void showEvent(QShowEvent *event);
int IconID;
QString GroupName;

@ -33,7 +33,6 @@ setupUi(this);
db=database;
CtxMenu=new QMenu(this);
DeleteAction=CtxMenu->addAction(*Icon_EditDelete,tr("Delete"));
CustomIconsModified=false;
connect(Button_AddIcon, SIGNAL(clicked()), this, SLOT(OnAddIcon()));
connect(Button_PickIcon, SIGNAL(clicked()), this, SLOT(OnPickIcon()));
connect(Button_Cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
@ -41,6 +40,7 @@ connect(DeleteAction,SIGNAL(triggered()),this,SLOT(OnDelete()));
connect(List,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(OnSelectionChanged(QListWidgetItem*,QListWidgetItem*)));
updateView();
List->setCurrentItem(List->item(CurrentID));
ModFlag=false;
}
void CSelectIconDlg::updateView(){
@ -70,7 +70,7 @@ for(int i=0;i<filenames.size();i++){
}
if(errors.size())
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon(s):\n"));
CustomIconsModified=true;
ModFlag=true;
updateView();
List->setCurrentItem(List->item(List->count()-1));
}
@ -89,8 +89,10 @@ CtxMenu->popup(event->globalPos());
}
void CSelectIconDlg::OnDelete(){
ModFlag=true;
db->removeIcon(List->currentItem()->data(32).toInt());
updateView();
List->setCurrentItem(List->item(0));
}
void CSelectIconDlg::OnPickIcon(){

@ -32,7 +32,7 @@ class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{
Q_OBJECT
public:
CSelectIconDlg(Database* db,int,QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WFlags fl = 0);
bool CustomIconsModified;
bool ModFlag;
public slots:
void OnAddIcon();

@ -383,7 +383,7 @@
<widget class="QComboBox" name="Combo_IconPicker" />
</item>
<item row="0" column="5" >
<widget class="QToolButton" name="toolButton" >
<widget class="QToolButton" name="Button_CustomIcons" >
<property name="text" >
<string>></string>
</property>

@ -101,7 +101,6 @@ for(int i=0;i<str.size();i++){
Keys << getKeysym(str[i]);
}
MainWin->hide();
Display* pDisplay = XOpenDisplay( NULL );
for(int i=0;i<Keys.size();i++){
@ -213,8 +212,140 @@ if(!tmpl.compare("left")){
if(!tmpl.compare("right")){
keys << XK_Right;
return;}
if(!tmpl.compare("f1")){
keys << XK_F1;
return;}
if(!tmpl.compare("f2")){
keys << XK_F2;
return;}
if(!tmpl.compare("f3")){
keys << XK_F3;
return;}
if(!tmpl.compare("f4")){
keys << XK_F4;
return;}
if(!tmpl.compare("f5")){
keys << XK_F5;
return;}
if(!tmpl.compare("f6")){
keys << XK_F6;
return;}
if(!tmpl.compare("f7")){
keys << XK_F7;
return;}
if(!tmpl.compare("f8")){
keys << XK_F8;
return;}
if(!tmpl.compare("f9")){
keys << XK_F9;
return;}
if(!tmpl.compare("f10")){
keys << XK_F10;
return;}
if(!tmpl.compare("f11")){
keys << XK_F11;
return;}
if(!tmpl.compare("f12")){
keys << XK_F12;
return;}
if(!tmpl.compare("f13")){
keys << XK_F13;
return;}
if(!tmpl.compare("f14")){
keys << XK_F14;
return;}
if(!tmpl.compare("f15")){
keys << XK_F15;
return;}
if(!tmpl.compare("f16")){
keys << XK_F16;
return;}
if(!tmpl.compare("add") || !tmpl.compare("plus")){
keys << getKeysym('+');
return;}
if(!tmpl.compare("subtract")){
keys << getKeysym('-');
return;}
if(!tmpl.compare("multiply")){
keys << getKeysym('+');
return;}
if(!tmpl.compare("divide")){
keys << getKeysym('/');
return;}
if(!tmpl.compare("at")){
keys << getKeysym('@');
return;}
if(!tmpl.compare("percent")){
keys << getKeysym('%');
return;}
if(!tmpl.compare("caret")){
keys << getKeysym('^');
return;}
if(!tmpl.compare("tilde")){
keys << getKeysym('~');
return;}
if(!tmpl.compare("leftbrace")){
keys << getKeysym('{');
return;}
if(!tmpl.compare("rightbrace")){
keys << getKeysym('}');
return;}
if(!tmpl.compare("leftparen")){
keys << getKeysym('(');
return;}
if(!tmpl.compare("rightparen")){
keys << getKeysym(')');
return;}
if(!tmpl.compare("winl")){
keys << XK_Super_L;
return;}
if(!tmpl.compare("winr")){
keys << XK_Super_R;
return;}
if(!tmpl.compare("win")){
keys << XK_Super_L;
return;}
if(!tmpl.compare("tab")){
keys << XK_Tab;
return;}
}
void AutoType::stringToKeysyms(const QString& string,QList<quint16>& KeySymList){
for(int i=0; i<string.length();i++)
KeySymList << getKeysym(string[i]);

@ -101,6 +101,10 @@ updateItems(CurrentGroup);
void KeepassEntryView::updateItems(unsigned int GroupID){
QList<QTreeWidgetItem*> ItemSelec=selectedItems();
QList<quint32> SelectionIDs;
for(int i=0; i<ItemSelec.size(); i++)
SelectionIDs << ((EntryViewItem*)ItemSelec[i])->pEntry->sID;
IsSearchGroup=false;
clear();
Items.clear();
@ -111,6 +115,11 @@ for(int i=0;i<db->numEntries();i++){
if(db->entry(i).GroupID==GroupID)
setEntry(&db->entry(i));
}
if(SelectionIDs.size())
for(int i=0;i<Items.size();i++){
for(int j=0; j<SelectionIDs.size();j++){
if(Items[i]->pEntry->sID==SelectionIDs[j]) setItemSelected(Items[i],true);}
}
}
void KeepassEntryView::showSearchResults(QList<Q_UINT32>& results){
@ -149,13 +158,13 @@ void KeepassEntryView::setEntry(CEntry* entry){
if(config.Columns[4]){
tmp->setText(j++,entry->Additional.section('\n',0,0));}
if(config.Columns[5]){
tmp->setText(j++,entry->Expire.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->Expire.dateToString(Qt::LocalDate));}
if(config.Columns[6]){
tmp->setText(j++,entry->Creation.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->Creation.dateToString(Qt::LocalDate));}
if(config.Columns[7]){
tmp->setText(j++,entry->LastMod.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->LastMod.dateToString(Qt::LocalDate));}
if(config.Columns[8]){
tmp->setText(j++,entry->LastAccess.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->LastAccess.dateToString(Qt::LocalDate));}
if(config.Columns[9]){
tmp->setText(j++,entry->BinaryDesc);}
Items.back()->setIcon(0,db->icon(entry->ImageID));
@ -187,13 +196,13 @@ for(int i=0;i<Items.size();i++){
if(config.Columns[4]){
tmp->setText(j++,entry->Additional.section('\n',0,0));}
if(config.Columns[5]){
tmp->setText(j++,entry->Expire.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->Expire.dateToString(Qt::LocalDate));}
if(config.Columns[6]){
tmp->setText(j++,entry->Creation.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->Creation.dateToString(Qt::LocalDate));}
if(config.Columns[7]){
tmp->setText(j++,entry->LastMod.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->LastMod.dateToString(Qt::LocalDate));}
if(config.Columns[8]){
tmp->setText(j++,entry->LastAccess.date().toString(Qt::LocalDate));}
tmp->setText(j++,entry->LastAccess.dateToString(Qt::LocalDate));}
if(config.Columns[9]){
tmp->setText(j++,entry->BinaryDesc);}
tmp->setIcon(0,db->icon(entry->ImageID));
@ -229,8 +238,8 @@ resizeColumns();
}
void KeepassEntryView::resizeColumns(){
AutoResizeColumns=false;
if(!header()->count())return;
for(int i=0;i<NUM_COLUMNS;i++)
if(!config.Columns[i])ColumnSizes[i]=0;

@ -794,9 +794,11 @@ CEditGroupDialog dlg(db,this,"EditGroupDlg",true);
dlg.GroupName=pGroup->Name;
dlg.IconID=pGroup->ImageID;
if(!dlg.exec())return;
if((pGroup->Name != dlg.GroupName) || (pGroup->ImageID != dlg.IconID)){
if((pGroup->Name != dlg.GroupName) || (pGroup->ImageID != dlg.IconID) || dlg.ModFlag){
setStateFileModified(true);
pGroup->Name = dlg.GroupName;
if(pGroup->ImageID<BUILTIN_ICONS && dlg.IconID>=BUILTIN_ICONS)
pGroup->OldImgID=pGroup->ImageID;
pGroup->ImageID = dlg.IconID;
GroupView->updateItems();
}
@ -942,7 +944,7 @@ config.Columns[7]=ViewColumnsLastChangeAction->isChecked();
config.Columns[8]=ViewColumnsLastAccessAction->isChecked();
config.Columns[9]=ViewColumnsAttachmentAction->isChecked();
EntryView->updateColumns();
if(FileOpen) EntryView->refreshItems();
if(FileOpen) EntryView->updateItems();
}
void KeepassMainWindow::OnUsernPasswVisibilityChanged(bool value){