Uploading the Okteta program into KDE's playground,

so the code isn't lost, after growing slowly only on my hdd for more than a year.

Okteta is a planned successor to KHexEdit, yet misses all of it's functionality.
With it's modular architecture, based on the co-developed lib kakao, it should
soon offer more than would could be done with the monolithic KHexEdit. I hope.


svn path=/trunk/playground/utils/okteta/; revision=728529
parent 415c0bc9
project( okteta )
include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} )
# include_directories (${QDBUS_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
add_subdirectory( core )
add_subdirectory( gui )
add_subdirectory( parts )
add_subdirectory( program )
project( oktetacore )
set( libcontroller_SRCS
controller/kchareditor.cpp
controller/kcontroller.cpp
......
project( oktetagui )
include_directories(
../core
../gui/libkcolumnsview
......
add_subdirectory( kbytesedit )
add_subdirectory( kpart )
project( oktetaparts )
add_subdirectory( kbytesedit )
add_subdirectory( kpart )
......@@ -22,7 +22,7 @@
// hexedit gui
#include <kbytearrayview.h>
// KDE
#include <kaction.h>
#include <KAction>
OktetaBrowserExtension::OktetaBrowserExtension( OktetaPart *p )
......
......@@ -25,13 +25,13 @@
// hexedit core
#include <kcharcodec.h>
// KDE
#include <klocale.h>
#include <KLocale>
//#include <kcomponentdata.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kstandardaction.h>
#include <kselectaction.h>
#include <ktoggleaction.h>
#include <KAction>
#include <KActionCollection>
#include <KStandardAction>
#include <KSelectAction>
#include <KToggleAction>
//#include <kglobalsettings.h>
......
......@@ -20,9 +20,9 @@
// part
#include "part.h"
// KDE
#include <kcomponentdata.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <KComponentData>
#include <KAboutData>
#include <KLocale>
// Part
......
project( oktetaprogram )
add_subdirectory( libkakao )
add_subdirectory( oktetakakao )
# if(KDE4_BUILD_TESTS)
# add_subdirectory(tests)
# endif(KDE4_BUILD_TESTS)
include_directories(
libkakao/core/document
libkakao/core/system
libkakao/gui/view
libkakao/gui/system
libkakao/gui/controller
libkakao/controllers
oktetakakao/document
oktetakakao/view
oktetakakao/controllers/document
oktetakakao/controllers/view
oktetakakao/controllers/view/libfinddialog
)
set( okteta_SRCS
main.cpp
program.cpp
about.cpp
mainwindow.cpp
)
kde4_add_executable( okteta ${okteta_SRCS} )
target_link_libraries( okteta
oktetagui
oktetacore
okteta_kakaocontrollers
okteta_kakaogui
okteta_kakaocore
kakaocontrollers
kakaogui
kakaocore
${KDE4_KIO_LIBS}
)
install( TARGETS okteta DESTINATION ${BIN_INSTALL_DIR} )
install( FILES okteta.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES oktetaui.rc DESTINATION ${DATA_INSTALL_DIR}/okteta )
kde4_install_icons( ${ICON_INSTALL_DIR} hicolor )
Unimplemented Feature of KHexEdit:
----------------------------------
Letzte Dateien
revert
Speichern
Bookmarks
Suchleiste
Dokumentenliste
Einstellung Anzeige a-f/A-F
Einstellung Anzeige Offset Hex/Dez
<!--Menu name="special" append="edit_paste_merge"><text>Spec&amp;ial</text>
<Action name="copy_as_text" />
<Action name="paste_into_new_file" />
<Action name="paste_into_new_window" />
</Menu-->
Zugriffsrechte (Größe/Verändern)
Rückgängig/Wiederherstellen
Zeichenkettenextraktion
Transcoder
Binärfilter
Einstellung Anzeige voller Pfad in Titel
Exportieren
Drucken
Dokumentverwaltung:
-------------------
Arbeitskopie kann verwickelt mit Speicherkopie sein oder nicht.
Ort/Name der Speicherkopie kann verändert werden, unter Löschen der alten oder Beibehaltung.
SK (und AK?) können gelöscht werden.
EINFACHER FALL:
Arbeitskopie separate Kopie. Versionsverwaltung kann ausgelagert werden.
Vorkommnisse:
* SK wird extern geändert (Datumsstempel)
a) kein Konflikt da keine lokale Änderung
b) Konflikt mit lokalen Änderungen
* SK wird extern gelöscht
*
KOMPLIZIERTER FALL:
Arbeitskopie nur Teilkopie der Speicherkopie. Speicherkopie darf also nicht von anderen bearbeitet werden.
/*
This file is part of the Okteta program, part of the KDE project.
Copyright 2007 Friedrich W. H. Kossebau <kossebau@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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, Boston, MA 02110-1301, USA.
*/
#include "about.h"
// KDE
#include <KLocale>
// Program
static const char ProgramId[] = "okteta";
static const char ProgramVersion[] = "0.0.1";
// Author
static const char FWHKEmailAddress[] = "kossebau@kde.org";
OktetaAboutData::OktetaAboutData()
: KAboutData( ProgramId, 0,
ki18n("Okteta"), ProgramVersion, // name
ki18n("KDE bytes editor"), // description
KAboutData::License_GPL_V2,
ki18n("Copyright 2007 Friedrich W. H. Kossebau"), //copyright
ki18n("Edit files as streams of bytes"), // comment
0, FWHKEmailAddress )
{
setOrganizationDomain( "kde.org" );
addAuthor( ki18n("Friedrich W. H. Kossebau"), // name
ki18n("Author"), // task
FWHKEmailAddress );
}
/*
This file is part of the Okteta program, part of the KDE project.
Copyright 2006 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#ifndef OKTETAABOUT_H
#define OKTETAABOUT_H
// KDE
#include <kaboutdata.h>
class OktetaAboutData : public KAboutData
{
public:
OktetaAboutData();
};
#endif
add_subdirectory( core )
add_subdirectory( gui )
add_subdirectory( controllers )
libkakao
--------
libkakao is another approach to a model-view-controller oriented system
for (set of) programs operating on "desktop" objects.
It's a work in progress, there are a lot of undocumented temporary solutions
to have the basic system work at all. Do not try to guess the planned architecture
by the existing classes and their methods. There are a lot of unsketched ideas which
will be tried and developed by the time.
For other, currently more advanced (in code ;) systems look for
Sublime in kdevplatform, Kate's doc/view system, or the one used by KOffice.
Once libkakao is in a state where discussions make sense I will let the world
know.
AUTHOR:
Friedrich W. H. Kossebau <kossebau@kde.org>
ABOUT THE NAME:
Guess what I was drinking when I thought that kmvt (t from toolet)
or kmvc sound boring. So far it is just the project name.
project( kakaocontrollers )
include_directories(
../core/document
../core/system
../gui/view
../gui/system
../gui/controller
)
set( SYNCHRONIZECONTROLLER_SRCS
document/synchronize/synchronizecontroller.cpp
)
set( CREATORCONTROLLER_SRCS
documentsystem/creator/creatorcontroller.cpp
)
set( ZOOMCONTROLLER_SRCS
view/zoom/zoomcontroller.cpp
)
set( SELECTCONTROLLER_SRCS
view/select/selectcontroller.cpp
)
set( CLIPBOARDCONTROLLER_SRCS
view/clipboard/clipboardcontroller.cpp
)
set( CLOSECONTROLLER_SRCS
viewsystem/close/closecontroller.cpp
)
set( VIEWLISTMENUCONTROLLER_SRCS
shellwindow/viewlistmenu/viewlistmenucontroller.cpp
)
set( FULLSCREENCONTROLLER_SRCS
shellwindow/fullscreen/fullscreencontroller.cpp
)
set( QUITCONTROLLER_SRCS
program/quit/quitcontroller.cpp
)
set( KAKAO_CONTROLLERS_SRCS
${CLOSECONTROLLER_SRCS}
${VIEWLISTMENUCONTROLLER_SRCS}
${FULLSCREENCONTROLLER_SRCS}
${ZOOMCONTROLLER_SRCS}
${CREATORCONTROLLER_SRCS}
${SYNCHRONIZECONTROLLER_SRCS}
${SELECTCONTROLLER_SRCS}
${CLIPBOARDCONTROLLER_SRCS}
${QUITCONTROLLER_SRCS}
)
kde4_add_library( kakaocontrollers STATIC ${KAKAO_CONTROLLERS_SRCS} )
/***************************************************************************
synchronizecontroller.cpp - description
-------------------
begin : Sun Sep 2 2007
copyright : 2007 by Friedrich W. H. Kossebau
email : kossebau@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* version 2 as published by the Free Software Foundation. *
* *
***************************************************************************/
#include "synchronizecontroller.h"
// kakao
#include <kdocumentsynchronizer.h>
#include <kviewmanager.h>
#include <kistorable.h>
// KDE
#include <KActionCollection>
#include <KAction>
#include <KStandardAction>
#include <KXmlGuiWindow>
SynchronizeController::SynchronizeController( KDocumentSynchronizer *documentSynchronizer, KXmlGuiWindow *window )
: mDocumentSynchronizer( documentSynchronizer ), mMainWindow( window )
{
KActionCollection *actionCollection = mMainWindow->actionCollection();
mSaveAction = KStandardAction::save( this, SLOT(save()), actionCollection );
mSaveAsAction = KStandardAction::saveAs( this, SLOT(saveAs()), actionCollection );
// mReloadAction = KStandardAction::revert( this, SLOT(reload()), actionCollection ); TODO
setView( 0 );
}
void SynchronizeController::setView( KAbstractView *view )
{
disconnect( mDocument );
mDocument = ( view != 0 ) ? view->document() : 0;
//TODO: reuse Factory here, it can load, so needs to know about decode, so should know about encode, too?
mStoreControl = mDocument ? qobject_cast<KDE::If::Storable *>( mDocument ) : 0;
// TODO: Storable interface should be used by Synchronizer
// synchronizer should report about possible activities
bool inSync = true;
bool hasUrl = false;
if( mStoreControl )
{
inSync = ( mDocument->synchronizationStates() == KAbstractDocument::InSync );
hasUrl = !mStoreControl->url().isEmpty();
connect( mDocument, SIGNAL(modified( KAbstractDocument::SynchronizationStates )),
SLOT(onSynchronizationStateChange( KAbstractDocument::SynchronizationStates )) );
}
mSaveAction->setEnabled( mStoreControl && !inSync && hasUrl );
mSaveAsAction->setEnabled( mStoreControl );
// mReloadAction->setEnabled( mStoreControl && !inSync );// TODO: only if has url
}
void SynchronizeController::save()
{
mDocumentSynchronizer->save( mDocument );
}
void SynchronizeController::saveAs()
{
mDocumentSynchronizer->saveAs( mDocument );
}
void SynchronizeController::reload()
{
mDocumentSynchronizer->reload( mDocument );
}
void SynchronizeController::onSynchronizationStateChange( KAbstractDocument::SynchronizationStates newStates )
{
const bool hasUrl = !mStoreControl->url().isEmpty();
mSaveAction->setEnabled( newStates!=KAbstractDocument::InSync && hasUrl );
// mReloadAction->setEnabled( newStates!=KAbstractDocument::InSync && hasUrl ); // TODO: only if document has url
}
/***************************************************************************
synchronizecontroller.h - description
-------------------
begin : Sun Sep 2 2007
copyright : 2007 by Friedrich W. H. Kossebau
email : kossebau@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* version 2 as published by the Free Software Foundation. *
* *
***************************************************************************/
#ifndef KDOCUMENTSYNCHRONIZERTOOLET_H
#define KDOCUMENTSYNCHRONIZERTOOLET_H
// lib
#include <kabstractdocument.h>
#include <kviewcontroller.h>
// KDE
#include <KUrl>
class KDocumentSynchronizer;
class KAction;
class KXmlGuiWindow;
// class KAbstractDocument;
namespace KDE { namespace If {
class Storable;
} }
class SynchronizeController : public KViewController
{
Q_OBJECT
public:
SynchronizeController( KDocumentSynchronizer *documentSynchronizer, KXmlGuiWindow *window );
public: // KToolet API
virtual void setView( KAbstractView *view );
protected Q_SLOTS:
void save();
void saveAs();
void reload();
private Q_SLOTS:
void onSynchronizationStateChange( KAbstractDocument::SynchronizationStates newStates );
protected:
KDocumentSynchronizer *mDocumentSynchronizer;
KXmlGuiWindow *mMainWindow;
KAbstractDocument *mDocument;
KDE::If::Storable *mStoreControl;
KAction *mSaveAction;
KAction *mSaveAsAction;
KAction *mReloadAction;
};
#endif
/***************************************************************************
creatorcontroller.cpp - description
-------------------
begin : Fri Jun 2 2006
copyright : 2006 by Friedrich W. H. Kossebau
email : kossebau@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* version 2 as published by the Free Software Foundation. *
* *
***************************************************************************/
#include "creatorcontroller.h"
// kakao
#include <kdocumentcreator.h>
// KDE
#include <KRecentFilesAction>
#include <KActionCollection>
#include <KStandardAction>
#include <KXmlGuiWindow>
#include <KFileDialog>
#include <KGlobal>
static const char AllFileNamesFilter[] = "*";
static const char CreatorConfigGroupId[] = "Recent Files";
CreatorController::CreatorController( KDocumentCreator *creator, KXmlGuiWindow *window )
: mCreator( creator ), mMainWindow( window )
{
KActionCollection *actionCollection = mMainWindow->actionCollection();
KStandardAction::openNew( this, SLOT(createNew()), actionCollection );
KStandardAction::open( this, SLOT(open()), actionCollection );
mOpenRecentAction =
KStandardAction::openRecent( this, SLOT(openRecent( const KUrl& )), actionCollection );
KConfigGroup configGroup( KGlobal::config(), CreatorConfigGroupId );
mOpenRecentAction->loadEntries( configGroup );
}
void CreatorController::setWorkingUrl( const KUrl &Url )
{
mWorkingUrl = Url;
}
void CreatorController::setView( KAbstractView *view )
{
Q_UNUSED( view )
}
void CreatorController::createNew()
{
mCreator->createNew();
}
void CreatorController::open()
{
KUrl url = KFileDialog::getOpenUrl( mWorkingUrl.url(), AllFileNamesFilter, mMainWindow );
if( !url.isEmpty() )
{
mCreator->open( url );
// store path