mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Merge pull request #3657 from ward:manage-filters-up-down
This commit is contained in:
@@ -289,9 +289,13 @@ EditNamedSearches::EditNamedSearches(QWidget *parent, Context *context) : QDialo
|
||||
#endif
|
||||
searchList->header()->setStretchLastSection(true);
|
||||
|
||||
// delete button
|
||||
// up/down/delete button
|
||||
QHBoxLayout *row4 = new QHBoxLayout;
|
||||
layout->addLayout(row4);
|
||||
upButton = new QPushButton(tr("Up"), this);
|
||||
row4->addWidget(upButton);
|
||||
downButton = new QPushButton(tr("Down"), this);
|
||||
row4->addWidget(downButton);
|
||||
row4->addStretch();
|
||||
deleteButton = new QPushButton(tr("Delete"), this);
|
||||
row4->addWidget(deleteButton);
|
||||
@@ -314,6 +318,8 @@ EditNamedSearches::EditNamedSearches(QWidget *parent, Context *context) : QDialo
|
||||
connect(addButton, SIGNAL(clicked()), this, SLOT(addClicked()));
|
||||
connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
|
||||
connect(updateButton, SIGNAL(clicked()), this, SLOT(updateClicked()));
|
||||
connect(upButton, SIGNAL(clicked()), this, SLOT(upClicked()));
|
||||
connect(downButton, SIGNAL(clicked()), this, SLOT(downClicked()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -373,6 +379,46 @@ EditNamedSearches::updateClicked()
|
||||
selectionChanged(); // QT signals whilst rows are being removed, this is very confusing
|
||||
}
|
||||
|
||||
void
|
||||
EditNamedSearches::upClicked()
|
||||
{
|
||||
if (active || searchList->currentItem() == NULL) return;
|
||||
active = true;
|
||||
|
||||
int index = searchList->invisibleRootItem()->indexOfChild(searchList->currentItem());
|
||||
int newIndex = index - 1;
|
||||
|
||||
if (index > 0) {
|
||||
context->athlete->namedSearches->getList().swapItemsAt(newIndex, index);
|
||||
QTreeWidgetItem* child = searchList->invisibleRootItem()->takeChild(index);
|
||||
searchList->invisibleRootItem()->insertChild(newIndex, child);
|
||||
searchList->setCurrentItem(child);
|
||||
}
|
||||
|
||||
active = false;
|
||||
selectionChanged(); // QT signals whilst rows are being removed, this is very confusing
|
||||
}
|
||||
|
||||
void
|
||||
EditNamedSearches::downClicked()
|
||||
{
|
||||
if (active || searchList->currentItem() == NULL) return;
|
||||
active = true;
|
||||
|
||||
int index = searchList->invisibleRootItem()->indexOfChild(searchList->currentItem());
|
||||
int newIndex = index + 1;
|
||||
|
||||
if (index < (context->athlete->namedSearches->getList().size() - 1)) {
|
||||
context->athlete->namedSearches->getList().swapItemsAt(newIndex, index);
|
||||
QTreeWidgetItem* child = searchList->invisibleRootItem()->takeChild(index);
|
||||
searchList->invisibleRootItem()->insertChild(newIndex, child);
|
||||
searchList->setCurrentItem(child);
|
||||
}
|
||||
|
||||
active = false;
|
||||
selectionChanged(); // QT signals whilst rows are being removed, this is very confusing
|
||||
}
|
||||
|
||||
void
|
||||
EditNamedSearches::deleteClicked()
|
||||
{
|
||||
@@ -391,7 +437,7 @@ EditNamedSearches::deleteClicked()
|
||||
void EditNamedSearches::closeEvent(QCloseEvent*) { writeSearches(); }
|
||||
void EditNamedSearches::reject() { writeSearches(); }
|
||||
|
||||
void
|
||||
void
|
||||
EditNamedSearches::writeSearches()
|
||||
{
|
||||
context->athlete->namedSearches->write();
|
||||
|
||||
@@ -113,12 +113,16 @@ class EditNamedSearches : public QDialog
|
||||
QTreeWidget *searchList;
|
||||
QPushButton *addButton,
|
||||
*updateButton,
|
||||
*upButton,
|
||||
*downButton,
|
||||
*deleteButton;
|
||||
QIcon searchIcon, filterIcon;
|
||||
|
||||
private slots:
|
||||
void addClicked();
|
||||
void updateClicked();
|
||||
void upClicked();
|
||||
void downClicked();
|
||||
void deleteClicked();
|
||||
void selectionChanged();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user