aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Mingulov <[email protected]>2010-06-18 11:02:48 +0200
committerThorbjørn Lindeijer <[email protected]>2010-06-18 11:50:41 +0200
commitfc3fd82e552942a02d6793c857d93e3d9727e6ee (patch)
tree45a31aa066a2802ce5cde09e138e41cefecc1b02 /src
parent491675559d77dc24223cd16a106f1e1d896bef8b (diff)
BinEditor Plugin: Remove ImageViewer
Merge-request: 2165 Reviewed-by: Thorbjørn Lindeijer <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/bineditor/ImageViewer.mimetypes.xml70
-rw-r--r--src/plugins/bineditor/bineditor.pro9
-rw-r--r--src/plugins/bineditor/bineditor.qrc4
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp7
-rw-r--r--src/plugins/bineditor/imageviewer.cpp215
-rw-r--r--src/plugins/bineditor/imageviewer.h137
6 files changed, 5 insertions, 437 deletions
diff --git a/src/plugins/bineditor/ImageViewer.mimetypes.xml b/src/plugins/bineditor/ImageViewer.mimetypes.xml
deleted file mode 100644
index f4f99a7a1cf..00000000000
--- a/src/plugins/bineditor/ImageViewer.mimetypes.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
- <mime-type type="image/bmp">
- <sub-class-of type="application/octet-stream"/>
- <comment>BMP image</comment>
- <glob pattern="*.bmp"/>
- </mime-type>
- <mime-type type="image/gif">
- <sub-class-of type="application/octet-stream"/>
- <comment>GIF image</comment>
- <glob pattern="*.gif"/>
- </mime-type>
- <mime-type type="image/x-icon">
- <sub-class-of type="application/octet-stream"/>
- <comment>ICO image</comment>
- <glob pattern="*.ico"/>
- </mime-type>
- <mime-type type="image/jpeg">
- <sub-class-of type="application/octet-stream"/>
- <comment>JPEG image</comment>
- <glob pattern="*.jpg"/>
- <glob pattern="*.jpeg"/>
- </mime-type>
- <mime-type type="video/x-mng">
- <sub-class-of type="application/octet-stream"/>
- <comment>MNG video</comment>
- <glob pattern="*.mng"/>
- </mime-type>
- <mime-type type="image/x-portable-bitmap">
- <sub-class-of type="application/octet-stream"/>
- <comment>PBM image</comment>
- <glob pattern="*.pbm"/>
- </mime-type>
- <mime-type type="image/x-portable-graymap">
- <sub-class-of type="application/octet-stream"/>
- <comment>PGM image</comment>
- <glob pattern="*.pgm"/>
- </mime-type>
- <mime-type type="image/png">
- <sub-class-of type="application/octet-stream"/>
- <comment>PNG image</comment>
- <glob pattern="*.png"/>
- </mime-type>
- <mime-type type="image/x-portable-pixmap">
- <sub-class-of type="application/octet-stream"/>
- <comment>PPM image</comment>
- <glob pattern="*.ppm"/>
- </mime-type>
- <mime-type type="image/svg+xml">
- <sub-class-of type="application/octet-stream"/>
- <comment>SVG image</comment>
- <glob pattern="*.svg"/>
- </mime-type>
- <mime-type type="image/tiff">
- <sub-class-of type="application/octet-stream"/>
- <comment>TIFF image</comment>
- <glob pattern="*.tif"/>
- <glob pattern="*.tiff"/>
- </mime-type>
- <mime-type type="image/xbm">
- <sub-class-of type="application/octet-stream"/>
- <comment>XBM image</comment>
- <glob pattern="*.xbm"/>
- </mime-type>
- <mime-type type="image/xpm">
- <sub-class-of type="application/octet-stream"/>
- <comment>XPM image</comment>
- <glob pattern="*.xpm"/>
- </mime-type>
-</mime-info>
diff --git a/src/plugins/bineditor/bineditor.pro b/src/plugins/bineditor/bineditor.pro
index 6ee822f9658..976e701ff4a 100644
--- a/src/plugins/bineditor/bineditor.pro
+++ b/src/plugins/bineditor/bineditor.pro
@@ -5,14 +5,11 @@ include(bineditor_dependencies.pri)
HEADERS += bineditorplugin.h \
bineditor.h \
- bineditorconstants.h \
- imageviewer.h
+ bineditorconstants.h
SOURCES += bineditorplugin.cpp \
- bineditor.cpp \
- imageviewer.cpp
+ bineditor.cpp
RESOURCES += bineditor.qrc
-OTHER_FILES += BinEditor.pluginspec \
- ImageViewer.mimetypes.xml
+OTHER_FILES += BinEditor.pluginspec
diff --git a/src/plugins/bineditor/bineditor.qrc b/src/plugins/bineditor/bineditor.qrc
index 1bc50d279e2..339c4199884 100644
--- a/src/plugins/bineditor/bineditor.qrc
+++ b/src/plugins/bineditor/bineditor.qrc
@@ -1,5 +1,3 @@
<RCC>
- <qresource prefix="/bineditor">
- <file>ImageViewer.mimetypes.xml</file>
- </qresource>
+ <qresource prefix="/bineditor"/>
</RCC>
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 1d6c2900a4e..2793cf40958 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -31,8 +31,6 @@
#include "bineditor.h"
#include "bineditorconstants.h"
-#include "imageviewer.h"
-
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
@@ -472,16 +470,13 @@ void BinEditorPlugin::initializeEditor(BinEditor *editor)
bool BinEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
+ Q_UNUSED(errorMessage)
Core::ICore *core = Core::ICore::instance();
- if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/bineditor/ImageViewer.mimetypes.xml"), errorMessage))
- return false;
-
connect(core, SIGNAL(contextAboutToChange(Core::IContext *)),
this, SLOT(updateCurrentEditor(Core::IContext *)));
addAutoReleasedObject(new BinEditorFactory(this));
- addAutoReleasedObject(new ImageViewerFactory);
return true;
}
diff --git a/src/plugins/bineditor/imageviewer.cpp b/src/plugins/bineditor/imageviewer.cpp
deleted file mode 100644
index 57fdf994735..00000000000
--- a/src/plugins/bineditor/imageviewer.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation ([email protected])
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "imageviewer.h"
-
-#include <coreplugin/icore.h>
-#include <coreplugin/uniqueidmanager.h>
-
-#include <utils/reloadpromptutils.h>
-
-#include <QtCore/QMap>
-#include <QtCore/QFileInfo>
-#include <QtGui/QImageReader>
-#include <QtGui/QWidget>
-#include <QtGui/QGridLayout>
-#include <QtGui/QMainWindow>
-#include <QtDebug>
-
-namespace {
- const char * const IMAGE_VIEWER_ID = "Editors.ImageViewer";
- const char * const C_IMAGE_VIEWER = "Editors.ImageViewer";
-}
-
-using namespace BINEditor::Internal;
-using namespace Core;
-
-// #pragma mark -- ImageViewerFactory
-
-ImageViewerFactory::ImageViewerFactory(QObject *parent) :
- Core::IEditorFactory(parent)
-{
- QMap<QByteArray, QString> possibleMimeTypes;
- possibleMimeTypes.insert("bmp", QLatin1String("image/bmp"));
- possibleMimeTypes.insert("gif", QLatin1String("image/gif"));
- possibleMimeTypes.insert("ico", QLatin1String("image/x-icon"));
- possibleMimeTypes.insert("jpeg", QLatin1String("image/jpeg"));
- possibleMimeTypes.insert("jpg", QLatin1String("image/jpeg"));
- possibleMimeTypes.insert("mng", QLatin1String("video/x-mng"));
- possibleMimeTypes.insert("pbm", QLatin1String("image/x-portable-bitmap"));
- possibleMimeTypes.insert("pgm", QLatin1String("image/x-portable-graymap"));
- possibleMimeTypes.insert("png", QLatin1String("image/png"));
- possibleMimeTypes.insert("ppm", QLatin1String("image/x-portable-pixmap"));
- possibleMimeTypes.insert("svg", QLatin1String("image/svg+xml"));
- possibleMimeTypes.insert("tif", QLatin1String("image/tiff"));
- possibleMimeTypes.insert("tiff", QLatin1String("image/tiff"));
- possibleMimeTypes.insert("xbm", QLatin1String("image/xbm"));
- possibleMimeTypes.insert("xpm", QLatin1String("image/xpm"));
-
- QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
- foreach (const QByteArray &format, supportedFormats) {
- const QString &value = possibleMimeTypes.value(format);
- if (!value.isEmpty())
- m_mimeTypes.append(value);
- }
-}
-
-IEditor *ImageViewerFactory::createEditor(QWidget *parent)
-{
- return new ImageViewer(parent);
-}
-
-QStringList ImageViewerFactory::mimeTypes() const
-{
- return m_mimeTypes;
-}
-
-QString ImageViewerFactory::id() const
-{
- return QLatin1String(IMAGE_VIEWER_ID);
-}
-
-QString ImageViewerFactory::displayName() const
-{
- return tr("Image Viewer");
-}
-
-Core::IFile *ImageViewerFactory::open(const QString & /* fileName */)
-{
- return 0;
-}
-
-// #pragma mark -- ImageViewerFile
-
-ImageViewerFile::ImageViewerFile(ImageViewer *parent)
- : Core::IFile(parent),
- m_editor(parent)
-{
-
-}
-
-Core::IFile::ReloadBehavior ImageViewerFile::reloadBehavior(Core::IFile::ChangeTrigger state,
- Core::IFile::ChangeType type) const
-{
- if (type == TypePermissions)
- return BehaviorSilent;
- if (type == TypeContents && state == TriggerInternal)
- return BehaviorSilent;
- return BehaviorAsk;
-}
-
-void ImageViewerFile::reload(Core::IFile::ReloadFlag flag,
- Core::IFile::ChangeType type)
-{
- if (flag == FlagIgnore)
- return;
- if (type == TypePermissions) {
- emit changed();
- } else {
- m_editor->open(m_fileName);
- }
-}
-
-// #pragma mark -- ImageViewer
-
-ImageViewer::ImageViewer(QObject *parent)
- : IEditor(parent)
-{
- m_file = new ImageViewerFile(this);
- m_context << Core::ICore::instance()->uniqueIDManager()->uniqueIdentifier(C_IMAGE_VIEWER);
-
- m_scrollArea = new QScrollArea;
- m_scrollArea->setWidgetResizable(true);
- m_scrollArea->setFrameStyle(QFrame::NoFrame);
- m_imageView = new QWidget;
- QGridLayout *layout = new QGridLayout;
- m_label = new QLabel;
- m_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
- m_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
- layout->setMargin(0);
- m_imageView->setLayout(layout);
- layout->addWidget(m_label, 0, 0, 1, 1);
-
- connect(m_file, SIGNAL(changed()),
- this, SIGNAL(changed()));
-}
-
-ImageViewer::~ImageViewer()
-{
- delete m_scrollArea;
- // m_file deleted by parent hierarchy
-}
-
-QList<int> ImageViewer::context() const
-{
- return m_context;
-}
-
-QWidget *ImageViewer::widget()
-{
- return m_scrollArea;
-}
-
-bool ImageViewer::createNew(const QString &contents)
-{
- Q_UNUSED(contents)
- return false;
-}
-
-bool ImageViewer::open(const QString &fileName)
-{
- m_label->setPixmap(QPixmap(fileName));
- m_scrollArea->setWidget(m_imageView);
- setDisplayName(QFileInfo(fileName).fileName());
- m_file->setFileName(fileName);
- // m_file->setMimeType
- emit changed();
- return !m_label->pixmap()->isNull();
-}
-
-Core::IFile *ImageViewer::file()
-{
- return m_file;
-}
-
-QString ImageViewer::id() const
-{
- return QLatin1String(IMAGE_VIEWER_ID);
-}
-
-QString ImageViewer::displayName() const
-{
- return m_displayName;
-}
-
-void ImageViewer::setDisplayName(const QString &title)
-{
- m_displayName = title;
- emit changed();
-}
diff --git a/src/plugins/bineditor/imageviewer.h b/src/plugins/bineditor/imageviewer.h
deleted file mode 100644
index b74ad90293f..00000000000
--- a/src/plugins/bineditor/imageviewer.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation ([email protected])
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef IMAGEVIEWER_H
-#define IMAGEVIEWER_H
-
-#include <coreplugin/editormanager/ieditorfactory.h>
-#include <coreplugin/editormanager/ieditor.h>
-#include <coreplugin/ifile.h>
-
-#include <QtCore/QStringList>
-#include <QtGui/QWidget>
-#include <QtGui/QLabel>
-#include <QtGui/QScrollArea>
-
-namespace BINEditor {
-namespace Internal {
-
-class ImageViewerFactory : public Core::IEditorFactory
-{
-Q_OBJECT
-public:
- explicit ImageViewerFactory(QObject *parent = 0);
-
- Core::IEditor *createEditor(QWidget *parent);
-
- QStringList mimeTypes() const;
-
- QString id() const;
- QString displayName() const;
-
- Core::IFile *open(const QString &fileName);
-
-private:
- QStringList m_mimeTypes;
-};
-
-class ImageViewer;
-
-class ImageViewerFile : public Core::IFile
-{
- Q_OBJECT
-public:
- explicit ImageViewerFile(ImageViewer *parent = 0);
-
- bool save(const QString &fileName = QString()) { Q_UNUSED(fileName); return false; }
- void rename(const QString &newName) { m_fileName = newName; }
- QString fileName() const { return m_fileName; }
-
- QString defaultPath() const { return QString(); }
- QString suggestedFileName() const { return QString(); }
- QString mimeType() const { return m_mimeType; }
-
- bool isModified() const { return false; }
- bool isReadOnly() const { return true; }
- bool isSaveAsAllowed() const { return false; }
-
- ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
- void reload(ReloadFlag flag, ChangeType type);
-
- void setMimetype(const QString &mimetype) { m_mimeType = mimetype; emit changed(); }
- void setFileName(const QString &filename) { m_fileName = filename; emit changed(); }
-private:
- QString m_fileName;
- QString m_mimeType;
- ImageViewer *m_editor;
-};
-
-class ImageViewer : public Core::IEditor
-{
- Q_OBJECT
-public:
- explicit ImageViewer(QObject *parent = 0);
- ~ImageViewer();
-
- QList<int> context() const;
- QWidget *widget();
-
- bool createNew(const QString &contents = QString());
- bool open(const QString &fileName = QString());
- Core::IFile *file();
- QString id() const;
- QString displayName() const;
- void setDisplayName(const QString &title);
-
- bool duplicateSupported() const { return false; }
- IEditor *duplicate(QWidget * /* parent */) { return 0; }
-
- QByteArray saveState() const { return QByteArray(); }
- bool restoreState(const QByteArray & /* state */) { return true; }
-
- int currentLine() const { return 0; }
- int currentColumn() const { return 0; }
-
- bool isTemporary() const { return false; }
-
- QWidget *toolBar() { return 0; }
-
-private:
- QList<int> m_context;
- QString m_displayName;
- ImageViewerFile *m_file;
- QScrollArea *m_scrollArea;
- QWidget *m_imageView;
- QLabel *m_label;
-};
-
-}
-}
-
-#endif // IMAGEVIEWER_H