summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@theqtcompany.com>2015-05-12 13:15:04 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-05-13 09:41:21 +0300
commit03354a6a0542773b89cbf757f158f0a629a565f6 (patch)
tree987cdd8b15ebc6dc984360e7e88e6f9007e07ec7
parent5526421cebf492249c415a4ef75f56e6455340e0 (diff)
downloadqt-creator-03354a6a0542773b89cbf757f158f0a629a565f6.tar.gz
Add basic 'Close Test Suite' functionality
Change-Id: I1e0a6d51d170ff186ac0ad50a62a35de83964160 Reviewed-by: Robert Loehning <robert.loehning@theqtcompany.com>
-rw-r--r--plugins/autotest/testnavigationwidget.cpp15
-rw-r--r--plugins/autotest/testsquishfilehandler.cpp21
-rw-r--r--plugins/autotest/testsquishfilehandler.h3
-rw-r--r--plugins/autotest/testtreemodel.cpp2
4 files changed, 41 insertions, 0 deletions
diff --git a/plugins/autotest/testnavigationwidget.cpp b/plugins/autotest/testnavigationwidget.cpp
index 2a15c36013..c0c65eb22a 100644
--- a/plugins/autotest/testnavigationwidget.cpp
+++ b/plugins/autotest/testnavigationwidget.cpp
@@ -37,6 +37,7 @@
#include <QAction>
#include <QMenu>
+#include <QMessageBox>
#include <QTimer>
#include <QToolButton>
#include <QVBoxLayout>
@@ -107,6 +108,7 @@ bool TestNavigationWidget::handleSquishContextMenuEvent(QContextMenuEvent *event
deleteTestCase->setEnabled(enabled);
menu.addSeparator();
} else if (type == TestTreeItem::SQUISH_SUITE) {
+ const QString suiteName = list.first().data().toString();
isSquishMenu = true;
QAction *runThisTestSuite = new QAction(tr("Run This Test Suite"), &menu);
menu.addAction(runThisTestSuite);
@@ -122,6 +124,11 @@ bool TestNavigationWidget::handleSquishContextMenuEvent(QContextMenuEvent *event
menu.addAction(deleteTestSuite);
deleteTestSuite->setEnabled(enabled);
menu.addSeparator();
+
+ connect(closeTestSuite, &QAction::triggered,
+ [suiteName] () {
+ TestSquishFileHandler::instance()->closeTestSuite(suiteName);
+ });
}
}
}
@@ -148,6 +155,14 @@ bool TestNavigationWidget::handleSquishContextMenuEvent(QContextMenuEvent *event
QAction *closeAllSuites = new QAction(tr("Close All Test Suites"), &menu);
menu.addAction(closeAllSuites);
closeAllSuites->setEnabled(enabled);
+
+ connect(closeAllSuites, &QAction::triggered, [this] () {
+ if (QMessageBox::question(this, tr("Close All Test Suites"),
+ tr("Are you sure you want to close all test suites?"
+ /*"\nThis will close all related files as well."*/))
+ == QMessageBox::Yes)
+ TestSquishFileHandler::instance()->closeAllTestSuites();
+ });
}
menu.exec(mapToGlobal(event->pos()));
diff --git a/plugins/autotest/testsquishfilehandler.cpp b/plugins/autotest/testsquishfilehandler.cpp
index 3e8ac46104..26a2f718b0 100644
--- a/plugins/autotest/testsquishfilehandler.cpp
+++ b/plugins/autotest/testsquishfilehandler.cpp
@@ -89,5 +89,26 @@ void TestSquishFileHandler::openTestSuites()
}
}
+void TestSquishFileHandler::closeTestSuite(const QString &suite)
+{
+ const QString suiteConf = m_suites.value(suite);
+ if (suiteConf.isEmpty())
+ return;
+
+ // TODO close respective editors if there are any
+ // TODO remove file watcher
+ emit testTreeItemsRemoved(suiteConf, TestTreeModel::SquishTest);
+ m_suites.remove(suite);
+}
+
+void TestSquishFileHandler::closeAllTestSuites()
+{
+ // TODO close respective editors if there are any
+ // TODO remove file watcher
+ foreach (const QString &suiteConf, m_suites.values())
+ emit testTreeItemsRemoved(suiteConf, TestTreeModel::SquishTest);
+ m_suites.clear();
+}
+
} // namespace Internal
} // namespace Autotest
diff --git a/plugins/autotest/testsquishfilehandler.h b/plugins/autotest/testsquishfilehandler.h
index 66c6ccecdd..a63d435929 100644
--- a/plugins/autotest/testsquishfilehandler.h
+++ b/plugins/autotest/testsquishfilehandler.h
@@ -38,10 +38,13 @@ public:
static TestSquishFileHandler *instance();
void openTestSuites();
+ void closeTestSuite(const QString &suite);
+ void closeAllTestSuites();
signals:
void testTreeItemCreated(const TestTreeItem &item, TestTreeModel::Type type);
void testTreeItemModified(const TestTreeItem &item, TestTreeModel::Type type, const QString &file);
+ void testTreeItemsRemoved(const QString &filePath, TestTreeModel::Type type);
private:
QMap<QString, QString> m_suites;
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index 82bdf23a84..5e9aaa4aea 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -81,6 +81,8 @@ TestTreeModel::TestTreeModel(QObject *parent) :
this, &TestTreeModel::addTestTreeItem, Qt::QueuedConnection);
connect(m_squishFileHandler, &TestSquishFileHandler::testTreeItemModified,
this, &TestTreeModel::modifyTestTreeItem, Qt::QueuedConnection);
+ connect(m_squishFileHandler, &TestSquishFileHandler::testTreeItemsRemoved,
+ this, &TestTreeModel::removeTestTreeItems, Qt::QueuedConnection);
// CppTools::CppModelManagerInterface *cppMM = CppTools::CppModelManagerInterface::instance();
// if (cppMM) {