1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-6: Removed some more unused classes

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@369 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
julien 2010-03-21 21:24:45 +00:00 committed by julien
parent 69c05a5252
commit c3f7df4f03
9 changed files with 5 additions and 1102 deletions

View File

@ -1,660 +0,0 @@
/**
******************************************************************************
*
* @file basefilewizard.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup coreplugin
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "basefilewizard.h"
#include "coreconstants.h"
#include "icore.h"
#include "ifilewizardextension.h"
#include "mimedatabase.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/filewizarddialog.h>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QVector>
#include <QtCore/QDebug>
#include <QtCore/QSharedData>
#include <QtCore/QEventLoop>
#include <QtCore/QSharedPointer>
#include <QtGui/QMessageBox>
#include <QtGui/QWizard>
#include <QtGui/QMainWindow>
enum { debugWizard = 0 };
namespace Core {
class GeneratedFilePrivate : public QSharedData
{
public:
GeneratedFilePrivate() : binary(false) {}
explicit GeneratedFilePrivate(const QString &p);
QString path;
QByteArray contents;
QString editorKind;
bool binary;
};
GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) :
path(p),
binary(false)
{
}
GeneratedFile::GeneratedFile() :
m_d(new GeneratedFilePrivate)
{
}
GeneratedFile::GeneratedFile(const QString &p) :
m_d(new GeneratedFilePrivate(p))
{
}
GeneratedFile::GeneratedFile(const GeneratedFile &rhs) :
m_d(rhs.m_d)
{
}
GeneratedFile &GeneratedFile::operator=(const GeneratedFile &rhs)
{
if (this != &rhs)
m_d.operator=(rhs.m_d);
return *this;
}
GeneratedFile::~GeneratedFile()
{
}
QString GeneratedFile::path() const
{
return m_d->path;
}
void GeneratedFile::setPath(const QString &p)
{
m_d->path = p;
}
QString GeneratedFile::contents() const
{
return QString::fromUtf8(m_d->contents);
}
void GeneratedFile::setContents(const QString &c)
{
m_d->contents = c.toUtf8();
}
QByteArray GeneratedFile::binaryContents() const
{
return m_d->contents;
}
void GeneratedFile::setBinaryContents(const QByteArray &c)
{
m_d->contents = c;
}
bool GeneratedFile::isBinary() const
{
return m_d->binary;
}
void GeneratedFile::setBinary(bool b)
{
m_d->binary = b;
}
QString GeneratedFile::editorKind() const
{
return m_d->editorKind;
}
void GeneratedFile::setEditorKind(const QString &k)
{
m_d->editorKind = k;
}
bool GeneratedFile::write(QString *errorMessage) const
{
// Ensure the directory
const QFileInfo info(m_d->path);
const QDir dir = info.absoluteDir();
if (!dir.exists()) {
if (!dir.mkpath(dir.absolutePath())) {
*errorMessage = BaseFileWizard::tr("Unable to create the directory %1.").arg(dir.absolutePath());
return false;
}
}
// Write out
QFile file(m_d->path);
QIODevice::OpenMode flags = QIODevice::WriteOnly|QIODevice::Truncate;
if (!isBinary())
flags |= QIODevice::Text;
if (!file.open(flags)) {
*errorMessage = BaseFileWizard::tr("Unable to open %1 for writing: %2").arg(m_d->path, file.errorString());
return false;
}
if (file.write(m_d->contents) == -1) {
*errorMessage = BaseFileWizard::tr("Error while writing to %1: %2").arg(m_d->path, file.errorString());
return false;
}
file.close();
return true;
}
// ------------ BaseFileWizardParameterData
class BaseFileWizardParameterData : public QSharedData
{
public:
explicit BaseFileWizardParameterData(IWizard::Kind kind = IWizard::FileWizard);
IWizard::Kind kind;
QIcon icon;
QString description;
QString name;
QString category;
QString trCategory;
};
BaseFileWizardParameterData::BaseFileWizardParameterData(IWizard::Kind k) :
kind(k)
{
}
BaseFileWizardParameters::BaseFileWizardParameters(IWizard::Kind kind) :
m_d(new BaseFileWizardParameterData(kind))
{
}
BaseFileWizardParameters::BaseFileWizardParameters(const BaseFileWizardParameters &rhs) :
m_d(rhs.m_d)
{
}
BaseFileWizardParameters &BaseFileWizardParameters::operator=(const BaseFileWizardParameters &rhs)
{
if (this != &rhs)
m_d.operator=(rhs.m_d);
return *this;
}
BaseFileWizardParameters::~BaseFileWizardParameters()
{
}
IWizard::Kind BaseFileWizardParameters::kind() const
{
return m_d->kind;
}
void BaseFileWizardParameters::setKind(IWizard::Kind k)
{
m_d->kind = k;
}
QIcon BaseFileWizardParameters::icon() const
{
return m_d->icon;
}
void BaseFileWizardParameters::setIcon(const QIcon &icon)
{
m_d->icon = icon;
}
QString BaseFileWizardParameters::description() const
{
return m_d->description;
}
void BaseFileWizardParameters::setDescription(const QString &v)
{
m_d->description = v;
}
QString BaseFileWizardParameters::name() const
{
return m_d->name;
}
void BaseFileWizardParameters::setName(const QString &v)
{
m_d->name = v;
}
QString BaseFileWizardParameters::category() const
{
return m_d->category;
}
void BaseFileWizardParameters::setCategory(const QString &v)
{
m_d->category = v;
}
QString BaseFileWizardParameters::trCategory() const
{
return m_d->trCategory;
}
void BaseFileWizardParameters::setTrCategory(const QString &v)
{
m_d->trCategory = v;
}
/* WizardEventLoop: Special event loop that runs a QWizard and terminates if the page changes.
* Synopsis:
* \code
Wizard wizard(parent);
WizardEventLoop::WizardResult wr;
do {
wr = WizardEventLoop::execWizardPage(wizard);
} while (wr == WizardEventLoop::PageChanged);
* \endcode */
class WizardEventLoop : public QEventLoop
{
Q_OBJECT
Q_DISABLE_COPY(WizardEventLoop)
WizardEventLoop(QObject *parent);
public:
enum WizardResult { Accepted, Rejected , PageChanged };
static WizardResult execWizardPage(QWizard &w);
private slots:
void pageChanged(int);
void accepted();
void rejected();
private:
WizardResult execWizardPageI();
WizardResult m_result;
};
WizardEventLoop::WizardEventLoop(QObject *parent) :
QEventLoop(parent),
m_result(Rejected)
{
}
WizardEventLoop::WizardResult WizardEventLoop::execWizardPage(QWizard &wizard)
{
/* Install ourselves on the wizard. Main trick is here to connect
* to the page changed signal and quit() on it. */
WizardEventLoop *eventLoop = wizard.findChild<WizardEventLoop *>();
if (!eventLoop) {
eventLoop = new WizardEventLoop(&wizard);
connect(&wizard, SIGNAL(currentIdChanged(int)), eventLoop, SLOT(pageChanged(int)));
connect(&wizard, SIGNAL(accepted()), eventLoop, SLOT(accepted()));
connect(&wizard, SIGNAL(rejected()), eventLoop, SLOT(rejected()));
wizard.setAttribute(Qt::WA_ShowModal, true);
wizard.show();
}
const WizardResult result = eventLoop->execWizardPageI();
// Quitting?
if (result != PageChanged)
delete eventLoop;
if (debugWizard)
qDebug() << "WizardEventLoop::runWizard" << wizard.pageIds() << " returns " << result;
return result;
}
WizardEventLoop::WizardResult WizardEventLoop::execWizardPageI()
{
m_result = Rejected;
exec(QEventLoop::DialogExec);
return m_result;
}
void WizardEventLoop::pageChanged(int /*page*/)
{
m_result = PageChanged;
quit(); // !
}
void WizardEventLoop::accepted()
{
m_result = Accepted;
quit();
}
void WizardEventLoop::rejected()
{
m_result = Rejected;
quit();
}
// ---------------- BaseFileWizardPrivate
struct BaseFileWizardPrivate
{
explicit BaseFileWizardPrivate(const Core::BaseFileWizardParameters &parameters)
: m_parameters(parameters), m_wizardDialog(0)
{}
const Core::BaseFileWizardParameters m_parameters;
QWizard *m_wizardDialog;
};
// ---------------- Wizard
BaseFileWizard::BaseFileWizard(const BaseFileWizardParameters &parameters,
QObject *parent) :
IWizard(parent),
m_d(new BaseFileWizardPrivate(parameters))
{
}
BaseFileWizard::~BaseFileWizard()
{
delete m_d;
}
IWizard::Kind BaseFileWizard::kind() const
{
return m_d->m_parameters.kind();
}
QIcon BaseFileWizard::icon() const
{
return m_d->m_parameters.icon();
}
QString BaseFileWizard::description() const
{
return m_d->m_parameters.description();
}
QString BaseFileWizard::name() const
{
return m_d->m_parameters.name();
}
QString BaseFileWizard::category() const
{
return m_d->m_parameters.category();
}
QString BaseFileWizard::trCategory() const
{
return m_d->m_parameters.trCategory();
}
QStringList BaseFileWizard::runWizard(const QString &path, QWidget *parent)
{
typedef QList<IFileWizardExtension*> ExtensionList;
QString errorMessage;
// Compile extension pages, purge out unused ones
ExtensionList extensions = ExtensionSystem::PluginManager::instance()->getObjects<IFileWizardExtension>();
WizardPageList allExtensionPages;
for (ExtensionList::iterator it = extensions.begin(); it != extensions.end(); ) {
const WizardPageList extensionPages = (*it)->extensionPages(this);
if (extensionPages.empty()) {
it = extensions.erase(it);
} else {
allExtensionPages += extensionPages;
++it;
}
}
if (debugWizard)
qDebug() << Q_FUNC_INFO << path << parent << "exs" << extensions.size() << allExtensionPages.size();
QWizardPage *firstExtensionPage = 0;
if (!allExtensionPages.empty())
firstExtensionPage = allExtensionPages.front();
// Create dialog and run it. Ensure that the dialog is deleted when
// leaving the func, but not before the IFileWizardExtension::process
// has been called
const QSharedPointer<QWizard> wizard(createWizardDialog(parent, path, allExtensionPages));
GeneratedFiles files;
// Run the wizard: Call generate files on switching to the first extension
// page is OR after 'Accepted' if there are no extension pages
while (true) {
const WizardEventLoop::WizardResult wr = WizardEventLoop::execWizardPage(*wizard);
if (wr == WizardEventLoop::Rejected) {
files.clear();
break;
}
const bool accepted = wr == WizardEventLoop::Accepted;
const bool firstExtensionPageHit = wr == WizardEventLoop::PageChanged
&& wizard->page(wizard->currentId()) == firstExtensionPage;
const bool needGenerateFiles = firstExtensionPageHit || (accepted && allExtensionPages.empty());
if (needGenerateFiles) {
QString errorMessage;
files = generateFiles(wizard.data(), &errorMessage);
if (files.empty()) {
QMessageBox::critical(0, tr("File Generation Failure"), errorMessage);
break;
}
}
if (firstExtensionPageHit)
foreach (IFileWizardExtension *ex, extensions)
ex->firstExtensionPageShown(files);
if (accepted)
break;
}
if (files.empty())
return QStringList();
// Compile result list and prompt for overwrite
QStringList result;
foreach (const GeneratedFile &generatedFile, files)
result.push_back(generatedFile.path());
switch (promptOverwrite(path, result, &errorMessage)) {
case OverwriteCanceled:
return QStringList();
case OverwriteError:
QMessageBox::critical(0, tr("Existing files"), errorMessage);
return QStringList();
case OverwriteOk:
break;
}
// Write
foreach (const GeneratedFile &generatedFile, files) {
if (!generatedFile.write(&errorMessage)) {
QMessageBox::critical(parent, tr("File Generation Failure"), errorMessage);
return QStringList();
}
}
// Run the extensions
foreach (IFileWizardExtension *ex, extensions)
if (!ex->process(files, &errorMessage)) {
QMessageBox::critical(parent, tr("File Generation Failure"), errorMessage);
return QStringList();
}
// Post generation handler
if (!postGenerateFiles(files, &errorMessage)) {
QMessageBox::critical(0, tr("File Generation Failure"), errorMessage);
return QStringList();
}
return result;
}
QPixmap BaseFileWizard::watermark()
{
return QPixmap(QLatin1String(":/core/images/qtwatermark.png"));
}
void BaseFileWizard::setupWizard(QWizard *w)
{
w->setPixmap(QWizard::WatermarkPixmap, watermark());
w->setOption(QWizard::NoCancelButton, false);
w->setOption(QWizard::NoDefaultButton, false);
w->setOption(QWizard::NoBackButtonOnStartPage, true);
}
bool BaseFileWizard::postGenerateFiles(const GeneratedFiles &l, QString */*errorMessage*/)
{
// File mode: open the editors in file mode and ensure editor pane
const Core::GeneratedFiles::const_iterator cend = l.constEnd();
return true;
}
BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &location,
const QStringList &files,
QString *errorMessage) const
{
if (debugWizard)
qDebug() << Q_FUNC_INFO << location << files;
bool existingFilesFound = false;
bool oddStuffFound = false;
static const QString readOnlyMsg = tr(" [read only]");
static const QString directoryMsg = tr(" [directory]");
static const QString symLinkMsg = tr(" [symbolic link]");
// Format a file list message as ( "<file1> [readonly], <file2> [directory]").
QString fileNamesMsgPart;
foreach (const QString &fileName, files) {
const QFileInfo fi(fileName);
if (fi.exists()) {
existingFilesFound = true;
if (!fileNamesMsgPart.isEmpty())
fileNamesMsgPart += QLatin1String(", ");
fileNamesMsgPart += fi.fileName();
do {
if (fi.isDir()) {
oddStuffFound = true;
fileNamesMsgPart += directoryMsg;
break;
}
if (fi.isSymLink()) {
oddStuffFound = true;
fileNamesMsgPart += symLinkMsg;
break;
}
if (!fi.isWritable()) {
oddStuffFound = true;
fileNamesMsgPart += readOnlyMsg;
}
} while (false);
}
}
if (!existingFilesFound)
return OverwriteOk;
if (oddStuffFound) {
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.").arg(location).arg(fileNamesMsgPart);
return OverwriteError;
}
const QString messageFormat = tr("The following files already exist in the directory %1:\n"
"%2.\nWould you like to overwrite them?");
const QString message = messageFormat.arg(location).arg(fileNamesMsgPart);
const bool yes = (QMessageBox::question(Core::ICore::instance()->mainWindow(),
tr("Existing files"), message,
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No)
== QMessageBox::Yes);
return yes ? OverwriteOk : OverwriteCanceled;
}
QString BaseFileWizard::buildFileName(const QString &path,
const QString &baseName,
const QString &extension)
{
QString rc = path;
if (!rc.isEmpty() && !rc.endsWith(QDir::separator()))
rc += QDir::separator();
rc += baseName;
// Add extension unless user specified something else
const QChar dot = QLatin1Char('.');
if (!extension.isEmpty() && !baseName.contains(dot)) {
if (!extension.startsWith(dot))
rc += dot;
rc += extension;
}
if (debugWizard)
qDebug() << Q_FUNC_INFO << rc;
return rc;
}
QString BaseFileWizard::preferredSuffix(const QString &mimeType) const
{
const QString rc = Core::ICore::instance()->mimeDatabase()->preferredSuffixByType(mimeType);
if (rc.isEmpty())
qWarning("%s: WARNING: Unable to find a preferred suffix for %s.",
Q_FUNC_INFO, mimeType.toUtf8().constData());
return rc;
}
// ------------- StandardFileWizard
StandardFileWizard::StandardFileWizard(const BaseFileWizardParameters &parameters,
QObject *parent) :
BaseFileWizard(parameters, parent)
{
}
QWizard *StandardFileWizard::createWizardDialog(QWidget *parent,
const QString &defaultPath,
const WizardPageList &extensionPages) const
{
Utils::FileWizardDialog *standardWizardDialog = new Utils::FileWizardDialog(parent);
standardWizardDialog->setWindowTitle(tr("New %1").arg(name()));
setupWizard(standardWizardDialog);
standardWizardDialog->setPath(defaultPath);
foreach (QWizardPage *p, extensionPages)
standardWizardDialog->addPage(p);
return standardWizardDialog;
}
GeneratedFiles StandardFileWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
{
const Utils::FileWizardDialog *standardWizardDialog = qobject_cast<const Utils::FileWizardDialog *>(w);
return generateFilesFromPath(standardWizardDialog->path(),
standardWizardDialog->name(),
errorMessage);
}
} // namespace Core
#include "basefilewizard.moc"

