mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added code to select / desselect a range of items
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
c385e7aae8
commit
7add8594a7
2 changed files with 31 additions and 12 deletions
|
@ -34,21 +34,14 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()),
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
sortModel->setSourceModel(model);
|
sortModel->setSourceModel(model);
|
||||||
ui->ListWidget->setModel(sortModel);
|
ui->ListWidget->setModel(sortModel);
|
||||||
connect(ui->ListWidget, SIGNAL(activated(QModelIndex)), this, SLOT(diveSelected(QModelIndex)));
|
|
||||||
setWindowIcon(QIcon(":subsurface-icon"));
|
setWindowIcon(QIcon(":subsurface-icon"));
|
||||||
|
|
||||||
|
connect(ui->ListWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
|
this, SLOT(dive_selection_changed(QItemSelection,QItemSelection)));
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::diveSelected(const QModelIndex& index)
|
|
||||||
{
|
|
||||||
struct dive *dive = (struct dive*) index.model()->data(index, TreeItemDT::DIVE_ROLE).value<void*>();
|
|
||||||
|
|
||||||
if (dive)
|
|
||||||
selected_dive = get_index_for_dive(dive);
|
|
||||||
|
|
||||||
// Here should be the code to update the other widgets.
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionNew_triggered()
|
void MainWindow::on_actionNew_triggered()
|
||||||
{
|
{
|
||||||
qDebug("actionNew");
|
qDebug("actionNew");
|
||||||
|
@ -85,6 +78,30 @@ void MainWindow::on_actionOpen_triggered()
|
||||||
ui->ListWidget->sortByColumn(0, Qt::DescendingOrder);
|
ui->ListWidget->sortByColumn(0, Qt::DescendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::dive_selection_changed(const QItemSelection& newSelection, const QItemSelection& oldSelection)
|
||||||
|
{
|
||||||
|
// struct dive *dive = (struct dive*) index.model()->data(index, TreeItemDT::DIVE_ROLE).value<void*>();
|
||||||
|
//if (dive)
|
||||||
|
// selected_dive = get_index_for_dive(dive);
|
||||||
|
Q_FOREACH(const QModelIndex& desselect, oldSelection.indexes()){
|
||||||
|
struct dive *d = (struct dive*) desselect.data(TreeItemDT::DIVE_ROLE).value<void*>();
|
||||||
|
if (!d)
|
||||||
|
continue;
|
||||||
|
d->selected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct dive *lastSelected = 0;
|
||||||
|
Q_FOREACH(const QModelIndex& select, oldSelection.indexes()){
|
||||||
|
struct dive *d = (struct dive*) select.data(TreeItemDT::DIVE_ROLE).value<void*>();
|
||||||
|
if (!d)
|
||||||
|
continue;
|
||||||
|
d->selected = true;
|
||||||
|
lastSelected = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
select_dive( get_divenr(lastSelected) );
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionSave_triggered()
|
void MainWindow::on_actionSave_triggered()
|
||||||
{
|
{
|
||||||
qDebug("actionSave");
|
qDebug("actionSave");
|
||||||
|
|
|
@ -22,6 +22,7 @@ class DiveInfo;
|
||||||
class DiveNotes;
|
class DiveNotes;
|
||||||
class Stats;
|
class Stats;
|
||||||
class Equipment;
|
class Equipment;
|
||||||
|
class QItemSelection;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -67,7 +68,8 @@ private Q_SLOTS:
|
||||||
void on_actionAboutSubsurface_triggered();
|
void on_actionAboutSubsurface_triggered();
|
||||||
void on_actionUserManual_triggered();
|
void on_actionUserManual_triggered();
|
||||||
|
|
||||||
void diveSelected(const QModelIndex& index);
|
void dive_selection_changed(const QItemSelection& newSelection,
|
||||||
|
const QItemSelection& oldSelection);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
|
|
Loading…
Add table
Reference in a new issue