Commit 88424c44 authored by Aurélien Gâteau's avatar Aurélien Gâteau
Browse files

More work on rotation, rough skeleton implemented.

svn path=/trunk/KDE/kdegraphics/gwenview/; revision=681946
parent e1fd5670
......@@ -65,6 +65,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <lib/mimetypeutils.h>
#include <lib/sorteddirmodel.h>
#include <lib/thumbnailview.h>
#include <lib/transformimageoperation.h>
namespace Gwenview {
......@@ -472,6 +473,28 @@ struct MainWindow::Private {
return item->mimetype();
}
}
void applyImageOperation(AbstractImageOperation* op) {
QItemSelection selection = mThumbnailView->selectionModel()->selection();
QModelIndexList indexList = selection.indexes();
Q_ASSERT(indexList.count() > 0);
if (indexList.count() > 1) {
Q_FOREACH(QModelIndex index, indexList) {
KFileItem* item = mDirModel->itemForIndex(index);
KUrl url = item->url();
Document::Ptr doc = DocumentFactory::instance()->load(url);
op->apply(doc);
// TODO: Batch dialog, showing progress and errors
if (doc->isModified()) {
doc->save(url, doc->format());
}
}
} else {
KFileItem* item = mDirModel->itemForIndex(indexList[0]);
Document::Ptr doc = DocumentFactory::instance()->load(item->url());
op->apply(doc);
}
}
};
......@@ -773,18 +796,26 @@ void MainWindow::saveAs() {
void MainWindow::rotateLeft() {
TransformImageOperation op(TransformImageOperation::RotateLeft);
d->applyImageOperation(&op);
}
void MainWindow::rotateRight() {
TransformImageOperation op(TransformImageOperation::RotateRight);
d->applyImageOperation(&op);
}
void MainWindow::mirror() {
TransformImageOperation op(TransformImageOperation::Mirror);
d->applyImageOperation(&op);
}
void MainWindow::flip() {
TransformImageOperation op(TransformImageOperation::Flip);
d->applyImageOperation(&op);
}
......
set(gwenviewlib_SRCS
abstractdocumentimpl.cpp
abstractimageoperation.cpp
archiveutils.cpp
document.cpp
documentfactory.cpp
......@@ -16,6 +17,7 @@ set(gwenviewlib_SRCS
sorteddirmodel.cpp
thumbnailview.cpp
transupp.c
transformimageoperation.cpp
)
kde4_automoc(${gwenviewlib_SRCS})
......
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
/*
Gwenview: an image viewer
Copyright 2007 Aurélien Gâteau
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 2
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., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
*/
// Self
#include "abstractimageoperation.h"
// Qt
// KDE
// Local
namespace Gwenview {
struct AbstractImageOperationPrivate {
};
AbstractImageOperation::AbstractImageOperation()
: d(new AbstractImageOperationPrivate) {
}
AbstractImageOperation::~AbstractImageOperation() {
delete d;
}
} // namespace
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
/*
Gwenview: an image viewer
Copyright 2007 Aurélien Gâteau
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 2
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., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
*/
#ifndef ABSTRACTIMAGEOPERATION_H
#define ABSTRACTIMAGEOPERATION_H
#include "gwenviewlib_export.h"
// Qt
// KDE
// Local
#include "document.h"
namespace Gwenview {
class AbstractImageOperationPrivate;
class GWENVIEWLIB_EXPORT AbstractImageOperation {
public:
AbstractImageOperation();
virtual ~AbstractImageOperation();
virtual void apply(Document::Ptr) = 0;
private:
AbstractImageOperationPrivate* const d;
};
} // namespace
#endif /* ABSTRACTIMAGEOPERATION_H */
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
/*
Gwenview: an image viewer
Copyright 2007 Aurélien Gâteau
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 2
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., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
*/
// Self
#include "transformimageoperation.h"
// Qt
// KDE
// Local
namespace Gwenview {
struct TransformImageOperationPrivate {
};
TransformImageOperation::TransformImageOperation(TransformImageOperation::Transformation)
: d(new TransformImageOperationPrivate) {
}
TransformImageOperation::~TransformImageOperation() {
delete d;
}
void TransformImageOperation::apply(Document::Ptr) {
}
} // namespace
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
/*
Gwenview: an image viewer
Copyright 2007 Aurélien Gâteau
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 2
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., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
*/
#ifndef TRANSFORMIMAGEOPERATION_H
#define TRANSFORMIMAGEOPERATION_H
#include "gwenviewlib_export.h"
// Qt
// KDE
// Local
#include "abstractimageoperation.h"
namespace Gwenview {
class TransformImageOperationPrivate;
class GWENVIEWLIB_EXPORT TransformImageOperation : public AbstractImageOperation {
public:
enum Transformation {
RotateLeft,
RotateRight,
Mirror,
Flip
};
TransformImageOperation(Transformation);
~TransformImageOperation();
virtual void apply(Document::Ptr);
private:
TransformImageOperationPrivate* const d;
};
} // namespace
#endif /* TRANSFORMIMAGEOPERATION_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment