Show
Ignore:
Timestamp:
12/31/08 18:23:22 (4 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
215618cb3db4556e21f4040ae192e01f100fde03
Children:
c66abc31de85dace6d89600a4638b1993978f0e4
git-committer:
Armin Burgmeier <armin@arbur.net> / 2008-12-31T18:23:22Z+0100
Message:

Added begin-save-operation signal

2008-12-31 Armin Burgmeier <armin@…>

  • code/operations/operations.hpp:
  • code/operations/operations.cpp: Added a begin_save_operation signal, and added a boolean parameter to base operation's finished signal which indicates whether the operation was performed successfully or not. Removed the remove() function, and added finish() and fail() instead.
  • code/operations/operation-open.hpp: Derive from sigc::trackable.
  • code/operations/operation-save.hpp:
  • code/operations/operation-save.cpp: Added get_document(), get_start_time() and derive from sigc::trackable, adapt to finish() and fail().
  • code/operations/operation-new.cpp:
  • code/operations/operation-open.cpp:
  • code/operations/operation-delete.cpp: Adapt to finish() and fail().
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • code/operations/operations.cpp

    r215618c r9a8cd27  
    4444} 
    4545 
    46 Gobby::Operations::Operation* 
     46Gobby::OperationNew* 
    4747Gobby::Operations::create_directory(InfcBrowser* browser, 
    4848                                    InfcBrowserIter* parent, 
     
    5656} 
    5757 
    58 Gobby::Operations::Operation* 
     58Gobby::OperationNew* 
    5959Gobby::Operations::create_document(InfcBrowser* browser, 
    6060                                   InfcBrowserIter* parent, 
     
    6868} 
    6969 
    70 Gobby::Operations::Operation* 
     70Gobby::OperationOpen* 
    7171Gobby::Operations::create_document(InfcBrowser* browser, 
    7272                                   InfcBrowserIter* parent, 
     
    8484} 
    8585 
    86 Gobby::Operations::Operation* 
     86Gobby::OperationSave* 
    8787Gobby::Operations::save_document(DocWindow& document, 
    8888                                 Folder& folder, 
     
    9191                                 DocumentInfoStorage::EolStyle eol_style) 
    9292{ 
     93        OperationSave* prev_op = get_save_operation_for_document(document); 
     94 
     95        // Cancel previous save operation: 
     96        if(prev_op != NULL) 
     97                fail_operation(prev_op); 
     98 
    9399        OperationSave* op = new OperationSave(*this, document, folder, uri, 
    94100                                              encoding, eol_style); 
    95101 
    96102        m_operations.insert(op); 
     103        m_signal_begin_save_operation.emit(op); 
    97104        return op; 
    98105} 
    99106 
    100 Gobby::Operations::Operation* 
     107Gobby::OperationDelete* 
    101108Gobby::Operations::delete_node(InfcBrowser* browser, 
    102109                               InfcBrowserIter* iter) 
     
    107114} 
    108115 
    109 void Gobby::Operations::remove_operation(Operation* operation) 
     116Gobby::OperationSave* 
     117Gobby::Operations::get_save_operation_for_document(DocWindow& document) 
     118{ 
     119        for(OperationSet::iterator iter = m_operations.begin(); 
     120            iter != m_operations.end(); ++ iter) 
     121        { 
     122                Operation* op = *iter; 
     123                OperationSave* save_op = dynamic_cast<OperationSave*>(op); 
     124                if(save_op != NULL) 
     125                { 
     126                        if(save_op->get_document() == &document) 
     127                                return save_op; 
     128                } 
     129        } 
     130 
     131        return NULL; 
     132} 
     133 
     134void Gobby::Operations::finish_operation(Operation* operation) 
    110135{ 
    111136        m_operations.erase(operation); 
     137        operation->signal_finished().emit(true); 
    112138        delete operation; 
    113139} 
     140 
     141void Gobby::Operations::fail_operation(Operation* operation) 
     142{ 
     143        m_operations.erase(operation); 
     144        operation->signal_finished().emit(false); 
     145        delete operation; 
     146}