Changed: Mission Compiler add/remove selected/all and reset filter functions.

This commit is contained in:
sfb 2011-06-07 14:30:34 -05:00
parent 0685091cda
commit effaba1a11
3 changed files with 87 additions and 10 deletions

View file

@ -51,13 +51,24 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) :
m_selectedPrimitivesModel = new QStringListModel(this); m_selectedPrimitivesModel = new QStringListModel(this);
ui->selectedPrimitivesList->setModel(m_selectedPrimitivesModel); ui->selectedPrimitivesList->setModel(m_selectedPrimitivesModel);
connect(ui->filterEdit, SIGNAL(textEdited(const QString&)), this, SLOT(handleFilterChanged(const QString&))); // Connections for toolbar buttons.
connect(ui->actionValidate, SIGNAL(triggered()), this, SLOT(handleValidation())); connect(ui->actionValidate, SIGNAL(triggered()), this, SLOT(handleValidation()));
connect(ui->actionCompile, SIGNAL(triggered()), this, SLOT(handleCompile())); connect(ui->actionCompile, SIGNAL(triggered()), this, SLOT(handleCompile()));
connect(ui->actionPublish, SIGNAL(triggered()), this, SLOT(handlePublish())); connect(ui->actionPublish, SIGNAL(triggered()), this, SLOT(handlePublish()));
// Connections for selected item moves.
connect(ui->allPrimitivesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(handleAllDoubleClick(const QModelIndex &))); connect(ui->allPrimitivesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(handleAllDoubleClick(const QModelIndex &)));
connect(ui->selectedPrimitivesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(handleSelDoubleClick(const QModelIndex &)));
connect(ui->addSelectedButton, SIGNAL(clicked()), this, SLOT(handleMoveSelectedRight()));
connect(ui->removeSelectedButton, SIGNAL(clicked()), this, SLOT(handleMoveSelectedLeft()));
connect(ui->addAllButton, SIGNAL(clicked()), this, SLOT(handleMoveAllRight()));
connect(ui->removeAllButton, SIGNAL(clicked()), this, SLOT(handleMoveAllLeft()));
// Connections for the filter group box.
connect(ui->dataDirButton, SIGNAL(clicked()), this, SLOT(handleDataDirButton())); connect(ui->dataDirButton, SIGNAL(clicked()), this, SLOT(handleDataDirButton()));
connect(ui->dataDirEdit, SIGNAL(textChanged(const QString &)), this, SLOT(handleDataDirChanged(const QString &))); connect(ui->dataDirEdit, SIGNAL(textChanged(const QString &)), this, SLOT(handleDataDirChanged(const QString &)));
connect(ui->filterEdit, SIGNAL(textEdited(const QString&)), this, SLOT(handleFilterChanged(const QString&)));
connect(ui->resetFiltersButton, SIGNAL(clicked()), this, SLOT(handleResetFiltersButton()));
// Set the default data dir to the primitives path. // Set the default data dir to the primitives path.
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
@ -96,6 +107,14 @@ void MissionCompilerMainWindow::populateAllPrimitives(const QString &dataDir)
m_allPrimitivesModel->setStringList(list); m_allPrimitivesModel->setStringList(list);
} }
void MissionCompilerMainWindow::handleResetFiltersButton()
{
handleDataDirChanged(m_lastDir);
ui->filterEdit->setText("");
handleFilterChanged("");
}
void MissionCompilerMainWindow::handleDataDirChanged(const QString &text) void MissionCompilerMainWindow::handleDataDirChanged(const QString &text)
{ {
populateAllPrimitives(text); populateAllPrimitives(text);
@ -128,17 +147,58 @@ void MissionCompilerMainWindow::handlePublish()
compileMission(true); compileMission(true);
} }
void MissionCompilerMainWindow::handleMoveSelectedRight()
{
QModelIndexList indexes = ui->allPrimitivesList->selectionModel()->selectedIndexes();
while(!indexes.isEmpty())
{
const QModelIndex index = indexes.takeFirst();
moveSelectedItem(index, m_allPrimitivesModel, m_selectedPrimitivesModel);
indexes = ui->allPrimitivesList->selectionModel()->selectedIndexes();
}
}
void MissionCompilerMainWindow::handleMoveAllRight()
{
ui->allPrimitivesList->selectAll();
handleMoveSelectedRight();
}
void MissionCompilerMainWindow::handleMoveSelectedLeft()
{
QModelIndexList indexes = ui->selectedPrimitivesList->selectionModel()->selectedIndexes();
while(!indexes.isEmpty())
{
const QModelIndex index = indexes.takeFirst();
moveSelectedItem(index, m_selectedPrimitivesModel, m_allPrimitivesModel);
indexes = ui->selectedPrimitivesList->selectionModel()->selectedIndexes();
}
}
void MissionCompilerMainWindow::handleMoveAllLeft()
{
ui->selectedPrimitivesList->selectAll();
handleMoveSelectedLeft();
}
void MissionCompilerMainWindow::moveSelectedItem(const QModelIndex &index, QStringListModel *from, QStringListModel *to)
{
QString item = from->data(index, Qt::DisplayRole).toString();
from->removeRows(index.row(),1);
QStringList list = to->stringList();
list << item;
to->setStringList(list);
}
void MissionCompilerMainWindow::handleAllDoubleClick(const QModelIndex &index) void MissionCompilerMainWindow::handleAllDoubleClick(const QModelIndex &index)
{ {
const QAbstractItemModel *model = index.model(); moveSelectedItem(index, m_allPrimitivesModel, m_selectedPrimitivesModel);
QString item = model->data(index).toString(); }
nlinfo("all primitives was double clicked: %s", item.toAscii().data());
m_filteredProxyModel->removeRows(index.row(),1); void MissionCompilerMainWindow::handleSelDoubleClick(const QModelIndex &index)
{
QStringList list = m_selectedPrimitivesModel->stringList(); moveSelectedItem(index, m_selectedPrimitivesModel, m_allPrimitivesModel);
list << item;
m_selectedPrimitivesModel->setStringList(list);
} }
void MissionCompilerMainWindow::compileMission(bool publish) void MissionCompilerMainWindow::compileMission(bool publish)

