mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 00:28:42 +00:00
Less right-click on Activity list
.. group by and field chooser now appear on the popupMenu in the sidebar.
This commit is contained in:
@@ -133,7 +133,7 @@ QDesktopWidget *desktop = NULL;
|
||||
MainWindow::MainWindow(const QDir &home) :
|
||||
home(home), session(0), isclean(false), ismultisave(false),
|
||||
zones_(new Zones), hrzones_(new HrZones),
|
||||
ride(NULL), workout(NULL)
|
||||
ride(NULL), workout(NULL), groupByMapper(NULL)
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
// get an autorelease pool setup
|
||||
@@ -1353,6 +1353,42 @@ MainWindow::showTreeContextMenuPopup(const QPoint &pos)
|
||||
connect(actUploadCalendar, SIGNAL(triggered(void)), this, SLOT(uploadCalendar()));
|
||||
menu.addAction(actUploadCalendar);
|
||||
#endif
|
||||
menu.addSeparator();
|
||||
|
||||
// ride navigator stuff
|
||||
QAction *colChooser = new QAction(tr("Show Column Chooser"), treeWidget);
|
||||
connect(colChooser, SIGNAL(triggered(void)), listView, SLOT(showColumnChooser()));
|
||||
menu.addAction(colChooser);
|
||||
|
||||
if (listView->groupBy() >= 0) {
|
||||
|
||||
// already grouped lets ungroup
|
||||
QAction *nogroups = new QAction(tr("Do Not Show In Groups"), treeWidget);
|
||||
connect(nogroups, SIGNAL(triggered(void)), listView, SLOT(noGroups()));
|
||||
menu.addAction(nogroups);
|
||||
|
||||
} else {
|
||||
|
||||
QMenu *groupByMenu = new QMenu(tr("Group By"), treeWidget);
|
||||
groupByMenu->setEnabled(true);
|
||||
menu.addMenu(groupByMenu);
|
||||
|
||||
// add menu options for each column
|
||||
if (groupByMapper) delete groupByMapper;
|
||||
groupByMapper = new QSignalMapper(this);
|
||||
connect(groupByMapper, SIGNAL(mapped(const QString &)), listView, SLOT(setGroupByColumnName(QString)));
|
||||
|
||||
foreach(QString heading, listView->columnNames()) {
|
||||
if (heading == "*") continue; // special hidden column
|
||||
|
||||
QAction *groupByAct = new QAction(heading, treeWidget);
|
||||
connect(groupByAct, SIGNAL(triggered()), groupByMapper, SLOT(map()));
|
||||
groupByMenu->addAction(groupByAct);
|
||||
|
||||
// map action to column heading
|
||||
groupByMapper->setMapping(groupByAct, heading);
|
||||
}
|
||||
}
|
||||
menu.exec(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +445,7 @@ class MainWindow : public QMainWindow
|
||||
IntervalTreeView *intervalWidget;
|
||||
|
||||
// Miscellany
|
||||
QSignalMapper *groupByMapper;
|
||||
QSignalMapper *toolMapper;
|
||||
WithingsDownload *withingsDownload;
|
||||
ZeoDownload *zeoDownload;
|
||||
|
||||
@@ -124,6 +124,7 @@ RideNavigator::RideNavigator(MainWindow *parent, bool mainwindow) : main(parent)
|
||||
|
||||
// we accept drag and drop operations
|
||||
setAcceptDrops(true);
|
||||
columnsChanged(); // set visual headings etc
|
||||
}
|
||||
|
||||
RideNavigator::~RideNavigator()
|
||||
@@ -361,6 +362,31 @@ RideNavigator::showEvent(QShowEvent *)
|
||||
setWidth(geometry().width());
|
||||
}
|
||||
|
||||
// routines called by the sidebar to let the user
|
||||
// update the columns/grouping without using right-click
|
||||
QStringList
|
||||
RideNavigator::columnNames() const
|
||||
{
|
||||
return visualHeadings;
|
||||
}
|
||||
|
||||
void
|
||||
RideNavigator::setGroupByColumnName(QString name)
|
||||
{
|
||||
if (name == "") {
|
||||
|
||||
noGroups();
|
||||
|
||||
} else {
|
||||
|
||||
int logical = logicalHeadings.indexOf(name);
|
||||
if (logical >= 0) {
|
||||
currentColumn = logical;
|
||||
setGroupByColumn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RideNavigator::columnsChanged()
|
||||
{
|
||||
|
||||
@@ -120,6 +120,12 @@ class RideNavigator : public GcWindow
|
||||
QString columns() const { return _columns; }
|
||||
void setColumns(QString x) { _columns = x; }
|
||||
|
||||
// These are used in the main sidebar to let the users
|
||||
// add remove columns etc without using right click
|
||||
QStringList columnNames() const;
|
||||
void setGroupByColumnName(QString); // set blank turns it off
|
||||
void noGroups() { currentColumn=-1; setGroupByColumn(); }
|
||||
|
||||
QString widths() const { return _widths; }
|
||||
void setWidths (QString x) { _widths = x; resetView(); } // only reset once widths are set
|
||||
|
||||
|
||||
Reference in New Issue
Block a user