コード例 #1
0
void DCommandHistory::redo() {
    DCommand* command = m_commands[ d->m_current + 1 ];
    command->execute();
    emit commandExecuted( command );

    if ( m_undo ) {
        m_undo->setEnabled(true);
        m_undo->setText( tr("&Undo: %1").arg(command->name()) );
    }

    ++d->m_current;

    if ( d->m_current == d->m_savedAt )
        emit documentRestored();

    if ( isRedoAvailable() ) {
        if ( m_redo ) {
            command = m_commands[ d->m_current + 1 ];
            m_redo->setEnabled(true);
            m_redo->setText( tr("&Redo: %1").arg(command->name()) );
        }
    } else {
        if( m_redo ) {
            m_redo->setEnabled(false);
            m_redo->setText( tr("&Redo") );
        }
    }

    emit modified();
}
コード例 #2
0
void DCommandHistory::undo() {
    Q_ASSERT( d->m_current >= 0 );

    DCommand* command = m_commands[ d->m_current ];

    command->unexecute();
    emit commandExecuted( command );
    if ( m_redo )
    {
        m_redo->setEnabled(true);
        m_redo->setText( tr("&Redo: %1").arg(command->name()) );
    }

    --d->m_current;
    if ( d->m_current >= 0 ) {
        // undoing further is possible
        if (m_undo ) {
            DCommand* command = m_commands[ d->m_current ];
            m_undo->setEnabled(true);
            m_undo->setText( tr("&Undo: %1").arg(command->name()) );
        }
    } else {
        // undoing further is not possible
        if ( m_undo ) {
            m_undo->setEnabled(false);
            m_undo->setText( tr("&Undo") );
        }
    }

    if ( d->m_current == d->m_savedAt )
        emit documentRestored();

    clipCommands(); // only needed here and in addCommand, NOT in redo

    emit modified();
}
コード例 #3
0
FITSViewer::FITSViewer (const KURL *url, QWidget *parent, const char *name)
	: KMainWindow (parent, name)
{
    image      = NULL;
    currentURL = *url;
    imgBuffer  = NULL;
    histo      = NULL;
    Dirty      = 0;
    
    /* Initiliaze menu actions */
    history = new KCommandHistory(actionCollection());
    history->setUndoLimit(10);
    history->setRedoLimit(10);
    history->documentSaved();
    connect(history, SIGNAL(documentRestored()), this, SLOT(fitsRestore()));
    
    /* Setup image widget */    
    image = new FITSImage(this);
    setCentralWidget(image);
   
    statusBar()->insertItem("", 0);
    statusBar()->setItemFixed(0, 100);
    statusBar()->insertItem("", 1);
    statusBar()->setItemFixed(1, 100);
    statusBar()->insertItem("", 2);
    statusBar()->setItemFixed(2, 100);
    statusBar()->insertItem(i18n("Welcome to KStars FITS Viewer"), 3, 1, true);
    statusBar()->setItemAlignment(3 , Qt::AlignLeft);
    
    /* FITS initializations */
    if (!initFITS())
    {
     close();
     return;
    }
     
    QFile tempFile;
    
    if (KSUtils::openDataFile( tempFile, "imgreduction.png" ) )
    {
    	new KAction( i18n("Image Reduction"), tempFile.name(), KShortcut( "Ctrl+R" ), this, SLOT( imageReduction()), actionCollection(), "image_reduce");
	tempFile.close();
    }
    else
    	new KAction( i18n("Image Reduction"), "blend", KShortcut( "Ctrl+R" ), this, SLOT( imageReduction()), actionCollection(), "image_reduce");
	
    /*if (KSUtils::openDataFile( tempFile, "bricon.png" ) )
    {
    	new KAction( i18n("Brightness/Contrast"), tempFile.name(), KShortcut( "Ctrl+T" ), this, SLOT( BrightContrastDlg()), actionCollection(), "image_brightness_contrast");
	tempFile.close();
    }
    else*/
       	new KAction( i18n("Brightness/Contrast"), "contrast+", KShortcut( "Ctrl+T" ), this, SLOT( BrightContrastDlg()), actionCollection(), "image_brightness_contrast");
	
    if (KSUtils::openDataFile( tempFile, "histogram.png" ) )
    {
    	new KAction ( i18n("Histogram"), tempFile.name(), KShortcut("Ctrl+H"), this, SLOT (imageHistogram()), actionCollection(), "image_histogram");
	tempFile.close();
    }
    else
        new KAction ( i18n("Histogram"), "wizard", KShortcut("Ctrl+H"), this, SLOT (imageHistogram()), actionCollection(), "image_histogram");
    
    KStdAction::open(this, SLOT(fileOpen()), actionCollection());   
    KStdAction::save(this, SLOT(fileSave()), actionCollection());
    KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
    KStdAction::close(this, SLOT(slotClose()), actionCollection());
    KStdAction::copy(this, SLOT(fitsCOPY()), actionCollection());
    KStdAction::zoomIn(image, SLOT(fitsZoomIn()), actionCollection());
    KStdAction::zoomOut(image, SLOT(fitsZoomOut()), actionCollection());
    new KAction( i18n( "&Default Zoom" ), "viewmagfit.png", KShortcut( "Ctrl+D" ),
		image, SLOT(fitsZoomDefault()), actionCollection(), "zoom_default" );
    new KAction( i18n( "Statistics"), "sum", 0, this, SLOT(fitsStatistics()), actionCollection(), "image_stats");
    new KAction( i18n( "FITS Header"), "frame_spreadsheet.png", 0, this, SLOT(fitsHeader()), actionCollection(), "fits_editor");
    
   /* Create GUI */  
   createGUI("fitsviewer.rc");
     
   /* initially resize in accord with KDE rules */
   resize(640, 480); 
}