From kde-commits Thu May 31 20:48:42 2012 From: =?utf-8?q?Friedrich=20W=2E=20H=2E=20Kossebau?= Date: Thu, 31 May 2012 20:48:42 +0000 To: kde-commits Subject: KDE/kdesdk/okteta Message-Id: <20120531204842.9B809AC76E () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=133849750510021 SVN commit 1297559 by kossebau: Changed: set each ByteArrayView a fixed ByteArrayViewProfileSynchronizer for now M +9 -3 kasten/controllers/view/viewprofiles/viewprofilescontroller.cpp M +1 -4 kasten/controllers/view/viewprofiles/viewprofilesynccontroller.cpp M +8 -10 kasten/gui/view/bytearrayview.cpp M +4 -4 kasten/gui/view/bytearrayview.h M +10 -11 kasten/gui/view/bytearrayviewfactory.cpp M +1 -0 parts/kpart/CMakeLists.txt M +13 -5 parts/kpart/part.cpp M +5 -1 parts/kpart/part.h M +9 -10 parts/kpart/partfactory.cpp M +11 -0 parts/kpart/partfactory.h --- trunk/KDE/kdesdk/okteta/kasten/controllers/view/viewprofiles/viewprofilescontroller.cpp #1297558:1297559 @@ -106,6 +106,7 @@ mByteArrayViewProfileSynchronizer->viewProfileId() : ByteArrayViewProfile::Id(); + bool isCurrentViewProfileExisting = false; foreach( const ByteArrayViewProfile& viewProfile, viewProfiles ) { const QString title = viewProfile.viewProfileTitle(); @@ -113,18 +114,23 @@ action->setCheckable( true ); const ByteArrayViewProfile::Id viewProfileId = viewProfile.id(); action->setData( viewProfileId ); - if( viewProfileId == currentViewProfileId ) - action->setChecked( true ); + const bool isCurrentViewProfile = ( viewProfileId == currentViewProfileId ); + action->setChecked( isCurrentViewProfile ); + if( isCurrentViewProfile ) + isCurrentViewProfileExisting = true; mViewProfilesActionGroup->addAction( action ); } + // reset id if no longer existing + if( ! isCurrentViewProfileExisting && mByteArrayViewProfileSynchronizer ) + mByteArrayViewProfileSynchronizer->setViewProfileId( ByteArrayViewProfile::Id() ); + mGuiClient->plugActionList( QLatin1String("view_profile_list"), mViewProfilesActionGroup->actions() ); } void ViewProfilesController::onViewProfileTriggered( QAction* action ) { - if( mByteArrayViewProfileSynchronizer ) mByteArrayViewProfileSynchronizer->setViewProfileId( action->data().toString() ); } --- trunk/KDE/kdesdk/okteta/kasten/controllers/view/viewprofiles/viewprofilesynccontroller.cpp #1297558:1297559 @@ -77,7 +77,6 @@ mByteArrayView = model ? model->findBaseModel() : 0; mByteArrayViewProfileSynchronizer = mByteArrayView ? mByteArrayView->synchronizer() : 0; - const bool hasView = ( mByteArrayView != 0 ); const bool hasSynchronizer = ( mByteArrayViewProfileSynchronizer != 0 ); if( hasSynchronizer ) { @@ -92,7 +91,7 @@ mResetChangesAction->setEnabled( false ); } - mCreateNewAction->setEnabled( hasView ); + mCreateNewAction->setEnabled( hasSynchronizer ); } @@ -144,13 +143,11 @@ void ViewProfileSyncController::onResetChangesActionTriggered() { - if( mByteArrayViewProfileSynchronizer ) mByteArrayViewProfileSynchronizer->syncFromRemote(); } void ViewProfileSyncController::onSaveChangesActionTriggered() { - if( mByteArrayViewProfileSynchronizer ) mByteArrayViewProfileSynchronizer->syncToRemote(); } --- trunk/KDE/kdesdk/okteta/kasten/gui/view/bytearrayview.cpp #1297558:1297559 @@ -37,18 +37,20 @@ namespace Kasten2 { -ByteArrayView::ByteArrayView( ByteArrayDocument* document ) +ByteArrayView::ByteArrayView( ByteArrayDocument* document, ByteArrayViewProfileSynchronizer* synchronizer ) : AbstractView( document ) , mDocument( document ) - , mByteArrayViewProfileSynchronizer( 0 ) + , mByteArrayViewProfileSynchronizer( synchronizer ) { init(); + synchronizer->setView( this ); } -ByteArrayView::ByteArrayView( ByteArrayView* other, Qt::Alignment alignment ) +ByteArrayView::ByteArrayView( ByteArrayView* other, ByteArrayViewProfileSynchronizer* synchronizer, + Qt::Alignment alignment ) : AbstractView( static_cast(other->baseModel()) ) , mDocument( static_cast(other->baseModel()) ) - , mByteArrayViewProfileSynchronizer( 0 ) + , mByteArrayViewProfileSynchronizer( synchronizer ) { init(); @@ -95,6 +97,8 @@ // TODO: doesn't really work at this stage, because the widget will get resized when inserted // and then ensureCursorVisible destroys the fun mWidget->setViewPos( viewPos ); + + synchronizer->setView( this ); } void ByteArrayView::init() @@ -134,12 +138,6 @@ connect( mWidget, SIGNAL(viewModusChanged(int)), SIGNAL(viewModusChanged(int)) ); } -void ByteArrayView::setSynchronizer( ByteArrayViewProfileSynchronizer* synchronizer ) -{ - delete mByteArrayViewProfileSynchronizer; - mByteArrayViewProfileSynchronizer = synchronizer; -} - ByteArrayViewProfileSynchronizer* ByteArrayView::synchronizer() const { return mByteArrayViewProfileSynchronizer; } const AbstractModelSelection* ByteArrayView::modelSelection() const { return &mSelection; } --- trunk/KDE/kdesdk/okteta/kasten/gui/view/bytearrayview.h #1297558:1297559 @@ -64,8 +64,9 @@ enum { ColumnViewId = 0, RowViewId }; public: - explicit ByteArrayView( ByteArrayDocument* document ); - explicit ByteArrayView( ByteArrayView* other, Qt::Alignment alignment = 0 ); + ByteArrayView( ByteArrayDocument* document, ByteArrayViewProfileSynchronizer* synchronizer ); + ByteArrayView( ByteArrayView* other, ByteArrayViewProfileSynchronizer* synchronizer, + Qt::Alignment alignment = 0 ); virtual ~ByteArrayView(); @@ -182,7 +183,6 @@ void viewModusChanged( int viewModus ); public: - void setSynchronizer( ByteArrayViewProfileSynchronizer* synchronizer ); ByteArrayViewProfileSynchronizer* synchronizer() const; private: @@ -199,7 +199,7 @@ ByteArraySelection mSelection; // KCursorProxy *mCursorProxy; - ByteArrayViewProfileSynchronizer* mByteArrayViewProfileSynchronizer; + ByteArrayViewProfileSynchronizer* const mByteArrayViewProfileSynchronizer; }; } --- trunk/KDE/kdesdk/okteta/kasten/gui/view/bytearrayviewfactory.cpp #1297558:1297559 @@ -45,20 +45,12 @@ ByteArrayDocument* document = static_cast( _document ); if( document ) { - result = new ByteArrayView( document ); - - const ByteArrayViewProfile::Id defaultViewProfileId = - mByteArrayViewProfileManager->defaultViewProfileId(); - if( ! defaultViewProfileId.isEmpty() ) - { ByteArrayViewProfileSynchronizer* synchronizer = new ByteArrayViewProfileSynchronizer( mByteArrayViewProfileManager ); - synchronizer->setViewProfileId( defaultViewProfileId ); - synchronizer->setView( result ); - result->setSynchronizer( synchronizer ); - } + synchronizer->setViewProfileId( mByteArrayViewProfileManager->defaultViewProfileId() ); + result = new ByteArrayView( document, synchronizer ); } return result; @@ -70,8 +62,15 @@ ByteArrayView* view = qobject_cast( _view ); if( view ) - result = new ByteArrayView( view, alignment ); + { + ByteArrayViewProfileSynchronizer* synchronizer = + new ByteArrayViewProfileSynchronizer( mByteArrayViewProfileManager ); + synchronizer->setViewProfileId( view->synchronizer()->viewProfileId() ); + + result = new ByteArrayView( view, synchronizer, alignment ); + } + return result; } --- trunk/KDE/kdesdk/okteta/parts/kpart/CMakeLists.txt #1297558:1297559 @@ -11,6 +11,7 @@ ${OKTETAKASTEN_REL_DIR}/gui ${OKTETAKASTEN_REL_DIR}/gui/io ${OKTETAKASTEN_REL_DIR}/gui/view + ${OKTETAKASTEN_REL_DIR}/gui/system ${OKTETAKASTEN_REL_DIR}/core ${OKTETAKASTEN_REL_DIR}/core/io ${OKTETAKASTEN_REL_DIR}/core/document --- trunk/KDE/kdesdk/okteta/parts/kpart/part.cpp #1297558:1297559 @@ -28,6 +28,8 @@ // Okteta Kasten #include #include +#include +#include #include #include #include @@ -73,9 +75,11 @@ OktetaPart::OktetaPart( QObject* parent, const KComponentData& componentData, - Modus modus ) - : KParts::ReadWritePart( parent ), - mModus( modus ) + Modus modus, + Kasten2::ByteArrayViewProfileManager* viewProfileManager ) + : KParts::ReadWritePart( parent ) + , mModus( modus ) + , mViewProfileManager( viewProfileManager ) { setComponentData( componentData ); @@ -130,7 +134,9 @@ // TODO: BrowserExtension might rely on existing objects (session snap while loadJob), // so this hack just creates some dummies mDocument = new Kasten2::ByteArrayDocument( QString() ); - mByteArrayView = new Kasten2::ByteArrayView( mDocument ); + Kasten2::ByteArrayViewProfileSynchronizer* viewProfileSynchronizer = + new Kasten2::ByteArrayViewProfileSynchronizer( viewProfileManager ); + mByteArrayView = new Kasten2::ByteArrayView( mDocument, viewProfileSynchronizer ); if( modus == BrowserViewModus ) new OktetaBrowserExtension( this ); @@ -185,7 +191,9 @@ connect( mDocument->synchronizer(), SIGNAL(localSyncStateChanged(Kasten2::LocalSyncState)), SLOT(onModified(Kasten2::LocalSyncState)) ); - mByteArrayView = new Kasten2::ByteArrayView( mDocument ); + Kasten2::ByteArrayViewProfileSynchronizer* viewProfileSynchronizer = + new Kasten2::ByteArrayViewProfileSynchronizer( mViewProfileManager ); + mByteArrayView = new Kasten2::ByteArrayView( mDocument, viewProfileSynchronizer ); // mByteArrayView->setNoOfBytesPerLine( 16 ); mByteArrayView->setShowsNonprinting( false ); connect( mByteArrayView, SIGNAL(hasSelectedDataChanged(bool)), SIGNAL(hasSelectedDataChanged(bool)) ); --- trunk/KDE/kdesdk/okteta/parts/kpart/part.h #1297558:1297559 @@ -29,6 +29,7 @@ #include namespace Kasten2 { +class ByteArrayViewProfileManager; class ByteArrayView; class ByteArrayDocument; class PrintController; @@ -51,7 +52,8 @@ public: OktetaPart( QObject* parent, const KComponentData& componentData, - Modus modus ); + Modus modus, + Kasten2::ByteArrayViewProfileManager* viewProfileManager ); virtual ~OktetaPart(); @@ -89,6 +91,8 @@ Kasten2::PrintController* mPrintController; QList mControllers; + + Kasten2::ByteArrayViewProfileManager* mViewProfileManager; }; --- trunk/KDE/kdesdk/okteta/parts/kpart/partfactory.cpp #1297558:1297559 @@ -25,6 +25,7 @@ // part #include "part.h" // Okteta Kasten +#include #include #include #include @@ -47,18 +48,16 @@ static const char FWHKEmailAddress[] = "kossebau@kde.org"; -static KComponentData* _componentData = 0; -static KAboutData* _aboutData = 0; - - OktetaPartFactory::OktetaPartFactory() { // TODO: also load encoder and other plugins here - _aboutData = new KAboutData( PartId, 0, ki18n(PartName), PartVersion, ki18n(PartDescription), + mAboutData = new KAboutData( PartId, 0, ki18n(PartName), PartVersion, ki18n(PartDescription), KAboutData::License_GPL_V2, ki18n(PartCopyright), KLocalizedString(), 0, FWHKEmailAddress ); - _aboutData->addAuthor( ki18n(FWHKName), ki18n(FWHKTask), FWHKEmailAddress ); - _componentData = new KComponentData( _aboutData ); + mAboutData->addAuthor( ki18n(FWHKName), ki18n(FWHKTask), FWHKEmailAddress ); + mComponentData = new KComponentData( mAboutData ); + mByteArrayViewProfileManager = new Kasten2::ByteArrayViewProfileManager(); + // const QList encoderList = // ByteArrayStreamEncoderFactory::createStreamEncoders(); @@ -93,7 +92,7 @@ ( className == "Browser/View" ) ? OktetaPart::BrowserViewModus : /* else */ OktetaPart::ReadWriteModus; - OktetaPart* part = new OktetaPart( parent, *_componentData, modus ); + OktetaPart* part = new OktetaPart( parent, *mComponentData, modus, mByteArrayViewProfileManager ); return part; } @@ -101,6 +100,6 @@ OktetaPartFactory::~OktetaPartFactory() { - delete _componentData; - delete _aboutData; + delete mComponentData; + delete mAboutData; } --- trunk/KDE/kdesdk/okteta/parts/kpart/partfactory.h #1297558:1297559 @@ -26,7 +26,13 @@ // KDE #include +namespace Kasten2 { +class ByteArrayViewProfileManager; +} +class KComponentData; +class KAboutData; + class OktetaPartFactory : public KParts::Factory { Q_OBJECT @@ -40,6 +46,11 @@ virtual KParts::Part* createPartObject( QWidget* parentWidget, QObject* parent, const char* className, const QStringList& args ); + + private: + KComponentData* mComponentData; + KAboutData* mAboutData; + Kasten2::ByteArrayViewProfileManager* mByteArrayViewProfileManager; }; #endif