View File

@ -1,227 +0,0 @@
/**
******************************************************************************
*
* @file basefilewizard.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup coreplugin
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef BASEFILEWIZARD_H
#define BASEFILEWIZARD_H
#include "core_global.h"
#include <coreplugin/dialogs/iwizard.h>
#include <QtGui/QIcon>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QMap>
#include <QtCore/QList>
QT_BEGIN_NAMESPACE
class QWizard;
class QWizardPage;
QT_END_NAMESPACE
namespace Core {
class IFileWizardExtension;
class BaseFileWizardParameterData;
struct BaseFileWizardPrivate;
class GeneratedFilePrivate;
/*!
* Represents a file generated by a wizard. The Wizard class will check for
* each file whether it already exists and will report any errors that may
* occur during creation of the files.
*/
class CORE_EXPORT GeneratedFile
{
public:
GeneratedFile();
explicit GeneratedFile(const QString &path);
GeneratedFile(const GeneratedFile &);
GeneratedFile &operator=(const GeneratedFile &);
~GeneratedFile();
// Full path of the file should be created, or the suggested file name
QString path() const;
void setPath(const QString &p);
// Contents of the file (UTF8)
QString contents() const;
void setContents(const QString &c);
QByteArray binaryContents() const;
void setBinaryContents(const QByteArray &c);
// Defaults to false (Text file).
bool isBinary() const;
void setBinary(bool b);
// Kind of editor to open the file with
QString editorKind() const;
void setEditorKind(const QString &k);
bool write(QString *errorMessage) const;
private:
QSharedDataPointer<GeneratedFilePrivate> m_d;
};
typedef QList<GeneratedFile> GeneratedFiles;
/* Parameter class for passing parameters to instances of class Wizard
* containing name, icon and such. */
class CORE_EXPORT BaseFileWizardParameters
{
public:
explicit BaseFileWizardParameters(IWizard::Kind kind = IWizard::FileWizard);
BaseFileWizardParameters(const BaseFileWizardParameters &);
BaseFileWizardParameters &operator=(const BaseFileWizardParameters&);
~BaseFileWizardParameters();
IWizard::Kind kind() const;
void setKind(IWizard::Kind k);
QIcon icon() const;
void setIcon(const QIcon &icon);
QString description() const;
void setDescription(const QString &description);
QString name() const;
void setName(const QString &name);
QString category() const;
void setCategory(const QString &category);
QString trCategory() const;
void setTrCategory(const QString &trCategory);
private:
QSharedDataPointer<BaseFileWizardParameterData> m_d;
};
/* A generic wizard for creating files.
*
* The abstract methods:
*
* createWizardDialog() : Called to create the QWizard dialog to be shown
* generateFiles() : Generate file content
*
* must be implemented. The behaviour can be further customized by overwriting
* the virtual method:
* postGenerateFiles() : Called after generating the files.
*/
class CORE_EXPORT BaseFileWizard : public IWizard
{
Q_DISABLE_COPY(BaseFileWizard)
Q_OBJECT
public:
virtual ~BaseFileWizard();
// IWizard
virtual Kind kind() const;
virtual QIcon icon() const;
virtual QString description() const;
virtual QString name() const;
virtual QString category() const;
virtual QString trCategory() const;
virtual QStringList runWizard(const QString &path, QWidget *parent);
// Build a file name, adding the extension unless baseName already has one
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
// Return standard pixmap to be used as watermark
static QPixmap watermark();
// Set the standard watermark on a QWizard
static void setupWizard(QWizard *);
protected:
typedef QList<QWizardPage *> WizardPageList;
explicit BaseFileWizard(const BaseFileWizardParameters &parameters, QObject *parent = 0);
// Overwrite to create the wizard dialog on the parent, adding
// the extension pages.
virtual QWizard *createWizardDialog(QWidget *parent,
const QString &defaultPath,
const WizardPageList &extensionPages) const = 0;
// Overwrite to query the parameters from the dialog and generate the files.
virtual GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const = 0;
/* Overwrite to perform steps to be done after files are actually created.
* The default implementation opens editors with the newly generated files. */
virtual bool postGenerateFiles(const GeneratedFiles &l, QString *errorMessage);
// Utility that returns the preferred suffix for a mime type
QString preferredSuffix(const QString &mimeType) const;
// Utility that performs an overwrite check on a set of files. It checks if
// the file exists, can be overwritten at all and prompts the user.
enum OverwriteResult { OverwriteOk, OverwriteError, OverwriteCanceled };
OverwriteResult promptOverwrite(const QString &location,
const QStringList &files,
QString *errorMessage) const;
private:
BaseFileWizardPrivate *m_d;
};
// StandardFileWizard convenience class for creating one file. It uses
// Utils::FileWizardDialog and introduces a new virtual to generate the
// files from path and name.
class CORE_EXPORT StandardFileWizard : public BaseFileWizard
{
Q_DISABLE_COPY(StandardFileWizard)
Q_OBJECT
protected:
explicit StandardFileWizard(const BaseFileWizardParameters &parameters, QObject *parent = 0);
// Implemented to create a Utils::FileWizardDialog
virtual QWizard *createWizardDialog(QWidget *parent,
const QString &defaultPath,
const WizardPageList &extensionPages) const;
// Implemented to retrieve path and name and call generateFilesFromPath()
virtual GeneratedFiles generateFiles(const QWizard *w,
QString *errorMessage) const;
// Newly introduced virtual that creates a file from a path
virtual GeneratedFiles generateFilesFromPath(const QString &path,
const QString &name,
QString *errorMessage) const = 0;
};
} // namespace Core
#endif // BASEFILEWIZARD_H

