2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "currentprojectfind.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectexplorer.h"
|
2011-09-07 20:28:04 +02:00
|
|
|
#include "project.h"
|
2011-12-13 10:50:57 +01:00
|
|
|
#include "session.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-12-13 10:50:57 +01:00
|
|
|
#include <coreplugin/ifile.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
2009-10-01 16:38:08 +02:00
|
|
|
#include <QtCore/QSettings>
|
2011-09-07 20:28:04 +02:00
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QHBoxLayout>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace Find;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
2011-09-02 11:51:31 +02:00
|
|
|
CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin)
|
|
|
|
|
: AllProjectsFind(plugin),
|
2010-10-11 10:23:30 +02:00
|
|
|
m_plugin(plugin)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
connect(m_plugin, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
2011-12-14 15:55:05 +01:00
|
|
|
this, SLOT(handleProjectChanged()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-03 15:53:29 +02:00
|
|
|
QString CurrentProjectFind::id() const
|
|
|
|
|
{
|
2010-02-01 12:43:56 +01:00
|
|
|
return QLatin1String("Current Project");
|
2009-04-03 15:53:29 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-12 12:06:15 +02:00
|
|
|
QString CurrentProjectFind::displayName() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return tr("Current Project");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CurrentProjectFind::isEnabled() const
|
|
|
|
|
{
|
2012-01-24 18:57:39 +01:00
|
|
|
return ProjectExplorerPlugin::currentProject() != 0 && BaseFileFind::isEnabled();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-12-13 10:50:57 +01:00
|
|
|
QVariant CurrentProjectFind::additionalParameters() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-01-24 18:57:39 +01:00
|
|
|
Project *project = ProjectExplorerPlugin::currentProject();
|
|
|
|
|
if (project && project->file())
|
|
|
|
|
return qVariantFromValue(project->file()->fileName());
|
2011-12-13 10:50:57 +01:00
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters,
|
|
|
|
|
const QVariant &additionalParameters) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(additionalParameters.isValid(), return new Utils::FileIterator());
|
|
|
|
|
QList<Project *> allProjects = m_plugin->session()->projects();
|
|
|
|
|
QString projectFile = additionalParameters.toString();
|
|
|
|
|
foreach (Project *project, allProjects) {
|
|
|
|
|
if (project->file() && projectFile == project->file()->fileName())
|
|
|
|
|
return filesForProjects(nameFilters, QList<Project *>() << project);
|
|
|
|
|
}
|
|
|
|
|
return new Utils::FileIterator();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-07 20:28:04 +02:00
|
|
|
QString CurrentProjectFind::label() const
|
|
|
|
|
{
|
2012-01-24 18:57:39 +01:00
|
|
|
QTC_ASSERT(ProjectExplorerPlugin::currentProject(), return QString());
|
|
|
|
|
return tr("Project '%1':").arg(ProjectExplorerPlugin::currentProject()->displayName());
|
2011-09-07 20:28:04 +02:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 15:55:05 +01:00
|
|
|
void CurrentProjectFind::handleProjectChanged()
|
|
|
|
|
{
|
|
|
|
|
emit enabledChanged(isEnabled());
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void CurrentProjectFind::writeSettings(QSettings *settings)
|
|
|
|
|
{
|
2010-02-01 12:43:56 +01:00
|
|
|
settings->beginGroup(QLatin1String("CurrentProjectFind"));
|
2008-12-02 12:01:29 +01:00
|
|
|
writeCommonSettings(settings);
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CurrentProjectFind::readSettings(QSettings *settings)
|
|
|
|
|
{
|
2010-02-01 12:43:56 +01:00
|
|
|
settings->beginGroup(QLatin1String("CurrentProjectFind"));
|
|
|
|
|
readCommonSettings(settings, QString(QLatin1Char('*')));
|
2008-12-02 12:01:29 +01:00
|
|
|
settings->endGroup();
|
|
|
|
|
}
|