mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-16 09:29:55 +00:00
@@ -28,8 +28,8 @@
|
||||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
|
||||
SearchBox::SearchBox(MainWindow *main, QWidget *parent)
|
||||
: QLineEdit(parent), main(main), filtered(false)
|
||||
SearchBox::SearchBox(MainWindow *main, QWidget *parent, bool nomenu)
|
||||
: QLineEdit(parent), main(main), filtered(false), nomenu(nomenu)
|
||||
{
|
||||
setFixedHeight(21);
|
||||
//clear button
|
||||
@@ -51,6 +51,11 @@ SearchBox::SearchBox(MainWindow *main, QWidget *parent)
|
||||
toolButton->setCursor(Qt::ArrowCursor);
|
||||
toolButton->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
dropMenu = new QMenu(this);
|
||||
toolButton->setMenu(dropMenu);
|
||||
connect(dropMenu, SIGNAL(aboutToShow()), this, SLOT(setMenu()));
|
||||
connect(dropMenu, SIGNAL(triggered(QAction*)), this, SLOT(runMenu(QAction*)));
|
||||
|
||||
// search button
|
||||
searchButton = new QToolButton(this);
|
||||
QIcon search = iconFromPNG(":images/toolbar/search3.png", false);
|
||||
@@ -60,11 +65,6 @@ SearchBox::SearchBox(MainWindow *main, QWidget *parent)
|
||||
searchButton->setCursor(Qt::ArrowCursor);
|
||||
connect(searchButton, SIGNAL(clicked()), this, SLOT(toggleMode()));
|
||||
|
||||
dropMenu = new QMenu(this);
|
||||
toolButton->setMenu(dropMenu);
|
||||
connect(dropMenu, SIGNAL(aboutToShow()), this, SLOT(setMenu()));
|
||||
connect(dropMenu, SIGNAL(triggered(QAction*)), this, SLOT(runMenu(QAction*)));
|
||||
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
#ifdef Q_OS_MAC
|
||||
setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
@@ -186,14 +186,16 @@ void SearchBox::checkMenu()
|
||||
void SearchBox::setMenu()
|
||||
{
|
||||
dropMenu->clear();
|
||||
if (text() != "") dropMenu->addAction(tr("Add Favourite"));
|
||||
if (main->namedSearches->getList().count()) {
|
||||
dropMenu->addAction(tr("Edit Favourites"));
|
||||
dropMenu->addSeparator();
|
||||
foreach(NamedSearch x, main->namedSearches->getList()) {
|
||||
dropMenu->addAction(x.name);
|
||||
if (!nomenu) {
|
||||
if (text() != "") dropMenu->addAction(tr("Add Favourite"));
|
||||
if (main->namedSearches->getList().count()) {
|
||||
dropMenu->addAction(tr("Edit Favourites"));
|
||||
dropMenu->addSeparator();
|
||||
foreach(NamedSearch x, main->namedSearches->getList()) {
|
||||
dropMenu->addAction(x.name);
|
||||
}
|
||||
dropMenu->addSeparator();
|
||||
}
|
||||
dropMenu->addSeparator();
|
||||
}
|
||||
dropMenu->addAction(tr("Column Chooser"));
|
||||
}
|
||||
@@ -202,7 +204,13 @@ void SearchBox::runMenu(QAction *x)
|
||||
{
|
||||
// just qdebug for now
|
||||
if (x->text() == tr("Add Favourite")) addNamed();
|
||||
else if (x->text() == tr("Column Chooser")) {
|
||||
else if (x->text() == tr("Edit Favourites")) {
|
||||
|
||||
EditNamedSearches *editor = new EditNamedSearches(this, main);
|
||||
editor->move(QCursor::pos()-QPoint(230,-5));
|
||||
editor->show();
|
||||
|
||||
} else if (x->text() == tr("Column Chooser")) {
|
||||
ColumnChooser *selector = new ColumnChooser(main->listView->logicalHeadings);
|
||||
selector->show();
|
||||
} else {
|
||||
@@ -253,7 +261,7 @@ SearchBox::dropEvent(QDropEvent *event)
|
||||
|
||||
// we do very little to the name, just space to _ and lower case it for now...
|
||||
name.replace(' ', '_');
|
||||
insert(name + (mode == Search ? ":\"\"" : ""));
|
||||
insert(name);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user