summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpptoolsplugin.cpp
diff options
context:
space:
mode:
authorhjk <qthjk@ovi.com>2012-10-10 21:00:48 +0200
committerhjk <qthjk@ovi.com>2012-10-12 14:48:42 +0200
commit0df1ee1abd30703722c83a5c43c4fff4a14ab779 (patch)
treebf3c2faf8203d11d661e330373eb712775f49f20 /src/plugins/cpptools/cpptoolsplugin.cpp
parent315a3ebdebc20b91fd509be4f3eca600f716c601 (diff)
downloadqt-creator-0df1ee1abd30703722c83a5c43c4fff4a14ab779.tar.gz
CppTools: make correspondingHeaderOrSource freely accessible
Change-Id: Ic8aba607157381359984ef1c99b2f32161daaecd Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp')
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp
index e368f6c2bb..d1742ea51e 100644
--- a/src/plugins/cpptools/cpptoolsplugin.cpp
+++ b/src/plugins/cpptools/cpptoolsplugin.cpp
@@ -39,6 +39,7 @@
#include "cpplocatorfilter.h"
#include "symbolsfindfilter.h"
#include "cpptoolssettings.h"
+#include "cpptoolsreuse.h"
#include <extensionsystem/pluginmanager.h>
@@ -74,12 +75,15 @@
#include <sstream>
-using namespace CppTools::Internal;
using namespace CPlusPlus;
+namespace CppTools {
+namespace Internal {
+
enum { debug = 0 };
static CppToolsPlugin *m_instance = 0;
+static QHash<QString, QString> m_headerSourceMapping;
CppToolsPlugin::CppToolsPlugin() :
m_modelManager(0),
@@ -250,16 +254,23 @@ static int commonStringLength(const QString &s1, const QString &s2)
return length;
}
-QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) const
+} // namespace Internal
+
+QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
{
- const QFileInfo fi(fileName);
- if (m_headerSourceMapping.contains(fi.absoluteFilePath()))
- return m_headerSourceMapping.value(fi.absoluteFilePath());
+ using namespace Internal;
const Core::MimeDatabase *mimeDatase = Core::ICore::mimeDatabase();
- ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject();
+ const QFileInfo fi(fileName);
+ if (m_headerSourceMapping.contains(fi.absoluteFilePath())) {
+ if (wasHeader)
+ *wasHeader = fileType(mimeDatase, fi) == HeaderFile;
+ return m_headerSourceMapping.value(fi.absoluteFilePath());
+ }
- const FileType type = fileType(mimeDatase, fi);
+ FileType type = fileType(mimeDatase, fi);
+ if (wasHeader)
+ *wasHeader = type == HeaderFile;
if (debug)
qDebug() << Q_FUNC_INFO << fileName << type;
@@ -298,6 +309,7 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co
}
// Find files in the project
+ ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject();
if (project) {
QString bestFileName;
int compareValue = 0;
@@ -324,12 +336,6 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co
return QString();
}
-QString CppToolsPlugin::correspondingHeaderOrSource(const QString &fileName)
-{
- const QString rc = m_instance->correspondingHeaderOrSourceI(fileName);
- if (debug)
- qDebug() << Q_FUNC_INFO << fileName << rc;
- return rc;
-}
+} // namespace CppTools
-Q_EXPORT_PLUGIN(CppToolsPlugin)
+Q_EXPORT_PLUGIN(CppTools::Internal::CppToolsPlugin)