View File

@ -178,6 +178,6 @@ void CoreImpl::updateContext()
void CoreImpl::openFiles(const QStringList &arguments)
{
m_mainwindow->openFiles(arguments);
//m_mainwindow->openFiles(arguments);
}

View File

@ -101,7 +101,7 @@ void CorePlugin::remoteArgument(const QString& arg)
if (arg.isEmpty()) {
m_mainWindow->activateWindow();
} else {
m_mainWindow->openFiles(QStringList(arg));
//m_mainWindow->openFiles(QStringList(arg));
}
}

View File

@ -42,7 +42,6 @@ SOURCES += mainwindow.cpp \
variablemanager.cpp \
modemanager.cpp \
coreimpl.cpp \
basefilewizard.cpp \
plugindialog.cpp \
manhattanstyle.cpp \
minisplitter.cpp \
@ -84,14 +83,11 @@ HEADERS += mainwindow.h \
dialogs/ioptionspage.h \
icontext.h \
icore.h \
ifile.h \
ifilefactory.h \
imode.h \
ioutputpane.h \
coreconstants.h \
iversioncontrol.h \
iview.h \
ifilewizardextension.h \
icorelistener.h \
versiondialog.h \
core_global.h \
@ -101,7 +97,6 @@ HEADERS += mainwindow.h \
variablemanager.h \
modemanager.h \
coreimpl.h \
basefilewizard.h \
plugindialog.h \
manhattanstyle.h \
minisplitter.h \