View file

@ -39,8 +39,14 @@ public Q_SLOTS:
void handleCompile(); void handleCompile();
void handlePublish(); void handlePublish();
void handleAllDoubleClick(const QModelIndex &index); void handleAllDoubleClick(const QModelIndex &index);
void handleSelDoubleClick(const QModelIndex &index);
void handleMoveSelectedRight();
void handleMoveSelectedLeft();
void handleMoveAllRight();
void handleMoveAllLeft();
void handleDataDirButton(); void handleDataDirButton();
void handleDataDirChanged(const QString &text); void handleDataDirChanged(const QString &text);
void handleResetFiltersButton();
private: private:
Ui::MissionCompilerMainWindow *ui; Ui::MissionCompilerMainWindow *ui;
@ -49,6 +55,7 @@ private:
void populateAllPrimitives(const QString &dataDir = QString()); void populateAllPrimitives(const QString &dataDir = QString());
bool parsePrimForMissions(NLLIGO::IPrimitive const *prim, TMissionContainer &missions); bool parsePrimForMissions(NLLIGO::IPrimitive const *prim, TMissionContainer &missions);
void compileMission(bool publish=false); void compileMission(bool publish=false);
void moveSelectedItem(const QModelIndex &index, QStringListModel *from, QStringListModel *to);
QMenu *_toolModeMenu; QMenu *_toolModeMenu;
QUndoStack *m_undoStack; QUndoStack *m_undoStack;

View file

@ -239,6 +239,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="resetFiltersButton">
<property name="toolTip">
<string>Blanks out the filter and reloads all files from the data directory.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>