author | llornkcor <llornkcor> | 2003-05-29 01:18:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-05-29 01:18:11 (UTC) |
commit | 74f2f13e53b066eb461154f11f156bb4ce9c0646 (patch) (side-by-side diff) | |
tree | 94c8a576edd980e294a50acb95f2fdc08e1e278c | |
parent | 52047fd3d3f30509d65834747c3a0c5c6760dc01 (diff) | |
download | opie-74f2f13e53b066eb461154f11f156bb4ce9c0646.zip opie-74f2f13e53b066eb461154f11f156bb4ce9c0646.tar.gz opie-74f2f13e53b066eb461154f11f156bb4ce9c0646.tar.bz2 |
fix tr and clean up compile
-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index cca0c26..21de4d2 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp @@ -8,65 +8,66 @@ #include "formatter.h" #include "inputDialog.h" #include "output.h" #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/mimetype.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/storage.h> #include <qmultilineedit.h> #include <qstring.h> +#include <qlist.h> #include <qstringlist.h> #include <qdir.h> #include <qfile.h> -#include <qtextstream.h> +#include <qtstream.h> #include <qcombobox.h> #include <qpopupmenu.h> #include <qmessagebox.h> #include <qregexp.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qtabwidget.h> #include <qwidget.h> #include <qlayout.h> #include <qvariant.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/vfs.h> #include <mntent.h> #include <string.h> #include <errno.h> #define BLANK ' ' #define DELIMITER '#' /* Blah blah blah blah */ -FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) +FormatterApp::FormatterApp( QWidget* parent, const char* name, bool , WFlags fl ) : QMainWindow( parent, name, fl ) // : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "FormatterApp" ); connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); setCaption( tr( "Formatter" ) ); FormatterAppLayout = new QGridLayout( this ); FormatterAppLayout->setSpacing( 2); FormatterAppLayout->setMargin( 2 ); TabWidget = new QTabWidget( this, "TabWidget" ); tab = new QWidget( TabWidget, "tab" ); tabLayout = new QGridLayout( tab ); @@ -109,33 +110,33 @@ FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFla tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing(3); tabLayout_2->setMargin(2); mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1); deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1); TextLabel5 = new QLabel( tab_2, "TextLabel5" ); TextLabel5->setText( tr( "CAUTION:\n" "Changing parameters on this \n" "page may cause your system \n" - "to stop functioning properly!!" ) );//idiot message + "to stop functioning properly!" ) );//idiot message tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1); editPushButton = new QPushButton( tab_2, "editPushButton" ); editPushButton->setText( tr( "Edit fstab" ) ); editPushButton->setMaximumWidth(100); tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); fsckButton = new QPushButton( tab_2, "fsckPushButton" ); fsckButton->setText( tr( "Check Disk" ) ); fsckButton->setMaximumWidth(100); tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1); TextLabel3 = new QLabel( tab_2, "TextLabel3" ); @@ -190,57 +191,65 @@ void FormatterApp::doFormat() { #endif if( currentText.find("CF",0,TRUE) != -1) { umountS = "umount "; remountS = "mount "; // umountS = "/sbin/cardctl eject"; // remountS = "/sbin/cardctl insert"; } if( currentText.find("SD",0,TRUE) != -1) { umountS = "umount "; remountS = "mount "; // umountS = "/etc/sdcontrol compeject"; // remountS = "/etc/sdcontrol insert"; } - switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") +diskName+" "+ currentText + - tr("\nwith ") + fs + tr(" filesystem?!?\nYou will loose all data!!"),tr("Yes"),tr("No"),0,1,1) ) { + switch ( QMessageBox::warning(this,tr("Format?") + , tr("Really format\n") +diskName+" "+ currentText + + tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs ) + ,tr("Yes") + ,tr("No") + ,0 + ,1 + ,1) ) { case 0: { if(fs == "vfat") cmd = "mkdosfs -v " + diskDevice+" 2>&1"; else if(fs == "ext2") cmd = "mke2fs -v " + diskDevice+" 2>&1"; else { QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); break; } // cmd = "ls -l"; outDlg = new Output(this, tr("Formatter Output"),FALSE); outDlg->showMaximized(); outDlg->show(); qApp->processEvents(); FILE *fp; char line[130]; - outDlg->OutputEdit->append( tr("Trying to umount.") + currentText ); + + + outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); sleep(1); qDebug("Command is "+umountS); fp = popen( (const char *) umountS, "r"); - qDebug("%d", fp); + // qDebug("%d", fp); if ( !fp ) { qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); pclose(fp); return; } else { // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); while ( fgets( line, sizeof line, fp)) { if( ((QString)line).find("busy",0,TRUE) != -1) { qDebug("Could not find '" + umountS); QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); pclose(fp); return; } else { QString lineStr = line; @@ -263,41 +272,41 @@ void FormatterApp::doFormat() { QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); pclose(fp); // outDlg->OutputEdit->append("No such device"); // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); return; } else { QString lineStr = line; lineStr=lineStr.left(lineStr.length()-1); outDlg->OutputEdit->append(lineStr); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); } } outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); pclose(fp); - outDlg->OutputEdit->append( tr("Trying to mount.") + currentText ); + outDlg->OutputEdit->append( tr("Trying to mount %1.").arg( currentText) ); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); fp = popen( (const char *) remountS, "r"); if ( !fp) { qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); } else { - outDlg->OutputEdit->append( currentText + tr("\nhas been successfully mounted.")); + outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText )); while ( fgets( line, sizeof line, fp)) { QString lineStr = line; lineStr=lineStr.left(lineStr.length()-1); outDlg->OutputEdit->append(lineStr); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); } } pclose(fp); sleep(1); outDlg->OutputEdit->append(tr("You can now close the output window.")); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); // outDlg->close(); // if(outDlg) // delete outDlg; } @@ -322,42 +331,42 @@ void FormatterApp::fillCombos() { const QString disk = (*it)->disk(); const QString options = (*it)->options(); if( name.find( tr("Internal"),0,TRUE) == -1) { storageComboBox->insertItem(name +" -> "+disk); } // deviceComboBox->insertItem(disk); } parsetab("/etc/mtab"); // parsetab("/etc/fstab"); fileSystemsCombo->insertStringList( fsList,-1); deviceComboBox->insertStringList( deviceList,-1); storageComboSelected(0); deviceComboSelected(0); } -void FormatterApp::fsComboSelected(int index) { +void FormatterApp::fsComboSelected(int ) { } void FormatterApp::storageComboSelected(int index ) { QString currentText = storageComboBox->text(index); QString nameS = currentText.left( currentText.find("->",0,TRUE)); - TextLabel4->setText( tr( "Storage Type : ") + nameS ); + TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) ); currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); QString fsType = getFileSystemType((const QString &) currentText); // qDebug(fsType); for(int i = 0; i < fileSystemsCombo->count(); i++) { if( fsType == fileSystemsCombo->text(i)) fileSystemsCombo->setCurrentItem(i); } // deviceComboSelected(index); } void FormatterApp::deviceComboSelected(int index) { StorageInfo storageInfo; QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; @@ -378,33 +387,33 @@ void FormatterApp::deviceComboSelected(int index) { long div = 1024 / (*it)->blockSize(); if ( !mult ) mult = 1; if ( !div ) div = 1; long total = (*it)->totalBlocks() * mult / div; long totalMb = total/1024; long avail = (*it)->availBlocks() * mult / div; long availMb = avail/1024; long used = total - avail; long usedMb = used/1024; totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); } } fsType = getFileSystemType((const QString &)selectedText); - TextLabel5->setText("Type: "+ nameS+"\nFormatted with "+ fsType + " \n" + totalS + usedS + avS); + TextLabel5->setText(tr("Type: %1\nFormatted with %1\n%1, %1, %1").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS )); // storageComboSelected(0); } void FormatterApp::cleanUp() { } void FormatterApp::editFstab() { QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); e << (const QString &)"/etc/fstab"; } void FormatterApp::parsetab(const QString &fileName) { fileSystemTypeList.clear(); @@ -550,25 +559,25 @@ bool FormatterApp::doFsck() { outDlg->OutputEdit->append(tr("You can now close the output window.")); outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); pclose(fp); ///////////////////////////////////////// return true; } bool FormatterApp::doFsckCheck() { return FALSE; } -int FormatterApp::formatCheck(const QString &deviceStr) { +int FormatterApp::formatCheck(const QString &) { return -1; } -int FormatterApp::runCommand(const QString &command) { +int FormatterApp::runCommand(const QString &) { return -1; } |