View File

@ -1,78 +0,0 @@
/**
******************************************************************************
*
* @file ifile.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup coreplugin
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef IFILE_H
#define IFILE_H
#include "core_global.h"
#include <QtCore/QObject>
namespace Core {
class MimeType;
class CORE_EXPORT IFile : public QObject
{
Q_OBJECT
public:
// This enum must match the indexes of the reloadBehavior widget
// in generalsettings.ui
enum ReloadBehavior {
AskForReload = 0,
ReloadUnmodified = 1,
ReloadNone = 2,
ReloadAll,
ReloadPermissions
};
IFile(QObject *parent = 0) : QObject(parent) {}
virtual ~IFile() {}
virtual bool save(const QString &fileName = QString()) = 0;
virtual QString fileName() const = 0;
virtual QString defaultPath() const = 0;
virtual QString suggestedFileName() const = 0;
virtual QString mimeType() const = 0;
virtual bool isModified() const = 0;
virtual bool isReadOnly() const = 0;
virtual bool isSaveAsAllowed() const = 0;
virtual void modified(ReloadBehavior *behavior) = 0;
virtual void checkPermissions() {}
signals:
void changed();
};
} // namespace Core
#endif // IFILE_H

View File

@ -1,59 +0,0 @@
/**
******************************************************************************
*
* @file ifilefactory.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup coreplugin
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef IFILEFACTORY_H
#define IFILEFACTORY_H
#include "core_global.h"
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QStringList;
QT_END_NAMESPACE
namespace Core {
class IFile;
class CORE_EXPORT IFileFactory : public QObject
{
Q_OBJECT
public:
IFileFactory(QObject *parent = 0) : QObject(parent) {}
virtual ~IFileFactory() {}
virtual QStringList mimeTypes() const = 0;
virtual QString kind() const = 0;
virtual Core::IFile *open(const QString &fileName) = 0;
};
} // namespace Core
#endif // IFILEFACTORY_H

View File

@ -1,68 +0,0 @@
/**
******************************************************************************
*
* @file ifilewizardextension.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup coreplugin
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef IFILEWIZARDEXTENSION_H
#define IFILEWIZARDEXTENSION_H
#include <coreplugin/core_global.h>
#include <QtCore/QObject>
#include <QtCore/QList>
QT_BEGIN_NAMESPACE
class QWizardPage;
QT_END_NAMESPACE
namespace Core {
class IWizard;
class GeneratedFile;
/*!
Hook to add generic wizard pages to implementations of IWizard.
Used e.g. to add "Add to Project File/Add to version control" page
*/
class CORE_EXPORT IFileWizardExtension : public QObject
{
Q_OBJECT
public:
/* Return a list of pages to be added to the Wizard (empty list if not
* applicable). */
virtual QList<QWizardPage *> extensionPages(const IWizard *wizard) = 0;
/* Process the files using the extension parameters */
virtual bool process(const QList<GeneratedFile> &files, QString *errorMessage) = 0;
public slots:
/* Notification about the first extension page being shown. */
virtual void firstExtensionPageShown(const QList<GeneratedFile> &) {}
};
} // namespace Core
#endif // IFILEWIZARDEXTENSION_H

View File

@ -315,7 +315,7 @@ void MainWindow::dropEvent(QDropEvent *event)
QStringList files;
if (isDesktopFileManagerDrop(event->mimeData(), &files)) {
event->accept();
openFiles(files);
//openFiles(files);
} else {
event->ignore();
}
@ -633,7 +633,7 @@ void MainWindow::openFile()
{
}
static QList<IFileFactory*> getNonEditorFileFactories()
/*static QList<IFileFactory*> getNonEditorFileFactories()
{
QList<IFileFactory*> tmp;
return tmp;
@ -667,7 +667,7 @@ void MainWindow::openFiles(const QStringList &fileNames)
}
}
}
}*/
void MainWindow::setFocusToEditor()
{