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/text/editordock.cc

    r58 r59  
    77#include <QComboBox> 
    88#include <QPushButton> 
     9#include <QFileDialog> 
     10#include <QMessageBox> 
    911 
    1012using namespace QPunchCard; 
     
    6769} 
    6870 
     71const Codec* Text::EditorDock::getCodec() const { 
     72        return editor->codec; 
     73} 
     74 
     75QString Text::EditorDock::getText() const { 
     76        return editor->toPlainText(); 
     77} 
     78 
    6979void Text::EditorDock::setCodec(QString by_name) { 
    7080        // QSharedPointer: Durch Assignment wird das alte Objekt geloescht :-) 
     
    7484} 
    7585 
     86bool Text::EditorDock::exportTextAs() { 
     87        // show a funny `export text as` dialog 
     88        QString new_filename = QFileDialog::getSaveFileName(main, 
     89                tr("Export Card Text (%1)").arg(getCodec()->getName()), 
     90                filename.isEmpty() ? QDir::homePath() : QFileInfo(filename).absolutePath(), 
     91                tr("Plain Text File (*.txt);;Any File (*)")); 
     92        if(new_filename.isEmpty()) 
     93                return false; 
     94 
     95        // save filename and go on exporting normally 
     96        this->filename = new_filename; 
     97        this->exportText(); 
     98} 
     99 
     100bool Text::EditorDock::exportText() { 
     101        if(this->filename.isEmpty()) { 
     102                return exportTextAs(); 
     103        } 
     104 
     105        QFile file(this->filename); 
     106        // everything in one line ;-) 
     107        if(!file.open( QIODevice::WriteOnly | QIODevice::Text ) || 
     108           (file.write( this->getText().toAscii() ) == -1)  ) { 
     109                QMessageBox::critical(main, tr("Could not export to file"), 
     110                                      tr("Plain text export to file %1 failed: %2").arg(filename).arg(file.errorString())); 
     111                return false; 
     112        } else { 
     113                main->statusBar()->showMessage(tr("Successfully exported card text as %1 to %2 ").arg(getCodec()->getName()).arg(filename), 5000); 
     114                return true; 
     115        } 
     116} 
     117 
    76118void Text::EditorDock::showTextConverterDialog() { 
    77         qDebug("Text Converter Dialog... PENDING"); 
     119        QMessageBox::information(main, tr("Pending work"), tr("Well... the Text Converter Dialog hasn't been done yet...")); 
    78120} 
© 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