Second version
This commit is contained in:
parent
57d4b90182
commit
459e07ee11
|
@ -1419,7 +1419,7 @@ std::vector<Operation>* Database::Search(User* user, QString* description, QDate
|
||||||
if (tags.size())
|
if (tags.size())
|
||||||
{
|
{
|
||||||
if (firstCond) req += " AND " ; else firstCond = true;
|
if (firstCond) req += " AND " ; else firstCond = true;
|
||||||
req += "category IN ('";
|
req += "tag IN ('";
|
||||||
it = tags.begin();
|
it = tags.begin();
|
||||||
req += QString::number(*it);
|
req += QString::number(*it);
|
||||||
it++;
|
it++;
|
||||||
|
|
|
@ -191,8 +191,10 @@ AccountPanel::~AccountPanel()
|
||||||
{
|
{
|
||||||
delete[] _categoriesValues;
|
delete[] _categoriesValues;
|
||||||
delete[] _categories;
|
delete[] _categories;
|
||||||
delete[] _tagsValues;
|
if (_tagsValues)
|
||||||
delete[] _tags;
|
delete[] _tagsValues;
|
||||||
|
if (_tags)
|
||||||
|
delete[] _tags;
|
||||||
delete[] _accounts;
|
delete[] _accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,9 +228,9 @@ std::vector<Operation> * SearchBanner::Search()
|
||||||
if (_category->item(i)->checkState() == Qt::Checked)
|
if (_category->item(i)->checkState() == Qt::Checked)
|
||||||
categories.push_back((i) ? user->_categories[i-1].id : 0);
|
categories.push_back((i) ? user->_categories[i-1].id : 0);
|
||||||
|
|
||||||
for(i=0; i<user->GetTagsNumber()+1; i++)
|
for(i=0; i<user->GetTagsNumber(); i++)
|
||||||
if (_tag->item(i)->checkState() == Qt::Checked)
|
if (_tag->item(i+1)->checkState() == Qt::Checked)
|
||||||
tags.push_back((i) ? user->_tags[i-1].id : 0);
|
tags.push_back(user->_tags[i].id);
|
||||||
|
|
||||||
types |= (_optype->item(0)->checkState() == Qt::Checked) ? Database::FIX_OP : 0;
|
types |= (_optype->item(0)->checkState() == Qt::Checked) ? Database::FIX_OP : 0;
|
||||||
types |= (_optype->item(1)->checkState() == Qt::Checked) ? Database::NON_FIX_OP : 0;
|
types |= (_optype->item(1)->checkState() == Qt::Checked) ? Database::NON_FIX_OP : 0;
|
||||||
|
|
|
@ -52,10 +52,12 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
||||||
|
|
||||||
_changeAccountButton = new QPushButton(_("Change account"));
|
_changeAccountButton = new QPushButton(_("Change account"));
|
||||||
_changeCategoryButton = new QPushButton(_("Change category"));
|
_changeCategoryButton = new QPushButton(_("Change category"));
|
||||||
|
_changeTagButton = new QPushButton(_("Change tag"));
|
||||||
_renameButton = new QPushButton(_("Rename"));
|
_renameButton = new QPushButton(_("Rename"));
|
||||||
|
|
||||||
connect(_changeAccountButton, SIGNAL(clicked()), this, SLOT(OnButtonChangeAccount()));
|
connect(_changeAccountButton, SIGNAL(clicked()), this, SLOT(OnButtonChangeAccount()));
|
||||||
connect(_changeCategoryButton, SIGNAL(clicked()), this, SLOT(OnButtonChangeCategory()));
|
connect(_changeCategoryButton, SIGNAL(clicked()), this, SLOT(OnButtonChangeCategory()));
|
||||||
|
connect(_changeTagButton, SIGNAL(clicked()), this, SLOT(OnButtonChangeTag()));
|
||||||
connect(_renameButton, SIGNAL(clicked()), this, SLOT(OnButtonRename()));
|
connect(_renameButton, SIGNAL(clicked()), this, SLOT(OnButtonRename()));
|
||||||
|
|
||||||
_categories = new QString[user->GetCategoriesNumber()] ;
|
_categories = new QString[user->GetCategoriesNumber()] ;
|
||||||
|
@ -72,6 +74,7 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent, bool lowResolution) :
|
||||||
|
|
||||||
vbox2->addWidget(_changeAccountButton);
|
vbox2->addWidget(_changeAccountButton);
|
||||||
vbox2->addWidget(_changeCategoryButton);
|
vbox2->addWidget(_changeCategoryButton);
|
||||||
|
vbox2->addWidget(_changeTagButton);
|
||||||
vbox2->addWidget(_renameButton);
|
vbox2->addWidget(_renameButton);
|
||||||
|
|
||||||
hbox->addLayout(vbox2);
|
hbox->addLayout(vbox2);
|
||||||
|
@ -255,6 +258,51 @@ void SearchPanel::OnButtonChangeCategory()
|
||||||
_wxUI->NeedReload();
|
_wxUI->NeedReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ChangeTag(Operation* op, void** params)
|
||||||
|
{
|
||||||
|
int* tag = (int*) params[0];
|
||||||
|
|
||||||
|
op->tag = *tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchPanel::OnButtonChangeTag()
|
||||||
|
{
|
||||||
|
int i, a;
|
||||||
|
std::vector<int> rows;
|
||||||
|
User* user = _kiss->GetUser();
|
||||||
|
QStringList tags;
|
||||||
|
std::vector<Operation>::iterator it;
|
||||||
|
QString res;
|
||||||
|
int tag;
|
||||||
|
void * params[] = {&tag};
|
||||||
|
|
||||||
|
if (!_operations) return;
|
||||||
|
|
||||||
|
_grid->GetSelectedOperations(&rows);
|
||||||
|
|
||||||
|
tags << _("None");
|
||||||
|
for(i=0; i < user->GetTagsNumber(); i++)
|
||||||
|
tags << _(user->_tags[i].name.toStdString().c_str());
|
||||||
|
|
||||||
|
res = QInputDialog::getItem(0, "KissCount", _("Choose a new tag"), tags, 0, false);
|
||||||
|
|
||||||
|
if (res.length())
|
||||||
|
{
|
||||||
|
a = tags.indexOf(res);
|
||||||
|
tag = user->_tags[a].id ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_grid->MassUpdate(rows, true, ChangeTag, params);
|
||||||
|
|
||||||
|
UpdateCostRepartition();
|
||||||
|
|
||||||
|
_wxUI->NeedReload();
|
||||||
|
}
|
||||||
|
|
||||||
static void ChangeName(Operation* op, void** params)
|
static void ChangeName(Operation* op, void** params)
|
||||||
{
|
{
|
||||||
QString* description = (QString*) params[0];
|
QString* description = (QString*) params[0];
|
||||||
|
|
|
@ -45,12 +45,12 @@ public:
|
||||||
void OnShow();
|
void OnShow();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* void OnEnter(wxCommandEvent& event); */
|
|
||||||
void OnButtonSearch();
|
void OnButtonSearch();
|
||||||
void OnOperationModified();
|
void OnOperationModified();
|
||||||
|
|
||||||
void OnButtonChangeAccount();
|
void OnButtonChangeAccount();
|
||||||
void OnButtonChangeCategory();
|
void OnButtonChangeCategory();
|
||||||
|
void OnButtonChangeTag();
|
||||||
void OnButtonRename();
|
void OnButtonRename();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -63,7 +63,7 @@ private:
|
||||||
QString* _categories;
|
QString* _categories;
|
||||||
int *_categoriesValues;
|
int *_categoriesValues;
|
||||||
std::map<int, int> _categoriesIndexes;
|
std::map<int, int> _categoriesIndexes;
|
||||||
QPushButton* _searchButton, *_renameButton, *_changeAccountButton, *_changeCategoryButton;
|
QPushButton* _searchButton, *_renameButton, *_changeAccountButton, *_changeCategoryButton, *_changeTagButton;
|
||||||
|
|
||||||
static void OnEnter(void* caller);
|
static void OnEnter(void* caller);
|
||||||
};
|
};
|
||||||
|
|
|
@ -121,7 +121,8 @@ GridAccount::GridAccount(KissCount* kiss, QWidget *parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
_tags = new QString[user->GetTagsNumber()] ;
|
_tags = new QString[user->GetTagsNumber()] ;
|
||||||
for(i=0, tagIt = user->_tags.begin();
|
_tags[0] = _("No Tag");
|
||||||
|
for(i=1, tagIt = user->_tags.begin();
|
||||||
tagIt != user->_tags.end();
|
tagIt != user->_tags.end();
|
||||||
tagIt++, i++)
|
tagIt++, i++)
|
||||||
{
|
{
|
||||||
|
@ -246,7 +247,7 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, int month,
|
||||||
ChoiceDelegate* categoryEditor = new ChoiceDelegate(this, _categories, user->GetCategoriesNumber()-1);
|
ChoiceDelegate* categoryEditor = new ChoiceDelegate(this, _categories, user->GetCategoriesNumber()-1);
|
||||||
setItemDelegateForColumn(CATEGORY, categoryEditor);
|
setItemDelegateForColumn(CATEGORY, categoryEditor);
|
||||||
|
|
||||||
ChoiceDelegate* tagEditor = new ChoiceDelegate(this, _tags, user->GetTagsNumber());
|
ChoiceDelegate* tagEditor = new ChoiceDelegate(this, _tags, user->GetTagsNumber()+1);
|
||||||
setItemDelegateForColumn(TAG, tagEditor);
|
setItemDelegateForColumn(TAG, tagEditor);
|
||||||
|
|
||||||
ChoiceDelegate* accountEditor = new ChoiceDelegate(this, _accounts, _nbAccounts);
|
ChoiceDelegate* accountEditor = new ChoiceDelegate(this, _accounts, _nbAccounts);
|
||||||
|
@ -405,7 +406,10 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
if (!fix && !op.meta)
|
if (!fix && !op.meta)
|
||||||
setItem(line, CATEGORY, new QTableWidgetItem(_(cat.name.toStdString().c_str())));
|
setItem(line, CATEGORY, new QTableWidgetItem(_(cat.name.toStdString().c_str())));
|
||||||
|
|
||||||
setItem(line, TAG, new QTableWidgetItem(_(tag.name.toStdString().c_str())));
|
if (tag.id)
|
||||||
|
setItem(line, TAG, new QTableWidgetItem(_(tag.name.toStdString().c_str())));
|
||||||
|
else
|
||||||
|
setItem(line, TAG, new QTableWidgetItem(""));
|
||||||
|
|
||||||
checkBox = new QCheckBox();
|
checkBox = new QCheckBox();
|
||||||
checkBox->setCheckState(Qt::Unchecked);
|
checkBox->setCheckState(Qt::Unchecked);
|
||||||
|
@ -448,6 +452,7 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||||
if (op.meta)
|
if (op.meta)
|
||||||
resizeColumnToContents(TREE);
|
resizeColumnToContents(TREE);
|
||||||
resizeColumnToContents(CATEGORY);
|
resizeColumnToContents(CATEGORY);
|
||||||
|
resizeColumnToContents(TAG);
|
||||||
resizeColumnToContents(ACCOUNT);
|
resizeColumnToContents(ACCOUNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1034,6 +1039,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
catch (User::TagNotFound e)
|
catch (User::TagNotFound e)
|
||||||
{
|
{
|
||||||
op_complete++;
|
op_complete++;
|
||||||
|
setItem(row, TAG, new QTableWidgetItem(""));
|
||||||
}
|
}
|
||||||
op_complete--;
|
op_complete--;
|
||||||
}
|
}
|
||||||
|
@ -1117,6 +1123,11 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
|
|
||||||
if (need_insertion)
|
if (need_insertion)
|
||||||
InsertIntoGrid(new_op);
|
InsertIntoGrid(new_op);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resizeColumnToContents(CATEGORY);
|
||||||
|
resizeColumnToContents(TAG);
|
||||||
|
}
|
||||||
|
|
||||||
if (new_op.parent)
|
if (new_op.parent)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue