Show
Ignore:
Timestamp:
01/22/10 19:44:34 (2 years ago)
Author:
sven-win
Message:

Umfangreiche Weiterentwicklung (letzte Entwicklung am Netbook). Driver fuer M200 erstmals testweise implementiert; funktioniert(e mit Netbook).

-- Sven @ netboo

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • punch-card-project/trunk/punch-card-editor/src/qpunchcard/deck.cc

    r53 r59  
    77} 
    88 
    9 Deck::Deck(const FileFormat* format, QObject* parent) : 
    10                 QObject(parent), undo_stack(this), format(format) { 
     9Deck::Deck(FileFormat format, const QString& filename, QObject* parent) : 
     10                QObject(parent), undo_stack(this), format(format), filename(filename) { 
    1111        init(); 
     12        read(); 
    1213} 
    1314 
     
    1819 
    1920bool Deck::save() { 
    20         return file ? save(*file) : false; 
     21        return hasFile() ? save(filename) : false; 
    2122} 
    2223 
    23 bool Deck::save(QFile& file) { 
    24         return save(format.data(), file); 
     24bool Deck::save(const QString& filename) { 
     25        return hasFormat() ? save(format, filename) : false; 
    2526} 
    2627 
    27 bool Deck::save(const FileFormat* format, QFile& file) { 
    28         return format ? format->write(file, *this) : false; 
     28bool Deck::save(FileFormat format, const QString& filename) { 
     29        QFile file(filename); 
     30        return save(format, file); 
     31} 
     32 
     33bool Deck::save(FileFormat format, QFile& file) { 
     34        if( format.write(file, this) ) { 
     35                // save filename and format 
     36                this->format = format; 
     37                this->filename = file.fileName(); 
     38                return true; 
     39        } else { 
     40                qDebug() << "Deck saving failed. Format: " << format.getName(); 
     41                return false; 
     42        } 
    2943} 
    3044 
    3145bool Deck::read() { 
    32         return file ? read(*file) : false; 
     46        return hasFile() ? read(filename) : false; 
    3347} 
    3448 
    35 bool Deck::read(QFile& file) { 
    36         return read(format.data(), file); 
     49bool Deck::read(const QString& filename) { 
     50        return hasFormat() ? save(format, filename) : false; 
    3751} 
    3852 
    39 bool Deck::read(const FileFormat* format, QFile& file) { 
    40         return format ? format->read(file, *this) : false; 
     53bool Deck::read(FileFormat format, const QString &filename) { 
     54        QFile file(filename); 
     55        return read(format, file); 
    4156} 
    4257 
    43 void Deck::setFormat(const FileFormat* new_format) { 
    44         format = QSharedPointer<const FileFormat>(new_format); 
    45 } 
    46  
    47 void Deck::setFile(QFile* file) { 
    48         this->file = QSharedPointer<QFile>(file); 
     58bool Deck::read(FileFormat format, QFile& file) { 
     59        if( format.read(file, this) ) { 
     60                this->format = format; 
     61                this->filename = file.fileName(); 
     62                return true; 
     63        } else { 
     64                return false; 
     65        } 
    4966} 
    5067 
© 2008 - 2010 Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License