2010-06-18 11:02:48 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-06-18 11:02:48 +02:00
|
|
|
** Copyright (c) 2010 Denis Mingulov.
|
|
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-06-18 11:02:48 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
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.
|
2010-06-18 11:02:48 +02: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.
|
2010-06-18 11:02:48 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "imageviewerfile.h"
|
|
|
|
|
#include "imageviewer.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-09-05 16:10:37 +02:00
|
|
|
#include <coreplugin/id.h>
|
2010-06-18 11:02:48 +02:00
|
|
|
|
|
|
|
|
#include <utils/reloadpromptutils.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QMap>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QtDebug>
|
|
|
|
|
|
|
|
|
|
namespace ImageViewer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
struct ImageViewerFilePrivate
|
|
|
|
|
{
|
|
|
|
|
QString fileName;
|
|
|
|
|
QString mimeType;
|
|
|
|
|
ImageViewer *editor;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerFile::ImageViewerFile(ImageViewer *parent)
|
|
|
|
|
: Core::IFile(parent),
|
2011-09-16 15:00:41 +02:00
|
|
|
d(new ImageViewerFilePrivate)
|
2010-06-18 11:02:48 +02:00
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
d->editor = parent;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImageViewerFile::~ImageViewerFile()
|
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-04 15:24:13 +02:00
|
|
|
bool ImageViewerFile::reload(QString *errorString,
|
|
|
|
|
Core::IFile::ReloadFlag flag,
|
2010-06-18 11:02:48 +02:00
|
|
|
Core::IFile::ChangeType type)
|
|
|
|
|
{
|
|
|
|
|
if (flag == FlagIgnore)
|
2011-04-04 15:24:13 +02:00
|
|
|
return true;
|
2010-06-18 11:02:48 +02:00
|
|
|
if (type == TypePermissions) {
|
|
|
|
|
emit changed();
|
2011-04-04 15:24:13 +02:00
|
|
|
return true;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
2011-09-16 15:00:41 +02:00
|
|
|
return d->editor->open(errorString, d->fileName, d->fileName);
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-10 20:43:03 +02:00
|
|
|
bool ImageViewerFile::save(QString *errorString, const QString &fileName, bool autoSave)
|
2010-06-18 11:02:48 +02:00
|
|
|
{
|
2011-03-30 13:45:16 +02:00
|
|
|
Q_UNUSED(errorString)
|
2010-06-18 11:02:48 +02:00
|
|
|
Q_UNUSED(fileName);
|
2011-05-10 20:43:03 +02:00
|
|
|
Q_UNUSED(autoSave)
|
2010-06-18 11:02:48 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewerFile::rename(const QString &newName)
|
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
d->fileName = newName;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ImageViewerFile::fileName() const
|
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
return d->fileName;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ImageViewerFile::defaultPath() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ImageViewerFile::suggestedFileName() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ImageViewerFile::mimeType() const
|
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
return d->mimeType;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ImageViewerFile::isModified() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ImageViewerFile::isReadOnly() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ImageViewerFile::isSaveAsAllowed() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewerFile::setMimetype(const QString &mimetype)
|
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
d->mimeType = mimetype;
|
2010-06-18 11:02:48 +02:00
|
|
|
emit changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewerFile::setFileName(const QString &filename)
|
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
d->fileName = filename;
|
2010-06-18 11:02:48 +02:00
|
|
|
emit changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ImageViewer
|