author | zecke <zecke> | 2004-03-13 22:41:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-13 22:41:59 (UTC) |
commit | 3d27828732fe7e499219ad6e208dc13dead86431 (patch) (side-by-side diff) | |
tree | faa42dec364ad1e0470a370c81d0a7dc0cd2f9bc | |
parent | ee753c0009da5bec4a71d3263e9623d04dddc5c4 (diff) | |
download | opie-3d27828732fe7e499219ad6e208dc13dead86431.zip opie-3d27828732fe7e499219ad6e208dc13dead86431.tar.gz opie-3d27828732fe7e499219ad6e208dc13dead86431.tar.bz2 |
Namespace changes for Apps
QAshMoney and Reader need to be valgrinded
43 files changed, 90 insertions, 63 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 2ba3dca..a60d6ce 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -1,227 +1,229 @@ /*************************************************************************** AdvancedFm.cpp ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #define DEVELOPERS_VERSION #include "advancedfm.h" #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/mimetype.h> #include <qpe/applnk.h> #include <qpe/resource.h> #include <qpe/menubutton.h> #include <qcombobox.h> #include <qpopupmenu.h> #include <qlistview.h> #include <qmessagebox.h> #include <qlineedit.h> #include <sys/stat.h> #include <time.h> #include <dirent.h> #include <fcntl.h> #include <sys/vfs.h> #include <mntent.h> +using namespace Opie::Ui; + #ifdef NOQUICKLAUNCH AdvancedFm::AdvancedFm( ) #else AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) #endif : QMainWindow( ) { init(); renameBox = 0; unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); initConnections(); whichTab=1; rePopulate(); currentPathCombo->setFocus(); channel = new QCopChannel( "QPE/Application/advancedfm", this ); connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); } AdvancedFm::~AdvancedFm() { } void AdvancedFm::cleanUp() { QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); if(file.exists()) file.remove(); } void AdvancedFm::tabChanged(QWidget *) { // qWarning("tab changed"); QString path = CurrentDir()->canonicalPath(); currentPathCombo->lineEdit()->setText( path ); if(whichTab == 1) { viewMenu->setItemChecked(viewMenu->idAt(0), true); viewMenu->setItemChecked(viewMenu->idAt(1), false); } else { viewMenu->setItemChecked(viewMenu->idAt(0), false); viewMenu->setItemChecked(viewMenu->idAt(1), true); } QString fs= getFileSystemType( (const QString &) path); setCaption(tr("AdvancedFm :: ")+fs+" :: " +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); chdir( path.latin1()); } void AdvancedFm::populateView() { // qWarning("PopulateView"); QPixmap pm; QListView *thisView = CurrentView(); QDir *thisDir = CurrentDir(); QString path = thisDir->canonicalPath(); //qWarning("path is "+path); thisView->clear(); thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); thisDir->setMatchAllDirs(TRUE); thisDir->setNameFilter(filterStr); QString fileL, fileS, fileDate; QString fs= getFileSystemType((const QString &) path); setCaption(tr("AdvancedFm :: ")+fs+" :: " +checkDiskSpace((const QString &) path)+ tr(" kB free") ); bool isDir=FALSE; const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); QFileInfo *fi; while ( (fi=it.current()) ) { if (fi->isSymLink() ) { QString symLink=fi->readLink(); QFileInfo sym( symLink); fileS.sprintf( "%10i", sym.size() ); fileL = fi->fileName() +" -> " + sym.filePath().data(); fileDate = sym.lastModified().toString(); } else { fileS.sprintf( "%10i", fi->size() ); fileL = fi->fileName(); fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { // if(fileL == "..") fileL += "/"; isDir=TRUE; } } QFileInfo fileInfo( path + "/" + fileL); if(fileL !="./" && fi->exists()) { item = new QListViewItem( thisView, fileL, fileS , fileDate); if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) //is directory pm = Resource::loadPixmap( "lockedfolder" ); else pm= Resource::loadPixmap( "folder" ); } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { pm = Resource::loadPixmap( "exec"); } else if( (fileInfo.permission( QFileInfo::ExeUser) | fileInfo.permission( QFileInfo::ExeGroup) | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { pm = Resource::loadPixmap( "exec"); } else if( !fi->isReadable() ) { pm = Resource::loadPixmap( "locked" ); } else { //everything else goes by mimetype MimeType mt(fi->filePath()); pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) { pm = unknownXpm; } } if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { // qDebug(" overlay link image"); pm= Resource::loadPixmap( "advancedfm/symlink" ); // pm= Resource::loadPixmap( "folder" ); // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); // QPainter painter( &pm ); // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); // pm.setMask( pm.createHeuristicMask( FALSE ) ); } item->setPixmap( 0,pm); } isDir=FALSE; ++it; } if( path.find("dev",0,TRUE) != -1) { struct stat buf; dev_t devT; DIR *dir; struct dirent *mydirent; if((dir = opendir( path.latin1())) != NULL) while ((mydirent = readdir(dir)) != NULL) { lstat( mydirent->d_name, &buf); // qDebug(mydirent->d_name); fileL.sprintf("%s", mydirent->d_name); devT = buf.st_dev; fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); fileDate.sprintf("%s", ctime( &buf.st_mtime)); if( fileL.find(".") == -1 ) { item= new QListViewItem( thisView, fileL, fileS, fileDate); pm = unknownXpm; item->setPixmap( 0,pm); } } closedir(dir); } thisView->setSorting( 3,FALSE); fillCombo( (const QString &) path ); } void AdvancedFm::rePopulate() { populateView(); setOtherTabCurrent(); populateView(); // int tmpTab = whichTab; // // qDebug("%d", tmpTab); // for(int i =1; i < 3; i++) { // TabWidget->setCurrentWidget(i - 1); // populateView(); // } // TabWidget->setCurrentWidget( tmpTab - 1); } void AdvancedFm::ListClicked(QListViewItem *selectedItem) { //qWarning("listclicked"); if(selectedItem) { QString strItem=selectedItem->text(0); // qWarning(strItem); QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); bool isDirectory = false; QString strItem2; diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 547fa7c..4eaa6d6 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -1,192 +1,191 @@ /*************************************************************************** advancedfm.h ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #ifndef ADVANCEDFM_H #define ADVANCEDFM_H #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties #define QT_QWS_OPIE #include <opie2/oprocess.h> #include <opie2/osplitter.h> #include <qpe/ir.h> #include <qpe/qcopenvelope_qws.h> #include <qvariant.h> #include <qdialog.h> #include <qmainwindow.h> #include <qstringlist.h> #include <qdir.h> #include <qstring.h> #include <qpoint.h> #include <qtimer.h> #include <qpixmap.h> -using Opie::OSplitter; class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QComboBox; class QListView; class QListviewItem; class QLabel; class QProgressBar; class QSpinBox; class QWidget; class QPopupMenu; class QFile; class QListViewItem; class QLineEdit; class MenuButton; class QToolButton; class Ir; class AdvancedFm : public QMainWindow { Q_OBJECT public: static QString appName() { return QString::fromLatin1("advancedfm"); } #ifdef NOQUICKLAUNCH AdvancedFm(); #else AdvancedFm(QWidget *p = 0, const char* name = 0, WFlags fl = 0); #endif ~AdvancedFm(); protected slots: void slotSwitchMenu(int); void selectAll(); void addToDocs(); void doDirChange(); void mkDir(); void del(); void rn(); void populateView(); void rePopulate(); void showHidden(); void showMenuHidden(); void writeConfig(); void readConfig(); void ListClicked(QListViewItem *); void ListPressed( int, QListViewItem *, const QPoint&, int); void makeDir(); void doDelete(); void tabChanged(QWidget*); void cleanUp(); void renameIt(); void runThis(); void runText(); void filePerms(); void doProperties(); void runCommand(); void runCommandStd(); QStringList getPath(); void mkSym(); void switchToLocalTab(); void switchToRemoteTab(); protected: - OSplitter *TabWidget; + Opie::Ui::OSplitter *TabWidget; QCopChannel * channel; QPixmap unknownXpm; int whichTab; // QTabWidget *TabWidget; QWidget *tab, *tab_2, *tab_3; QListView *Local_View, *Remote_View; QLineEdit *currentPathEdit; QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; QDir currentDir, currentRemoteDir; QComboBox *currentPathCombo; QString filterStr, s_addBookmark, s_removeBookmark; QListViewItem * item; bool b; QStringList fileSystemTypeList, fsList; int currentServerConfig; bool zaurusDevice; QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; QStringList remoteDirPathStringList, localDirPathStringList; QLineEdit *renameBox; void init(); void initConnections(); void keyReleaseEvent( QKeyEvent *); void keyPressEvent( QKeyEvent *); QString getFileSystemType(const QString &); QString getDiskSpace(const QString &); void parsetab(const QString &fileName); QString checkDiskSpace(const QString &); QString dealWithSymName(const QString &); QDir *CurrentDir(); QDir *OtherDir(); QListView *CurrentView(); QListView *OtherView(); void setOtherTabCurrent(); void dealWithSchmooSchmaa(QWidget *); protected slots: void openSearch(); void dirMenuSelected(int); void showFileMenu(); void cancelMenuTimer(); void homeButtonPushed(); void docButtonPushed(); void SDButtonPushed(); void CFButtonPushed(); void QPEButtonPushed(); void upDir(); void currentPathComboChanged(); void copy(); void copyAs(); void copySameDir(); void currentPathComboActivated(const QString &); void fillCombo(const QString &); bool copyFile( const QString & , const QString & ); void move(); void fileStatus(); void doAbout(); void doBeam(); void fileBeamFinished( Ir *); bool copyDirectory( const QString & , const QString & ); // void navigateToSelected(); bool moveDirectory( const QString & , const QString & ); // void slotSwitchtoLocal(int); private: MenuButton *menuButton; QString oldName; QTimer menuTimer; void startProcess(const QString &); bool eventFilter( QObject * , QEvent * ); void cancelRename(); void doRename(QListView *); void okRename(); void customDirsToMenu(); void addCustomDir(); void removeCustomDir(); void gotoDirectory(const QString &); void navigateToSelected(); void findFile(const QString &); private slots: - void processEnded(OProcess *); - void oprocessStderr(OProcess *, char *, int); + void processEnded(Opie::Core::OProcess *); + void oprocessStderr(Opie::Core::OProcess *, char *, int); void gotoCustomDir(const QString &); void qcopReceive(const QCString&, const QByteArray&); void setDocument(const QString &); }; #endif // ADVANCEDFM_H diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index f791c77..73ef8f9 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp @@ -1,221 +1,222 @@ /*************************************************************************** advancedfmData.cpp ------------------- ** Created: Mon 09-23-2002 13:24:11 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "advancedfm.h" #include <qpe/storage.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/menubutton.h> #include <qlayout.h> #include <qhbox.h> #include <qmenubar.h> #include <qcombobox.h> #include <qtoolbutton.h> #include <qlineedit.h> #include <qlistview.h> #include <sys/utsname.h> +using namespace Opie::Ui; void AdvancedFm::init() { #if defined(QT_QWS_OPIE) qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); #endif setCaption( tr( "AdvancedFm" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setSpacing( 2); layout->setMargin( 2); QMenuBar *menuBar = new QMenuBar(this); fileMenu = new QPopupMenu( this ); viewMenu = new QPopupMenu( this ); // customDirMenu = new QPopupMenu( this ); layout->addWidget( menuBar ); menuBar->insertItem( tr( "File" ), fileMenu); menuBar->insertItem( tr( "View" ), viewMenu); cdUpButton = new QToolButton( 0,"cdUpButton"); cdUpButton->setPixmap(Resource::loadPixmap("up")); cdUpButton->setAutoRaise( true ); menuBar->insertItem( cdUpButton ); QHBox *lineBox = new QHBox( this ); qpeDirButton= new QToolButton( 0,"QPEButton"); qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); qpeDirButton->setAutoRaise( true ); menuBar->insertItem( qpeDirButton ); cfButton = new QToolButton( 0, "CFButton"); cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); cfButton->setAutoRaise( true ); menuBar->insertItem( cfButton ); sdButton = new QToolButton( 0, "SDButton"); sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); sdButton->setAutoRaise( true ); menuBar->insertItem( sdButton ); docButton = new QToolButton( 0,"docsButton"); docButton->setPixmap(Resource::loadPixmap("DocsIcon")); docButton->setAutoRaise( true ); menuBar->insertItem( docButton ); homeButton = new QToolButton( 0, "homeButton"); homeButton->setPixmap(Resource::loadPixmap("home")); homeButton->setAutoRaise( true ); menuBar->insertItem( homeButton ); fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); fileMenu->setCheckable(TRUE); viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); // viewMenu->insertSeparator(); // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); viewMenu->setCheckable(true); viewMenu->setItemChecked( viewMenu->idAt(0), true); viewMenu->setItemChecked( viewMenu->idAt(1), false); s_addBookmark = tr("Bookmark Directory"); s_removeBookmark = tr("Remove Current Directory from Bookmarks"); // menuButton->insertItem(""); // customDirMenu->insertItem(tr("Add This Directory")); // customDirMenu->insertItem(tr("Remove This Directory")); // customDirMenu->insertSeparator(); menuButton = new MenuButton( lineBox ); menuButton->setUseLabel(false); menuButton->setMaximumWidth( 20 ); menuButton->insertItem( s_addBookmark); menuButton->insertItem( s_removeBookmark); menuButton->insertSeparator(); menuButton->setFocusPolicy(NoFocus); customDirsToMenu(); currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); currentPathCombo->setEditable(TRUE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); currentPathCombo->setFocusPolicy(NoFocus); layout->addWidget( lineBox ); TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); // TabWidget = new QTabWidget( this, "TabWidget" ); layout->addWidget( TabWidget, 4 ); tab = new QWidget( TabWidget, "tab" ); tabLayout = new QGridLayout( tab ); tabLayout->setSpacing( 2); tabLayout->setMargin( 2); Local_View = new QListView( tab, "Local_View" ); Local_View->addColumn( tr("File"),130); Local_View->addColumn( tr("Size"),-1); Local_View->setColumnAlignment(1,QListView::AlignRight); Local_View->addColumn( tr("Date"),-1); Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); Local_View->setMultiSelection( TRUE ); Local_View->setSelectionMode(QListView::Extended); Local_View->setFocusPolicy(StrongFocus); Local_View->installEventFilter( this ); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); // TabWidget->insertTab( tab, tr("1")); tab_2 = new QWidget( TabWidget, "tab_2" ); tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing( 2); tabLayout_2->setMargin( 2); Remote_View = new QListView( tab_2, "Remote_View" ); Remote_View->addColumn( tr("File"),130); Remote_View->addColumn( tr("Size"),-1); Remote_View->setColumnAlignment(1,QListView::AlignRight); Remote_View->addColumn( tr("Date"),-1); Remote_View->setColumnAlignment(2,QListView::AlignRight); Remote_View->setAllColumnsShowFocus(TRUE); Remote_View->setMultiSelection( TRUE ); Remote_View->setSelectionMode(QListView::Extended); Remote_View->setFocusPolicy(StrongFocus); Remote_View->installEventFilter( this ); QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); tabLayout_2->addWidget( Remote_View, 0, 0 ); TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); TabWidget->setSizeChange( 370 ); // TabWidget->insertTab( tab_2, tr( "2")); /* tab_3 = new QWidget( TabWidget, "tab_3" ); tabLayout_3 = new QGridLayout( tab_3 ); tabLayout_3->setSpacing( 2); tabLayout_3->setMargin( 2); // OFileDialog fileDialog; // fileDialog; // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); QListView *fileTree; fileTree = new QListView( tab_3, "tree" ); tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); TabWidget->insertTab( tab_3, tr( "Remote" ) ); */ /////////////// if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) zaurusDevice=TRUE; else zaurusDevice=FALSE; if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { qDebug("not have sd"); sdButton->hide(); } if( !StorageInfo::hasCf() ) { qDebug("not have cf"); diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 9e740d0..a694b70 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -1,226 +1,228 @@ /***************************************************************************
AdvancedFm.cpp
-------------------
** Created: Sat Mar 9 23:33:09 2002
copyright : (C) 2002 by ljp
email : ljp@llornkcor.com
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "advancedfm.h"
#include "output.h"
#include "filePermissions.h"
#include <qpe/lnkproperties.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qlistview.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/sendfile.h>
#include <fcntl.h>
+using namespace Opie::Core; +using namespace Opie::Core; void AdvancedFm::doDirChange() {
QString pathItem = CurrentView()->currentItem()->text(0);
if( pathItem == "../") {
ListClicked( CurrentView()->currentItem());
} else {
if( pathItem.find(" -> ",0,TRUE) != -1)
pathItem = dealWithSymName((const QString&)pathItem)+"/";
// qWarning(pathItem);
gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
}
}
void AdvancedFm::showMenuHidden() {
if (b) {
CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
} else {
CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
}
b = !b;
populateView();
}
void AdvancedFm::showHidden() {
if (b) {
CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
} else {
CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
}
populateView();
}
QString AdvancedFm::dealWithSymName(const QString &fileName) {
QString strItem = fileName;
return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
}
void AdvancedFm::runThis() {
if( !CurrentView()->currentItem()) return;
QString fs;
QDir *thisDir = CurrentDir();
QString curFile = CurrentView()->currentItem()->text(0);
QString path = thisDir->canonicalPath();
if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
curFile = dealWithSymName((const QString&)curFile);
if(curFile != "../") {
fs = getFileSystemType((const QString &) path);
QFileInfo fileInfo( path + "/" + curFile);
// qDebug( fileInfo.owner());
if( (fileInfo.permission( QFileInfo::ExeUser)
| fileInfo.permission( QFileInfo::ExeGroup)
| fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
| fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
QCopEnvelope e("QPE/System", "execute(QString)" );
e << curFile;
} else {
curFile = path + "/" + curFile;
DocLnk nf(curFile);
QString execStr = nf.exec();
// qDebug( execStr);
if( execStr.isEmpty() ) {
} else {
nf.execute();
}
}
}
}
void AdvancedFm::runText() {
if( !CurrentView()->currentItem()) return;
QString curFile = CurrentView()->currentItem()->text(0);
if(curFile != "../") {
if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
curFile = dealWithSymName((const QString&)curFile);
curFile = CurrentDir()->canonicalPath()+"/"+curFile;
QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
e << curFile;
}
}
void AdvancedFm::makeDir() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QDir *thisDir = CurrentDir();
QString filename = fileDlg->LineEdit1->text();
thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
}
populateView();
}
void AdvancedFm::doDelete() {
QStringList curFileList = getPath();
bool doMsg=true;
int count = curFileList.count();
if( count > 0) {
if(count > 1 ) {
QString msg;
msg=tr("Really delete\n%1 files?").arg(count);
switch ( QMessageBox::warning(this,tr("Delete"),msg
,tr("Yes"),tr("No"),0,0,1) )
{
case 0:
doMsg=false;
break;
case 1:
return;
break;
};
}
QString myFile;
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
myFile = (*it);
if( myFile.find(" -> ",0,TRUE) != -1)
myFile = myFile.left( myFile.find(" -> ",0,TRUE));
QString f = CurrentDir()->canonicalPath();
if(f.right(1).find("/",0,TRUE) == -1)
f += "/";
f += myFile;
if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
//if file is a directory
switch ( QMessageBox::warning( this, tr("Delete Directory?"),
tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
tr("Yes"), tr("No"), 0, 0, 1) ) {
case 0:
{
f=f.left(f.length()-1);
QString cmd="rm -rf "+f;
startProcess( (const QString)cmd.latin1() );
populateView();
}
break;
case 1:
// exit
break;
};
} else {
if(doMsg) {
switch ( QMessageBox::warning(this,tr("Delete"),
tr("Really delete\n%1?").arg( myFile ),
tr("Yes"), tr("No"), 0, 0, 1) ) {
case 1:
return;
break;
};
}
QString cmd="rm "+f;
QFile file(f);
QFileInfo fi(myFile);
if( fi.fileName().find("../",0,TRUE)==-1) {
// qDebug("remove link files "+myFile);
// DocLnk lnk(f);
DocLnk *lnk;
lnk = new DocLnk(f);
// qDebug("Deleting doclnk " + lnk->linkFile());
if(lnk->isValid())
lnk->removeLinkFile();
// delete lnk;
file.remove();
}
}
}
}
populateView();
}
void AdvancedFm::filePerms() {
QStringList curFileList = getPath();
QString filePath;
filePath = CurrentDir()->canonicalPath()+"/";
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
@@ -513,324 +515,324 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { }
bool success = true;
struct stat status;
QFile srcFile(src);
QFile destFile(dest);
int err=0;
int read_fd=0;
int write_fd=0;
struct stat stat_buf;
off_t offset = 0;
if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
// qWarning("open failed");
return success = false;
}
read_fd = srcFile.handle();
if(read_fd != -1) {
fstat (read_fd, &stat_buf);
if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
// qWarning("destfile open failed");
return success = false;
}
write_fd = destFile.handle();
if(write_fd != -1) {
err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
if( err == -1) {
QString msg;
switch(err) {
case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
case EINVAL: msg = "Descriptor is not valid or locked. ";
case ENOMEM: msg = "Insufficient memory to read from in_fd.";
case EIO: msg = "Unspecified error while reading from in_fd.";
};
success = false;
// qWarning(msg);
}
} else {
success = false;
}
} else {
success = false;
}
srcFile.close();
destFile.close();
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ) {
chmod( (const char *) dest, status.st_mode );
}
return success;
}
void AdvancedFm::runCommand() {
if( !CurrentView()->currentItem()) return;
QDir *thisDir = CurrentDir();
QString curFile;
curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
//QString command;
if( fileDlg->result() == 1 ) {
// qDebug(fileDlg->LineEdit1->text());
QStringList command;
command << "/bin/sh";
command << "-c";
command << fileDlg->LineEdit1->text();
Output *outDlg;
outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
QPEApplication::execDialog( outDlg );
qApp->processEvents();
}
}
void AdvancedFm::runCommandStd() {
if( !CurrentView()->currentItem()) return;
QString curFile;
QDir *thisDir = CurrentDir();
QListView *thisView = CurrentView();
if( thisView->currentItem())
curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
qApp->processEvents();
startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
}
}
void AdvancedFm::fileStatus() {
if( !CurrentView()->currentItem()) return;
QString curFile;
curFile = CurrentView()->currentItem()->text(0);
QStringList command;
command << "/bin/sh";
command << "-c";
command << "stat -l "+ curFile;
Output *outDlg;
outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
QPEApplication::execDialog( outDlg );
qApp->processEvents();
}
void AdvancedFm::mkDir() {
makeDir();
}
void AdvancedFm::rn() {
renameIt();
}
void AdvancedFm::del() {
doDelete();
}
void AdvancedFm::mkSym() {
QString cmd;
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
QDir *thisDir = CurrentDir();
QDir * thatDir = OtherDir();
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString destName = thatDir->canonicalPath()+"/"+(*it);
if(destName.right(1) == "/") {
destName = destName.left( destName.length() -1);
}
QString curFile = thisDir->canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") {
curFile = curFile.left( curFile.length() -1);
}
cmd = "ln -s "+curFile+" "+destName;
// qDebug(cmd);
startProcess( (const QString)cmd );
}
rePopulate();
setOtherTabCurrent();
}
}
void AdvancedFm::doBeam() {
Ir ir;
if(!ir.supported()) {
} else {
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString curFile = (*it);
QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
if( curFilePath.right(1) == "/") {
curFilePath = curFilePath.left( curFilePath.length() -1);
}
Ir *file = new Ir(this, "IR");
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
file->send( curFilePath, curFile );
}
}
}
}
void AdvancedFm::fileBeamFinished( Ir *) {
QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
}
void AdvancedFm::selectAll() {
QListView *thisView = CurrentView();
thisView->selectAll(true);
thisView->setSelected( thisView->firstChild(),false);
}
void AdvancedFm::startProcess(const QString & cmd) {
QStringList command;
OProcess *process;
process = new OProcess();
- connect(process, SIGNAL(processExited(OProcess*)),
+ connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
this, SLOT( processEnded(OProcess*)));
- connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)),
+ connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
this, SLOT( oprocessStderr(OProcess*,char*,int)));
command << "/bin/sh";
command << "-c";
command << cmd.latin1();
*process << command;
if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
qDebug("could not start process");
}
void AdvancedFm::processEnded(OProcess *) {
rePopulate();
}
void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
// qWarning("received stderrt %d bytes", buflen);
QString lineStr = buffer;
QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
}
bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
if ( o->inherits( "QLineEdit" ) ) {
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent*)e;
if ( ke->key() == Key_Return ||
ke->key() == Key_Enter ) {
okRename();
return true;
}
else if ( ke->key() == Key_Escape ) {
cancelRename();
return true;
}
}
else if ( e->type() == QEvent::FocusOut ) {
cancelRename();
return true;
}
}
if ( o->inherits( "QListView" ) ) {
if ( e->type() == QEvent::FocusIn ) {
if( o == Local_View) { //keep track of which view
whichTab=1;
}
else {
whichTab=2;
}
}
OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
}
return QWidget::eventFilter( o, e );
}
void AdvancedFm::cancelRename() {
// qDebug("cancel rename");
QListView * view;
view = CurrentView();
bool resetFocus = view->viewport()->focusProxy() == renameBox;
delete renameBox;
renameBox = 0;
if ( resetFocus ) {
view->viewport()->setFocusProxy( view);
view->setFocus();
}
}
void AdvancedFm::doRename(QListView * view) {
if( !CurrentView()->currentItem()) return;
QRect r = view->itemRect( view->currentItem( ));
r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
r.setX( view->contentsX() );
if ( r.width() > view->visibleWidth() )
r.setWidth( view->visibleWidth() );
renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
renameBox->setFrame(true);
renameBox->setText( view->currentItem()->text(0) );
renameBox->selectAll();
renameBox->installEventFilter( this );
view->addChild( renameBox, r.x(), r.y() );
renameBox->resize( r.size() );
view->viewport()->setFocusProxy( renameBox );
renameBox->setFocus();
renameBox->show();
}
void AdvancedFm::renameIt() {
if( !CurrentView()->currentItem()) return;
QListView *thisView = CurrentView();
oldName = thisView->currentItem()->text(0);
doRename( thisView );
}
void AdvancedFm::okRename() {
if( !CurrentView()->currentItem()) return;
QString newName = renameBox->text();
cancelRename();
QListView * view = CurrentView();
QString path = CurrentDir()->canonicalPath() + "/";
oldName = path + oldName;
newName = path + newName;
if( rename( oldName.latin1(), newName.latin1())== -1)
QMessageBox::message(tr("Note"),tr("Could not rename"));
else
oldName = "";
view->takeItem( view->currentItem() );
delete view->currentItem();
rePopulate();
}
void AdvancedFm::openSearch() {
QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
}
diff --git a/noncore/apps/advancedfm/main.cpp b/noncore/apps/advancedfm/main.cpp index 3c1a164..df0d4af 100644 --- a/noncore/apps/advancedfm/main.cpp +++ b/noncore/apps/advancedfm/main.cpp @@ -1,33 +1,22 @@ /*************************************************************************** +using namespace Opie::Core; +using namespace Opie::Core; main.cpp - description ------------------- begin : March 10, 2002 copyright : (C) 2002 by llornkcor email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "advancedfm.h" - -#ifdef NOQUICKLAUNCH - -#include <qpe/qpeapplication.h> - -int main(int argc, char *argv[]) -{ - QPEApplication a(argc, argv); - - AdvancedFm advencedFm; - a.showMainWidget( &advencedFm); - return a.exec(); -} -#else #include <opie2/oapplicationfactory.h> +using namespace Opie::Core; + OPIE_EXPORT_APP( OApplicationFactory<AdvancedFm> ) -#endif diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 0bba1d8..16a0992 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp @@ -1,276 +1,278 @@ /**************************************************************************** ** outputEdit.cpp ** ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> ****************************************************************************/ #include "output.h" #include <qpe/qpeapplication.h> #include <qpe/applnk.h> #include <qfile.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <qlayout.h> #include <errno.h> /* XPM */ +using namespace Opie::Core; +using namespace Opie::Core; static char * filesave_xpm[] = { "16 16 78 1", " c None", ". c #343434", "+ c #A0A0A0", "@ c #565656", "# c #9E9E9E", "$ c #525252", "% c #929292", "& c #676767", "* c #848484", "= c #666666", "- c #D8D8D8", "; c #FFFFFF", "> c #DBDBDB", ", c #636363", "' c #989898", ") c #2D2D2D", "! c #909090", "~ c #AEAEAE", "{ c #EAEAEA", "] c #575757", "^ c #585858", "/ c #8A8A8A", "( c #828282", "_ c #6F6F6F", ": c #C9C9C9", "< c #050505", "[ c #292929", "} c #777777", "| c #616161", "1 c #3A3A3A", "2 c #BEBEBE", "3 c #2C2C2C", "4 c #7C7C7C", "5 c #F6F6F6", "6 c #FCFCFC", "7 c #6B6B6B", "8 c #959595", "9 c #4F4F4F", "0 c #808080", "a c #767676", "b c #818181", "c c #B8B8B8", "d c #FBFBFB", "e c #F9F9F9", "f c #CCCCCC", "g c #030303", "h c #737373", "i c #7A7A7A", "j c #7E7E7E", "k c #6A6A6A", "l c #FAFAFA", "m c #505050", "n c #9D9D9D", "o c #333333", "p c #7B7B7B", "q c #787878", "r c #696969", "s c #494949", "t c #555555", "u c #949494", "v c #E6E6E6", "w c #424242", "x c #515151", "y c #535353", "z c #3E3E3E", "A c #D4D4D4", "B c #0C0C0C", "C c #353535", "D c #474747", "E c #ECECEC", "F c #919191", "G c #7D7D7D", "H c #000000", "I c #404040", "J c #858585", "K c #323232", "L c #D0D0D0", "M c #1C1C1C", " ...+ ", " @#$%&..+ ", " .*=-;;>,..+ ", " ')!~;;;;;;{]..", " ^/(-;;;;;;;_:<", " [}|;;;;;;;{12$", " #34-55;;;;678$+", " 90ab=c;dd;e1fg ", " [ahij((kbl0mn$ ", " op^q^^7r&]s/$+ ", "@btu;vbwxy]zAB ", "CzDEvEv;;DssF$ ", "G.H{E{E{IxsJ$+ ", " +...vEKxzLM ", " +...z]n$ ", " +... "}; Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog( parent, name, modal, fl ) { QStringList cmmds; // cmmds=QStringList::split( " ", commands, false); cmmds=commands; // qDebug("count %d", cmmds.count()); if ( !name ) setName( tr("Output")); resize( 196, 269 ); setCaption( name ); OutputLayout = new QGridLayout( this ); OutputLayout->setSpacing( 2); OutputLayout->setMargin( 2); QPushButton *docButton; docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); docButton->setFixedSize( QSize( 20, 20 ) ); connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); // docButton->setFlat(TRUE); OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); proc = new OProcess(); - connect(proc, SIGNAL(processExited(OProcess*)), + connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processFinished())); - connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), + connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), this, SLOT(commandStdout(OProcess*,char*,int))); - connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), + connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT(commandStderr(OProcess*,char*,int))); // connect( , SIGNAL(received(const QByteArray&)), // this, SLOT(commandStdin(const QByteArray&))); // * proc << commands.latin1(); for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { qDebug( "%s", (*it).latin1() ); * proc << (*it).latin1(); } if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { OutputEdit->append(tr("Process could not start") ); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); perror("Error: "); QString errorMsg=tr("Error\n")+(QString)strerror(errno); OutputEdit->append( errorMsg); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } } Output::~Output() { } void Output::saveOutput() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = QPEApplication::documentDir(); if(filename.right(1).find('/') == -1) filename+="/"; QString name = fileDlg->LineEdit1->text(); filename+="text/plain/"+name; qDebug(filename); QFile f(filename); f.open( IO_WriteOnly); if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { DocLnk lnk; lnk.setName(name); //sets file name lnk.setFile(filename); //sets File property lnk.setType("text/plain"); if(!lnk.writeLink()) { qDebug("Writing doclink did not work"); } } else qWarning("Could not write file"); f.close(); } } void Output::commandStdout(OProcess*, char *buffer, int buflen) { qWarning("received stdout %d bytes", buflen); // QByteArray data(buflen); // data.fill(*buffer, buflen); // for (uint i = 0; i < data.count(); i++ ) { // printf("%c", buffer[i] ); // } // printf("\n"); QString lineStr = buffer; lineStr=lineStr.left(lineStr.length()-1); OutputEdit->append(lineStr); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } void Output::commandStdin( const QByteArray &data) { qWarning("received stdin %d bytes", data.size()); // recieved data from the io layer goes to sz proc->writeStdin(data.data(), data.size()); } void Output::commandStderr(OProcess*, char *buffer, int buflen) { qWarning("received stderrt %d bytes", buflen); QString lineStr = buffer; // lineStr=lineStr.left(lineStr.length()-1); OutputEdit->append(lineStr); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } void Output::processFinished() { delete proc; OutputEdit->append( tr("\nFinished\n") ); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); // close(); // disconnect( layer(), SIGNAL(received(const QByteArray&)), // this, SLOT(commandStdin(const QByteArray&))); } //============================== InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "InputDialog" ); resize( 234, 50 ); setMaximumSize( QSize( 240, 50 ) ); setCaption( tr(name ) ); LineEdit1 = new QLineEdit( this, "LineEdit1" ); LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); LineEdit1->setFocus(); LineEdit1->setFocus(); connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); } InputDialog::~InputDialog() { inputText = LineEdit1->text(); } void InputDialog::setInputText(const QString &string) { LineEdit1->setText( string); } void InputDialog::returned() { inputText = LineEdit1->text(); this->accept(); } diff --git a/noncore/apps/advancedfm/output.h b/noncore/apps/advancedfm/output.h index 26c0fa0..37ba57d 100644 --- a/noncore/apps/advancedfm/output.h +++ b/noncore/apps/advancedfm/output.h @@ -1,65 +1,65 @@ /**************************************************************************** ** Form interface generated from reading ui file 'outputEdit.ui' ** ** Created: Fri Apr 12 15:12:44 2002 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #ifndef OUTPUT_H #define OUTPUT_H #include <qvariant.h> #include <qdialog.h> #include <qcstring.h> #include <qstringlist.h> #include <qlineedit.h> #include <qwhatsthis.h> #include <opie2/oprocess.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QMultiLineEdit; class Output : public QDialog { Q_OBJECT public: Output(const QStringList commands=0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~Output(); QMultiLineEdit* OutputEdit; protected: QGridLayout* OutputLayout; - OProcess *proc; + Opie::Core::OProcess *proc; protected slots: void saveOutput(); - void commandStdout(OProcess*, char *, int); + void commandStdout(Opie::Core::OProcess*, char *, int); void commandStdin(const QByteArray &); - void commandStderr(OProcess*, char *, int); + void commandStderr(Opie::Core::OProcess*, char *, int); void processFinished(); private: QString cmmd; }; class InputDialog : public QDialog { Q_OBJECT public: InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~InputDialog(); QString inputText; QLineEdit* LineEdit1; void setInputText(const QString &); private slots: void returned(); }; #endif // OUTPUT_H diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 1b933f2..706d970 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp @@ -1,252 +1,253 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "checkbook.h" #include "cbinfo.h" #include "transaction.h" #include "traninfo.h" #include "graph.h" #include "graphinfo.h" #include "password.h" #include "cfg.h" #include <qpe/qpeapplication.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <qwhatsthis.h> #include <qpopupmenu.h> #define COL_ID 0 #define COL_SORTDATE 1 #define COL_NUM 2 #define COL_DATE 3 #define COL_DESC 4 #define COL_AMOUNT 5 #define COL_BAL 6 // --- Checkbook -------------------------------------------------------------- +using namespace Opie::Ui; Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) { info = i; _pCfg=cfg; // Title bar if ( info->name() != "" ) { QString tempstr = info->name(); tempstr.append( " - " ); tempstr.append( tr( "Checkbook" ) ); setCaption( tempstr ); } else { setCaption( tr( "New checkbook" ) ); } // Setup layout to make everything pretty QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Setup tabs for all info mainWidget = new OTabWidget( this ); layout->addWidget( mainWidget ); mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); if( _pCfg->isShowLastTab() ) mainWidget->setCurrentTab( info->getLastTab() ); else mainWidget->setCurrentTab( tr( "Info" ) ); connect( mainWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotTab(QWidget*) ) ); // Load checkbook information loadCheckbook(); } Checkbook::~Checkbook() { } // --- initInfo --------------------------------------------------------------- QWidget *Checkbook::initInfo() { QWidget *control = new QWidget( mainWidget, tr("Info") ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container ); layout->setSpacing( 2 ); layout->setMargin( 4 ); // Password protection passwordCB = new QCheckBox( tr( "Password protect" ), container ); QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); // Account name QLabel *label = new QLabel( tr( "Name:" ), container ); QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); layout->addWidget( label, 1, 0 ); nameEdit = new QLineEdit( container ); QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); connect( nameEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotNameChanged(const QString&) ) ); layout->addWidget( nameEdit, 1, 1 ); // Type of account label = new QLabel( tr( "Type:" ), container ); QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); layout->addWidget( label, 2, 0 ); typeList = new QComboBox( container ); QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); typeList->insertStringList( _pCfg->getAccountTypes() ); layout->addWidget( typeList, 2, 1 ); // Bank/institution name label = new QLabel( tr( "Bank:" ), container ); QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); layout->addWidget( label, 3, 0 ); bankEdit = new QLineEdit( container ); QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); layout->addWidget( bankEdit, 3, 1 ); // Account number label = new QLabel( tr( "Account number:" ), container ); QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); layout->addWidget( label, 4, 0 ); acctNumEdit = new QLineEdit( container ); QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); layout->addWidget( acctNumEdit, 4, 1 ); // PIN number label = new QLabel( tr( "PIN number:" ), container ); QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); layout->addWidget( label, 5, 0 ); pinNumEdit = new QLineEdit( container ); QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); layout->addWidget( pinNumEdit, 5, 1 ); // Starting balance label = new QLabel( tr( "Starting balance:" ), container ); QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); layout->addWidget( label, 6, 0 ); balanceEdit = new QLineEdit( container ); QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); connect( balanceEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotStartingBalanceChanged(const QString&) ) ); layout->addWidget( balanceEdit, 6, 1 ); // Notes label = new QLabel( tr( "Notes:" ), container ); QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); layout->addWidget( label, 7, 0 ); notesEdit = new QMultiLineEdit( container ); QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); notesEdit->setMinimumHeight( 25 ); notesEdit->setMaximumHeight( 65 ); layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); return control; } // --- initTransactions ------------------------------------------------------- QWidget *Checkbook::initTransactions() { QWidget *control = new QWidget( mainWidget, tr("Transactions") ); QGridLayout *layout = new QGridLayout( control ); layout->setSpacing( 2 ); layout->setMargin( 4 ); // Sort selector QLabel *label = new QLabel( tr( "Sort by:" ), control ); QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); layout->addMultiCellWidget( label, 0, 0, 0, 1 ); _cbSortType=new QComboBox( control ); _cbSortType->insertItem( tr("Entry Order") ); _cbSortType->insertItem( tr("Date") ); _cbSortType->insertItem( tr("Number") ); layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); connect( _cbSortType, SIGNAL( activated(const QString&) ), this, SLOT( slotSortChanged(const QString&) ) ); // Table tranTable = new QListView( control ); QFont fnt(QPEApplication::font()); fnt.setPointSize( fnt.pointSize()-1 ); tranTable->setFont( fnt ); QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); tranTable->addColumn( tr( "Id" ) ); tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); tranTable->setColumnWidth( COL_ID, 0); tranTable->addColumn( tr( "SortDate" ) ); tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); tranTable->setColumnWidth( COL_SORTDATE, 0); tranTable->addColumn( tr( "Num" ) ); tranTable->addColumn( tr( "Date" ) ); //tranTable->addColumn( tr( "Cleared" ) ); tranTable->addColumn( tr( "Description" ) ); int column = tranTable->addColumn( tr( "Amount" ) ); tranTable->setColumnAlignment( column, Qt::AlignRight ); column=tranTable->addColumn( tr("Balance") ); tranTable->setColumnAlignment( column, Qt::AlignRight ); tranTable->setAllColumnsShowFocus( TRUE ); tranTable->setSorting( -1 ); layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); connect( tranTable, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( slotMenuTran(QListViewItem*,const QPoint&) ) ); connect( tranTable, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( slotEditTran() ) ); _sortCol=COL_ID; // Buttons QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); layout->addWidget( btn, 2, 0 ); diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index e2f0e56..80bc106 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h @@ -1,150 +1,149 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef CHECKBOOK_H #define CHECKBOOK_H #include <opie2/otabwidget.h> #include <qdatetime.h> #include <qdialog.h> #include <qlistview.h> -using Opie::OTabWidget; class CBInfo; class Graph; class GraphInfo; class QCheckBox; class QComboBox; class QLabel; class QLineEdit; class QListView; class QMultiLineEdit; class QString; class TranInfo; class TranInfoList; class Cfg; class QMouseEvent; // --- Checkbook -------------------------------------------------------------- class Checkbook : public QDialog { Q_OBJECT public: Checkbook( QWidget *, CBInfo *, Cfg *cfg ); ~Checkbook(); // resort void resort(); // members TranInfoList *getTranList() { return(tranList); } private: CBInfo *info; TranInfoList *tranList; Cfg *_pCfg; - OTabWidget *mainWidget; + Opie::Ui::OTabWidget *mainWidget; void loadCheckbook(); void adjustBalance(); // Info tab QWidget *initInfo(); QCheckBox *passwordCB; QLineEdit *nameEdit; QComboBox *typeList; QLineEdit *bankEdit; QLineEdit *acctNumEdit; QLineEdit *pinNumEdit; QLineEdit *balanceEdit; QMultiLineEdit *notesEdit; int _sortCol; // Transactions tab QWidget *initTransactions(); QListView *tranTable; QComboBox *_cbSortType; QDate _dLastNew; // Charts tab QWidget *initCharts(); GraphInfo *graphInfo; QComboBox *graphList; Graph *graphWidget; void drawBalanceChart(); void drawCategoryChart( bool = TRUE ); protected slots: void accept(); void slotTab(QWidget *tab); private slots: void slotPasswordClicked(); void slotNameChanged( const QString & ); void slotStartingBalanceChanged( const QString & ); void slotNewTran(); void slotEditTran(); void slotMenuTran(QListViewItem *, const QPoint &); void slotDeleteTran(); void slotDrawGraph(); void slotSortChanged( const QString & ); }; // --- CBListItem ------------------------------------------------------------- class CBListItem : public QListViewItem { //Q_OBJECT public: CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); void paintCell( QPainter *, const QColorGroup &, int, int, int ); // --- members TranInfo *getTranInfo() { return(_pTran); } private: TranInfo *_pTran; QListView *owner; bool m_known; bool m_odd; bool isAltBackground(); }; #endif diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index 0384620..1135bee 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp @@ -1,33 +1,35 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/oapplicationfactory.h> +using namespace Opie::Core; +using namespace Opie::Core; #include "mainwindow.h" OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 254ce6a..ce15e3e 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp @@ -1,230 +1,230 @@ /* This file is part of the OPIE Project =. .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "mainwindow.h" #include "cbinfo.h" #include "configuration.h" #include "password.h" #include "checkbook.h" #include <qpe/config.h> #include <qpe/qpeapplication.h> #include <qpe/qpemessagebox.h> -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> #include <qpe/resource.h> #include <qmenubar.h> #include <qaction.h> #include <qdir.h> #include <qwhatsthis.h> MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ ) : QMainWindow( parent, name, WStyle_ContextHelp ) { setCaption( tr( "Checkbook" ) ); cbDir = Global::applicationFileName( "checkbook", "" ); lockIcon = Resource::loadPixmap( "locked" ); // Load configuration options Config config( "checkbook" ); _cfg.readConfig( config ); // Build menu and tool bars setToolBarsMovable( FALSE ); QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( TRUE ); QMenuBar *mb = new QMenuBar( bar ); mb->setMargin( 0 ); QPopupMenu *popup = new QPopupMenu( this ); bar = new QToolBar( this ); QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); a->addTo( popup ); a->addTo( bar ); actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); actionOpen->addTo( popup ); actionOpen->addTo( bar ); actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); actionDelete->addTo( popup ); actionDelete->addTo( bar ); popup->insertSeparator(); a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to configure this app." ) ); connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); a->addTo( popup ); a->addTo( bar ); mb->insertItem( tr( "Checkbook" ), popup ); // Load Checkbook selection list checkbooks = new CBInfoList(); QDir checkdir( cbDir ); if (checkdir.exists() == true) { QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time ); CBInfo *cb = 0x0; QString filename; for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) { filename = cbDir; filename.append( (*it) ); cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); checkbooks->inSort( cb ); } } // Build Checkbook selection list control cbList = 0x0; buildList(); // open last book? if( _cfg.isOpenLastBook() ) { this->show(); this->showMaximized(); QListViewItem *itm=cbList->firstChild(); while( itm ) { if( itm->text(posName)==_cfg.getLastBook() ) { openBook( itm ); break; } itm=itm->nextSibling(); } } } // --- ~MainWindow ------------------------------------------------------------ MainWindow::~MainWindow() { writeConfig(); } // --- buildList -------------------------------------------------------------- void MainWindow::buildList() { if ( cbList ) delete cbList; cbList = new QListView( this ); QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); if ( _cfg.getShowLocks() ) { cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); posName = 1; } else { posName = 0; } cbList->addColumn( tr( "Checkbook Name" ) ); if ( _cfg.getShowBalances() ) { int colnum = cbList->addColumn( tr( "Balance" ) ); cbList->setColumnAlignment( colnum, Qt::AlignRight ); } cbList->setAllColumnsShowFocus( TRUE ); cbList->setSorting( posName ); QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( slotEdit() ) ); setCentralWidget( cbList ); for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) { addCheckbook( cb ); } } void MainWindow::addCheckbook( CBInfo *cb ) { QListViewItem *lvi = new QListViewItem( cbList ); if ( _cfg.getShowLocks() && !cb->password().isNull() ) { lvi->setPixmap( 0, lockIcon ); } lvi->setText( posName, cb->name() ); if ( _cfg.getShowBalances() ) { QString balance; balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); lvi->setText( posName + 1, balance ); } } void MainWindow::buildFilename( const QString &name ) { tempFilename = cbDir; tempFilename.append( name ); tempFilename.append( ".qcb" ); } void MainWindow::slotNew() { CBInfo *cb = new CBInfo(); Checkbook *currcb = new Checkbook( this, cb, &_cfg ); if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) { // Save new checkbook buildFilename( cb->name() ); _cfg.setLastBook( cb->name() ); cb->setFilename( tempFilename ); cb->write(); // Add to listbox checkbooks->inSort( cb ); addCheckbook( cb ); } delete currcb; } // --- slotEdit --------------------------------------------------------------- void MainWindow::slotEdit() { diff --git a/noncore/apps/confedit/main.cpp b/noncore/apps/confedit/main.cpp index 584e6b2..3a010dd 100644 --- a/noncore/apps/confedit/main.cpp +++ b/noncore/apps/confedit/main.cpp @@ -1,5 +1,6 @@ - #include "mainwindow.h" #include <opie2/oapplicationfactory.h> +using namespace Opie::Core; + OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/apps/odict/main.cpp b/noncore/apps/odict/main.cpp index d5b08d3..7729d5f 100644 --- a/noncore/apps/odict/main.cpp +++ b/noncore/apps/odict/main.cpp @@ -1,24 +1,26 @@ /*************************************************************************** application: : ODict begin : December 2002 copyright : ( C ) 2002, 2003 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include <opie2/oapplicationfactory.h> #include "odict.h" +using namespace Opie::Core; +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<ODict> ) diff --git a/noncore/apps/odict/searchmethoddlg.cpp b/noncore/apps/odict/searchmethoddlg.cpp index f71cfd8..34e8b16 100644 --- a/noncore/apps/odict/searchmethoddlg.cpp +++ b/noncore/apps/odict/searchmethoddlg.cpp @@ -1,109 +1,108 @@ /*************************************************************************** application: : ODict begin : December 2002 copyright : ( C ) 2002, 2003 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include "searchmethoddlg.h" #include <opie2/ofileselector.h> #include <opie2/ofiledialog.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> #include <qlayout.h> #include <qvbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qdir.h> -using Opie::OFileDialog; -using Opie::OFileSelector; +using namespace Opie::Ui; SearchMethodDlg::SearchMethodDlg(QWidget *parent, const char *name, bool modal, QString itemname) : QDialog(parent, name, modal) { QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" ); QVBox *vbox = new QVBox( this ); QHBox *hbox1 = new QHBox( vbox ); QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 ); nameLE = new QLineEdit( hbox1 ); QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox ); QHBox *hbox2 = new QHBox( vbox ); dictFileLE = new QLineEdit( hbox2 ); QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 ); connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) ); QWidget *dummywidget = new QWidget( vbox ); QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget); QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget); QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget); lang1 = new QLineEdit( dummywidget ); lang2 = new QLineEdit( dummywidget ); trenner = new QLineEdit( dummywidget ); trenner->setText( "::" ); QGridLayout *grid = new QGridLayout( dummywidget, 2,3 ); grid->addWidget( lag1, 0,0 ); grid->addWidget( devider, 0,1 ); grid->addWidget( lag2, 0,2 ); grid->addWidget( lang1, 1,0 ); grid->addWidget( trenner, 1,1 ); grid->addWidget( lang2, 1,2 ); vbox_layout->addWidget( vbox ); QPEApplication::execDialog ( this ); if( !itemname ) setCaption( tr( "New Searchmethod" ) ); else { setCaption( tr( "Change Searchmethod" ) ); itemName = itemname; setupEntries(itemname); } } void SearchMethodDlg::setupEntries( QString item ) { Config cfg( "odict" ); cfg.setGroup( "Method_"+itemName ); trenner->setText( cfg.readEntry( "Seperator" ) ); lang1->setText( cfg.readEntry( "Lang1" ) ); lang2->setText( cfg.readEntry( "Lang2" ) ); nameLE->setText( itemName ); dictFileLE->setText( cfg.readEntry( "file" ) ); } void SearchMethodDlg::slotBrowse() { itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath()); dictFileLE->setText( itemName ); } void SearchMethodDlg::saveItem() { QString name = nameLE->text(); Config cfg( "odict" ); cfg.setGroup( "Method_"+name ); cfg.writeEntry( "Name", name ); cfg.writeEntry( "Seperator", trenner->text() ); cfg.writeEntry( "Lang1", lang1->text() ); cfg.writeEntry( "Lang2", lang2->text() ); cfg.writeEntry( "file", dictFileLE->text() ); } diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp index b6401ed..e6cb515 100644 --- a/noncore/apps/opie-bartender/bartender.cpp +++ b/noncore/apps/opie-bartender/bartender.cpp @@ -1,211 +1,211 @@ /**************************************************************************** ** ** Created: Sat Jul 20 08:10:53 2002 ** by: L.J. Potter <ljp@llornkcor.com> ** copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "bartender.h" #include "showdrinks.h" #include "inputDialog.h" #include "searchresults.h" #include "bac.h" -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> #include <qmenubar.h> //#include <opie2/colorpopupmenu.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qlineedit.h> #include <qdir.h> #include <qpushbutton.h> #include <qlistbox.h> #include <qmultilineedit.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qaction.h> #include <qheader.h> #include <qlistview.h> #include <qlayout.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { if ( !name ) setName( "Bartender" ); QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 2); layout->setMargin( 2); connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); setCaption( tr( "Bartender" ) ); ToolBar1 = new QToolBar( this, "ToolBar1" ); ToolBar1->setFixedHeight(22); layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); QMenuBar *menuBar = new QMenuBar( ToolBar1 ); QPopupMenu *fileMenu; fileMenu = new QPopupMenu( this); menuBar->insertItem( tr("File"), fileMenu ); fileMenu->insertItem(tr("New Drink")); fileMenu->insertItem(tr("Open Drink")); fileMenu->insertItem(tr("Find by Drink Name")); fileMenu->insertItem(tr("Find by Alcohol")); QPopupMenu *editMenu; editMenu = new QPopupMenu( this); menuBar->insertItem( tr("Edit"), editMenu ); editMenu->insertItem(tr("edit")); connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); a->addTo( ToolBar1 ); a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); a->addTo( ToolBar1 ); a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); a->addTo( ToolBar1 ); a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); a->addTo( ToolBar1 ); QPushButton *t; t= new QPushButton( "BAC", ToolBar1, "bacButtin"); connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); DrinkView = new QListView( this, "DrinkView" ); DrinkView->addColumn( tr( "Name of Drink" ) ); // DrinkView->setRootIsDecorated( TRUE ); DrinkView->header()->hide(); QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); if(QDir("db").exists()) { dbFile.setName( "db/drinkdb.txt"); } else dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); initDrinkDb(); } Bartender::~Bartender() { } /* this happens right before exit */ void Bartender::cleanUp() { dbFile.close(); } void Bartender::initDrinkDb() { if(!dbFile.isOpen()) if ( !dbFile.open( IO_ReadOnly)) { QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); return; } fillList(); } void Bartender::fillList() { dbFile.at(1); DrinkView->clear(); int i=0; QListViewItem * item ; QTextStream t( &dbFile); QString s; while ( !t.eof()) { s = t.readLine(); if(s.find("#",0,TRUE) != -1) { // qDebug(s.right(s.length()-2)); item= new QListViewItem( DrinkView, 0 ); item->setText( 0, s.right(s.length()-2)); i++; } } qDebug("there are currently %d of drinks", i); } void Bartender::fileNew() { New_Drink *newDrinks; newDrinks = new New_Drink(this,"New Drink....", TRUE); QString newName, newIng; QPEApplication::execDialog( newDrinks ); newName = newDrinks->LineEdit1->text(); newIng= newDrinks->MultiLineEdit1->text(); if(dbFile.isOpen()) dbFile.close(); if ( !dbFile.open( IO_WriteOnly| IO_Append)) { QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); return; } if(newDrinks ->result() == 1 ) { QString newDrink="\n# "+newName+"\n"; newDrink.append(newIng+"\n"); qDebug("writing "+newDrink); dbFile.writeBlock( newDrink.latin1(), newDrink.length()); clearList(); dbFile.close(); initDrinkDb(); } delete newDrinks; } void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { switch (mouse) { case 1: // showDrink(item); break; case 2: showDrink(item); break; } } void Bartender::showDrink( QListViewItem *item) { if(item==NULL) return; dbFile.at(0); Show_Drink *showDrinks; QString myDrink=item->text(0); showDrinks = new Show_Drink(this, myDrink, TRUE); QTextStream t( &dbFile); QString s, s2; while ( !t.eof()) { s = t.readLine(); if(s.find( myDrink, 0, TRUE) != -1) { for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { s2 = t.readLine(); if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { // qDebug(s2); showDrinks->MultiLineEdit1->append(s2); diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index 1a8c979..35a328f 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp @@ -1,92 +1,94 @@ #include "io_bt.h" +using namespace Opie::Core; +using namespace Opie::Core; IOBt::IOBt( const Profile &config ) : IOSerial( config ) { m_attach = 0; } IOBt::~IOBt() { if ( m_attach ) { delete m_attach; } } void IOBt::close() { IOSerial::close(); // still need error handling if ( m_attach ) { delete m_attach; m_attach = 0; } } bool IOBt::open() { bool ret = false; // only set up bt stuff if mac address was set, otherwise use the device set if ( !m_mac.isEmpty() ) { // now it should also be checked, if there is a connection to the device with that mac allready // hciattach here m_attach = new OProcess(); *m_attach << "hciattach /dev/ttyS2 any 57600"; // then start hcid, then rcfomm handling (m_mac) - connect( m_attach, SIGNAL( processExited(OProcess*) ), + connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), this, SLOT( slotExited(OProcess*) ) ); if ( m_attach->start() ) { ret = IOSerial::open(); } else { qWarning("could not attach to device"); delete m_attach; m_attach = 0; } } else { // directly to the normal serial // TODO: look first if the connection really exists. ( is set up ) ret =IOSerial::open(); } return ret; } void IOBt::reload( const Profile &config ) { m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); } QString IOBt::identifier() const { return "bluetooth"; } QString IOBt::name() const { return "BLuetooth IO Layer"; } void IOBt::slotExited( OProcess* proc ){ close(); delete proc; } QBitArray IOBt::supports() const { return QBitArray( 3 ); } bool IOBt::isConnected() { return false; } void IOBt::send(const QByteArray &data) { qDebug( "Please overload me..." ); } diff --git a/noncore/apps/opie-console/io_bt.h b/noncore/apps/opie-console/io_bt.h index df6dd38..00ca7e5 100644 --- a/noncore/apps/opie-console/io_bt.h +++ b/noncore/apps/opie-console/io_bt.h @@ -1,51 +1,51 @@ #ifndef OPIE_IO_BT #define OPIE_IO_BT #include <opie2/oprocess.h> #include "io_serial.h" /* Default values to be used if the profile information is incomplete */ #define BT_DEFAULT_DEVICE "/dev/ttyU0" #define BT_DEFAULT_BAUD 9600 #define BT_DEFAULT_PARITY 0 #define BT_DEFAULT_DBITS 8 #define BT_DEFAULT_SBITS 1 #define BT_DEFAULT_FLOW 0 #define BT_DEFAULT_MAC 0 /* IOSerial implements a RS232 IO Layer */ class IOBt : public IOSerial { Q_OBJECT public: IOBt(const Profile &); ~IOBt(); virtual QString identifier() const; virtual QString name() const; virtual QBitArray supports() const; virtual bool isConnected(); signals: void received(const QByteArray &); void error(int, const QString &); public slots: virtual void send( const QByteArray& ); virtual bool open(); virtual void close(); virtual void reload(const Profile &); private: - OProcess *m_attach; + Opie::Core::OProcess *m_attach; QString m_mac; private slots: - void slotExited(OProcess* proc); + void slotExited(Opie::Core::OProcess* proc); }; #endif /* OPIE_IO_IRDA */ diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp index b281b7d..ba0b0e5 100644 --- a/noncore/apps/opie-console/io_irda.cpp +++ b/noncore/apps/opie-console/io_irda.cpp @@ -1,77 +1,79 @@ #include "io_irda.h" +using namespace Opie::Core; +using namespace Opie::Core; IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { m_attach = 0; } IOIrda::~IOIrda() { if ( m_attach ) { delete m_attach; } } void IOIrda::close() { IOSerial::close(); // still need error handling delete m_attach; } bool IOIrda::open() { bool ret; // irdaattach here m_attach = new OProcess(); *m_attach << "irattach /dev/ttyS2 -s"; - connect( m_attach, SIGNAL( processExited(OProcess*) ), + connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), this, SLOT( slotExited(OProcess*) ) ); if ( m_attach->start() ) { ret= IOSerial::open(); } else { // emit error!!! qWarning("could not attach to device"); delete m_attach; m_attach = 0l; } return ret; } void IOIrda::reload( const Profile &config ) { m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); } QString IOIrda::identifier() const { return "irda"; } QString IOIrda::name() const { return "Irda IO Layer"; } void IOIrda::slotExited(OProcess* proc ){ close(); delete proc; } QBitArray IOIrda::supports()const { return QBitArray( 3 ); } bool IOIrda::isConnected() { return false; } void IOIrda::send(const QByteArray &data) { qDebug( "Please overload me..." ); } diff --git a/noncore/apps/opie-console/io_irda.h b/noncore/apps/opie-console/io_irda.h index 69bed7d..fb29686 100644 --- a/noncore/apps/opie-console/io_irda.h +++ b/noncore/apps/opie-console/io_irda.h @@ -1,49 +1,49 @@ #ifndef OPIE_IO_IRDA #define OPIE_IO_IRDA #include <opie2/oprocess.h> #include "io_serial.h" /* Default values to be used if the profile information is incomplete */ #define IRDA_DEFAULT_DEVICE "/dev/ircomm0" #define IRDA_DEFAULT_BAUD 9600 #define IRDA_DEFAULT_PARITY 0 #define IRDA_DEFAULT_DBITS 8 #define IRDA_DEFAULT_SBITS 1 #define IRDA_DEFAULT_FLOW 0 /* IOSerial implements a RS232 IO Layer */ class IOIrda : public IOSerial { Q_OBJECT public: IOIrda(const Profile &); ~IOIrda(); virtual QString identifier() const; virtual QString name() const; virtual QBitArray supports() const; virtual bool isConnected(); signals: void received(const QByteArray &); void error(int, const QString &); public slots: virtual void send( const QByteArray& ); virtual bool open(); virtual void close(); virtual void reload(const Profile &); private: - OProcess *m_attach; + Opie::Core::OProcess *m_attach; private slots: - void slotExited(OProcess* proc); + void slotExited(Opie::Core::OProcess* proc); }; #endif /* OPIE_IO_IRDA */ diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp index 1ce680a..b74d076 100644 --- a/noncore/apps/opie-console/io_modem.cpp +++ b/noncore/apps/opie-console/io_modem.cpp @@ -1,106 +1,108 @@ #include "io_modem.h" #include "dialer.h" +using namespace Opie::Core; +using namespace Opie::Core; IOModem::IOModem( const Profile &profile ) : IOSerial( profile ) { m_profile = profile; } IOModem::~IOModem() { } void IOModem::close() { // Hangup, discarding result // int fd = rawIO(); internDetach(); Dialer d(m_profile, m_fd); d.setHangupOnly(); //d.exec(); internAttach(); // closeRawIO(fd); IOSerial::close(); } bool IOModem::open() { bool ret = IOSerial::open(); if(!ret) return false; // int fd = rawIO(); internDetach(); Dialer d(m_profile, m_fd); int result = d.exec(); internAttach(); // closeRawIO(fd); if(result == QDialog::Accepted) { return true; } else { close(); return false; } } void IOModem::reload( const Profile &config ) { m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); } QString IOModem::identifier() const { return "modem"; } QString IOModem::name() const { return "Modem IO Layer"; } void IOModem::slotExited(OProcess* proc ){ close(); /* delete it afterwards */ delete proc; } QBitArray IOModem::supports()const { return QBitArray( 3 ); } bool IOModem::isConnected() { return false; } void IOModem::send(const QByteArray &data) { qDebug( "Please overload me..." ); } diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h index 96ec3ef..5b99e00 100644 --- a/noncore/apps/opie-console/io_modem.h +++ b/noncore/apps/opie-console/io_modem.h @@ -1,74 +1,74 @@ #ifndef OPIE_IO_MODEM #define OPIE_IO_MODEM #include <opie2/oprocess.h> #include "io_serial.h" #include "profile.h" /* Default values to be used if the profile information is incomplete */ #define MODEM_DEFAULT_DEVICE "/dev/ttyS0" #define MODEM_DEFAULT_BAUD 9600 #define MODEM_DEFAULT_PARITY 0 #define MODEM_DEFAULT_DBITS 8 #define MODEM_DEFAULT_SBITS 1 #define MODEM_DEFAULT_FLOW 0 #define MODEM_DEFAULT_INIT_STRING "AT" #define MODEM_DEFAULT_RESET_STRING "ATZ~" #define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" #define MODEM_DEFAULT_DIAL_SUFFIX1 "" #define MODEM_DEFAULT_DIAL_PREFIX2 "" #define MODEM_DEFAULT_DIAL_SUFFIX2 "" #define MODEM_DEFAULT_DIAL_PREFIX3 "" #define MODEM_DEFAULT_DIAL_SUFFIX3 "" #define MODEM_DEFAULT_CONNECT_STRING "CONNECT" #define MODEM_DEFAULT_HANGUP_STRING "+++ATH" #define MODEM_DEFAULT_CANCEL_STRING "" #define MODEM_DEFAULT_DIAL_TIME 45 #define MODEM_DEFAULT_DELAY_REDIAL 2 #define MODEM_DEFAULT_NUMBER_TRIES 10 #define MODEM_DEFAULT_DTR_DROP_TIME 1 #define MODEM_DEFAULT_BPS_DETECT 0 // bool #define MODEM_DEFAULT_DCD_LINES 1 //bool #define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool /* IOSerial implements a RS232 IO Layer */ class IOModem : public IOSerial { Q_OBJECT public: IOModem(const Profile &); ~IOModem(); virtual QString identifier() const; virtual QString name() const; virtual QBitArray supports() const; virtual bool isConnected(); signals: void received(const QByteArray &); void error(int, const QString &); public slots: virtual void send( const QByteArray& ); virtual bool open(); virtual void close(); virtual void reload(const Profile &); private: QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, m_bpsDetect, m_dcdLines, m_multiLineUntag; Profile m_profile; private slots: - void slotExited(OProcess* proc); + void slotExited(Opie::Core::OProcess* proc); }; #endif diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 197f799..06a8f7d 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,727 +1,728 @@ #include <assert.h> #include <qaction.h> #include <qmenubar.h> #include <qtoolbar.h> #include <qmessagebox.h> #include <qwhatsthis.h> #include <qfileinfo.h> #include <qpe/filemanager.h> #include <opie2/ofiledialog.h> #include "TEmulation.h" #include "profileeditordialog.h" #include "configdialog.h" #include "default.h" #include "profilemanager.h" #include "mainwindow.h" #include "tabwidget.h" #include "transferdialog.h" #include "function_keyboard.h" #include "emulation_handler.h" #include "script.h" +using namespace Opie::Ui; MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { KeyTrans::loadAll(); for (int i = 0; i < KeyTrans::count(); i++ ) { KeyTrans* s = KeyTrans::find(i ); assert( s ); } m_factory = new MetaFactory(); Default def(m_factory); m_sessions.setAutoDelete( TRUE ); m_curSession = 0; m_manager = new ProfileManager( m_factory ); m_manager->load(); m_scriptsData.setAutoDelete(TRUE); initUI(); populateProfiles(); populateScripts(); } void MainWindow::initUI() { setToolBarsMovable( FALSE ); /* tool bar for the menu */ m_tool = new QToolBar( this ); m_tool->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( m_tool ); m_console = new QPopupMenu( this ); m_scripts = new QPopupMenu( this ); m_sessionsPop= new QPopupMenu( this ); m_scriptsPop = new QPopupMenu( this ); /* add a toolbar for icons */ m_icons = new QToolBar(this); /* * the settings action */ m_setProfiles = new QAction(tr("Configure Profiles"), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0); m_setProfiles->addTo( m_console ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); m_console->insertSeparator(); /* * new Action for new sessions */ QAction* newCon = new QAction(tr("New Profile"), Resource::loadPixmap( "new" ), QString::null, 0, this, 0); newCon->addTo( m_console ); connect( newCon, SIGNAL(activated() ), this, SLOT(slotNew() ) ); m_console->insertSeparator(); QAction *saveCon = new QAction( tr("Save Profile" ), Resource::loadPixmap( "save" ), QString::null, 0, this, 0 ); saveCon->addTo( m_console ); connect( saveCon, SIGNAL(activated() ), this, SLOT(slotSaveSession() ) ); m_console->insertSeparator(); /* * connect action */ m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), QString::null, 0, this, 0 ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), QString::null, 0, this, 0 ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); m_console->insertSeparator(); m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); m_quickLaunch->addTo( m_icons ); connect( m_quickLaunch, SIGNAL( activated() ), this, SLOT( slotQuickLaunch() ) ); QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 0, this, 0 ); m_transfer->addTo( m_console ); connect(m_transfer, SIGNAL(activated() ), this, SLOT(slotTransfer() ) ); /* * immediate change of line wrap policy */ m_isWrapped = false; m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); m_wrap->addTo( m_console ); connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); /* * fullscreen */ m_isFullscreen = false; m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) , QString::null, 0, this, 0); m_fullscreen->addTo( m_console ); connect( m_fullscreen, SIGNAL( activated() ), this, SLOT( slotFullscreen() ) ); m_console->insertSeparator(); QAction *a = new QAction(); a->setText( tr("Save history") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotSaveHistory() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_terminate, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); m_closewindow = new QAction(); m_closewindow->setText( tr("Close Window") ); m_closewindow->addTo( m_console ); connect( m_closewindow, SIGNAL(activated() ), this, SLOT(slotClose() ) ); /* * script actions */ m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); m_recordScript->addTo(m_scripts); connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); m_saveScript->addTo(m_scripts); connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); /* * action that open/closes the keyboard */ m_openKeys = new QAction (tr("Open Keyboard..."), Resource::loadPixmap( "console/keys/keyboard_icon" ), QString::null, 0, this, 0); m_openKeys->setToggleAction(true); connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); /* insert the submenu */ m_console->insertItem(tr("New from Profile"), m_sessionsPop, -1, 0); /* insert the connection menu */ m_bar->insertItem( tr("Connection"), m_console ); /* the scripts menu */ m_bar->insertItem( tr("Scripts"), m_scripts ); /* and the keyboard */ m_keyBar = new QToolBar(this); addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); m_keyBar->setHorizontalStretchable( TRUE ); m_keyBar->hide(); m_kb = new FunctionKeyboard(m_keyBar); connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); a = new QAction(tr("Copy"), Resource::loadPixmap("copy"), QString::null, 0, this, 0 ); //a->addTo( m_icons ); connect( a, SIGNAL(activated() ), this, SLOT(slotCopy() ) ); QAction *paste = new QAction(tr("Paste"), Resource::loadPixmap("paste"), QString::null, 0, this, 0 ); connect( paste, SIGNAL(activated() ), this, SLOT(slotPaste() ) ); newCon->addTo( m_icons ); //m_setProfiles->addTo( m_icons ); paste->addTo( m_icons ); m_openKeys->addTo(m_icons); m_fullscreen->addTo( m_icons ); m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_fullscreen->setEnabled( false ); m_closewindow->setEnabled( false ); m_wrap->setEnabled( false ); /* * connect to the menu activation */ connect( m_sessionsPop, SIGNAL(activated(int) ), this, SLOT(slotProfile(int) ) ); m_consoleWindow = new TabWidget( this, "blah"); connect(m_consoleWindow, SIGNAL(activated(Session*) ), this, SLOT(slotSessionChanged(Session*) ) ); setCentralWidget( m_consoleWindow ); slotQuickLaunch(); } ProfileManager* MainWindow::manager() { return m_manager; } TabWidget* MainWindow::tabWidget() { return m_consoleWindow; } void MainWindow::populateProfiles() { m_sessionsPop->clear(); Profile::ValueList list = manager()->all(); for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { m_sessionsPop->insertItem( (*it).name() ); } } void MainWindow::populateScripts() { m_scriptsPop->clear(); m_scriptsData.clear(); DocLnkSet files(QPEApplication::documentDir(), "text/plain"); QListIterator<DocLnk> dit(files.children()); for (; dit.current(); ++dit) { if (*dit && (*dit)->name().length()>0) { QFileInfo info((*dit)->file()); if (info.extension(false) == "script") { m_scriptsData.append(new DocLnk(**dit)); m_scriptsPop->insertItem((*dit)->name()); } } } } MainWindow::~MainWindow() { delete m_factory; manager()->save(); } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { ProfileEditorDialog dlg(factory() ); dlg.setCaption( tr("New Connection") ); int ret = QPEApplication::execDialog( &dlg ); if ( ret == QDialog::Accepted ) { create( dlg.profile() ); } } void MainWindow::slotRecordScript() { if (currentSession()) { currentSession()->emulationHandler()->startRecording(); m_saveScript->setEnabled(true); m_recordScript->setEnabled(false); } } void MainWindow::slotSaveScript() { if (currentSession() && currentSession()->emulationHandler()->isRecording()) { QMap<QString, QStringList> map; QStringList text; text << "text/plain"; map.insert(tr("Script"), text ); - QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); + QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); if (!filename.isEmpty()) { QFileInfo info(filename); if (info.extension(FALSE) != "script") filename += ".script"; DocLnk nf; nf.setType("text/plain"); nf.setFile(filename); nf.setName(info.fileName()); FileManager fm; fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); currentSession()->emulationHandler()->clearScript(); m_saveScript->setEnabled(false); m_recordScript->setEnabled(true); populateScripts(); } } } void MainWindow::slotRunScript(int id) { if (currentSession()) { int index = m_scriptsPop->indexOf(id); DocLnk *lnk = m_scriptsData.at(index); QString filePath = lnk->file(); Script script(filePath); currentSession()->emulationHandler()->runScript(&script); } } void MainWindow::slotConnect() { if ( currentSession() ) { bool ret = currentSession()->layer()->open(); if(!ret) QMessageBox::warning(currentSession()->widgetStack(), QObject::tr("Failed"), QObject::tr("Connecting failed for this session.")); else { m_connect->setEnabled( false ); m_disconnect->setEnabled( true ); // if it does not support file transfer, disable the menu entry if ( ( m_curSession->layer() )->supports()[1] == 0 ) { m_transfer->setEnabled( false ); } else { m_transfer->setEnabled( true ); } m_recordScript->setEnabled( true ); m_scripts->setItemEnabled(m_runScript_id, true); } } } void MainWindow::slotDisconnect() { if ( currentSession() ) { currentSession()->layer()->close(); m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); } } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); slotClose(); /* FIXME move to the next session */ } void MainWindow::slotQuickLaunch() { Profile prof = manager()->profile( "default" ); if ( prof.name() == "default" ) { create( prof ); } else { Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); newProf.setAutoConnect( true ); create( newProf ); slotSaveSession(); } } void MainWindow::slotConfigure() { ConfigDialog conf( manager()->all(), factory() ); int ret = QPEApplication::execDialog( &conf ); if ( QDialog::Accepted == ret ) { manager()->setProfiles( conf.list() ); manager()->save(); populateProfiles(); } } /* * we will remove * this window from the tabwidget * remove it from the list * delete it * and set the currentSession() */ void MainWindow::slotClose() { if (!currentSession() ) return; Session* ses = currentSession(); qWarning("removing! currentSession %s", currentSession()->name().latin1() ); /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ m_curSession = NULL; tabWidget()->remove( /*currentSession()*/ses ); /*it's autodelete */ m_sessions.remove( ses ); qWarning("after remove!!"); if (!currentSession() ) { m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); m_fullscreen->setEnabled( false ); m_wrap->setEnabled( false ); m_closewindow->setEnabled( false ); } m_kb->loadDefaults(); } /* * We will get the name * Then the profile * and then we will make a profile */ void MainWindow::slotProfile( int id) { Profile prof = manager()->profile( m_sessionsPop->text( id) ); create( prof ); } void MainWindow::create( const Profile& prof ) { if(m_curSession) if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); Session *ses = manager()->fromProfile( prof, tabWidget() ); if((!ses) || (!ses->layer()) || (!ses->widgetStack())) { QMessageBox::warning(this, QObject::tr("Session failed"), QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); //if(ses) delete ses; return; } m_sessions.append( ses ); tabWidget()->add( ses ); tabWidget()->repaint(); m_curSession = ses; // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( true ); m_fullscreen->setEnabled( true ); m_wrap->setEnabled( true ); m_closewindow->setEnabled( true ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); // is io_layer wants direct connection, then autoconnect //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { if (prof.autoConnect()) { slotConnect(); } QWidget *w = currentSession()->widget(); if(w) w->setFocus(); if(currentSession()->profile().readNumEntry("Wrap", 80)){ m_isWrapped = true; } else { m_isWrapped = false; } m_kb->load(currentSession()->profile()); } void MainWindow::slotTransfer() { if ( currentSession() ) { Session *mysession = currentSession(); TransferDialog dlg(/*mysession->widgetStack()*/this, this); mysession->setTransferDialog(&dlg); //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); //dlg.showMaximized(); currentSession()->widgetStack()->addWidget(&dlg, -1); dlg.show(); //dlg.exec(); while(dlg.isRunning()) qApp->processEvents(); mysession->setTransferDialog(0l); } } void MainWindow::slotOpenKeb(bool state) { if (state) m_keyBar->show(); else m_keyBar->hide(); } void MainWindow::slotOpenButtons( bool state ) { if ( state ) { m_buttonBar->show(); } else { m_buttonBar->hide(); } } void MainWindow::slotSessionChanged( Session* ses ) { qWarning("changed!"); if(m_curSession) if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); if(ses) if(ses->transferDialog()) ses->transferDialog()->show(); if ( ses ) { m_curSession = ses; qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); if ( m_curSession->layer()->isConnected() ) { m_connect->setEnabled( false ); m_disconnect->setEnabled( true ); m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); m_scripts->setItemEnabled(m_runScript_id, true); } else { m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); } if ( ( m_curSession->layer() )->supports()[1] == 0 ) { m_transfer->setEnabled( false ); } else { m_transfer->setEnabled( true ); } QWidget *w = m_curSession->widget(); if(w) w->setFocus(); if(currentSession()->profile().readNumEntry("Wrap", 80)){ m_isWrapped = true; } else { m_isWrapped = false; } m_kb->load(currentSession()->profile()); } } void MainWindow::slotWrap() { if(m_curSession) { EmulationHandler *e = m_curSession->emulationHandler(); if(e) { if(m_isWrapped) { e->setWrap(80); m_isWrapped = false; } else { e->setWrap(0); m_isWrapped = true; } } } } void MainWindow::slotFullscreen() { if ( m_isFullscreen ) { ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); ( m_curSession->emulationHandler() )->cornerButton()->hide(); disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } else { savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop , QPoint(0,0), false ); ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); ( m_curSession->widgetStack() )->setFocus(); ( m_curSession->widgetStack() )->show(); ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } m_isFullscreen = !m_isFullscreen; } void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { if ( m_curSession ) { QEvent::Type state; if (pressed) state = QEvent::KeyPress; else state = QEvent::KeyRelease; QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); // is this the best way to do this? cant figure out any other way to work QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); ke.ignore(); } } void MainWindow::slotCopy() { if (!currentSession() ) return; currentSession()->emulationHandler()->copy(); } void MainWindow::slotPaste() { if (!currentSession() ) return; currentSession()->emulationHandler()->paste(); } /* * Save the session */ void MainWindow::slotSaveSession() { if (!currentSession() ) { QMessageBox::information(this, tr("Save Connection"), tr("<qt>There is no Connection.</qt>"), 1 ); return; } manager()->add( currentSession()->profile() ); manager()->save(); populateProfiles(); } void MainWindow::slotSaveHistory() { QMap<QString, QStringList> map; QStringList text; text << "text/plain"; map.insert(tr("History"), text ); - QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); + QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); if (filename.isEmpty() ) return; QFileInfo info(filename); DocLnk nf; nf.setType("text/plain"); nf.setFile(filename); nf.setName(info.fileName()); QFile file(filename); file.open(IO_WriteOnly ); QTextStream str(&file ); if ( currentSession() ) currentSession()->emulationHandler()->emulation()->streamHistory(&str); file.close(); nf.writeLink(); } diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 6e1e23e..dc42d8b 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -1,203 +1,204 @@ #include <qlayout.h> #include <qlineedit.h> #include <qlabel.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qscrollview.h> #include "metafactory.h" #include "profileeditordialog.h" +using namespace Opie::Ui; namespace { void setCurrent( const QString& str, QComboBox* bo ) { for (int i = 0; i < bo->count(); i++ ) { if ( bo->text(i) == str ) { bo->setCurrentItem( i ); } } }; } ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, const Profile& prof ) : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) { initUI(); // Apply current profile // plugin_plugin->load(profile); // ... (reset profile name line edit etc.) } ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) : QDialog(0, 0, TRUE), m_fact( fact ) { // Default profile m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102); initUI(); // Apply current profile // plugin_plugin->load(profile); } Profile ProfileEditorDialog::profile() const { return m_prof; } void ProfileEditorDialog::initUI() { m_con = m_term = m_key = 0l; QVBoxLayout *mainLayout = new QVBoxLayout( this ); tabWidget = new OTabWidget( this ); tabWidget->setTabStyle(OTabWidget::TextTab); mainLayout->add(tabWidget); /* base tabs */ tabprof = new QWidget(this); m_tabTerm = new QWidget(this); m_tabCon = new QWidget(this); m_tabKey = new QWidget(this); m_svCon = new QScrollView( m_tabCon ); m_svCon->setResizePolicy( QScrollView::AutoOneFit ); //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); m_svCon->setFrameShape( QFrame::NoFrame ); m_svTerm = new QScrollView( m_tabTerm ); m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); m_svTerm->setFrameShape( QFrame::NoFrame ); /* base layout for tabs */ m_layCon = new QHBoxLayout( m_tabCon , 2 ); m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); m_layKey = new QHBoxLayout( m_tabKey, 2 ); m_layCon->addWidget( m_svCon ); m_layTerm->addWidget( m_svTerm ); // profile tab QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); m_name = new QLineEdit(tabprof); QLabel *con = new QLabel(tr("Connection"), tabprof ); QLabel *term = new QLabel(tr("Terminal"), tabprof ); m_conCmb = new QComboBox( tabprof ); m_termCmb = new QComboBox( tabprof ); m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); // layouting QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); vbox3->add(name); vbox3->add(m_name); vbox3->add(con ); vbox3->add(m_conCmb ); vbox3->add(term ); vbox3->add(m_termCmb ); vbox3->add(m_autoConnect); vbox3->addStretch(1); m_showconntab = 0; tabWidget->addTab(tabprof, "", QObject::tr("Profile")); tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); tabWidget->setCurrentTab( tabprof ); // fill the comboboxes QStringList list = m_fact->connectionWidgets(); QStringList::Iterator it; for (it =list.begin(); it != list.end(); ++it ) { m_conCmb->insertItem( (*it) ); } list = m_fact->terminalWidgets(); for (it =list.begin(); it != list.end(); ++it ) { m_termCmb->insertItem( (*it) ); } // load profile values m_name->setText(m_prof.name()); slotKeyActivated( "Default Keyboard" ); setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); slotTermActivated( m_fact->external(m_prof.terminalName() ) ); m_autoConnect->setChecked(m_prof.autoConnect()); // signal and slots connect(m_conCmb, SIGNAL(activated(const QString&) ), this, SLOT(slotConActivated(const QString&) ) ); connect(m_termCmb, SIGNAL(activated(const QString&) ), this, SLOT(slotTermActivated(const QString&) ) ); } ProfileEditorDialog::~ProfileEditorDialog() { } void ProfileEditorDialog::accept() { if(profName().isEmpty()) { QMessageBox::information(this, QObject::tr("Invalid profile"), QObject::tr("Please enter a profile name.")); return; } // Save profile and plugin profile //if(plugin_plugin) plugin_plugin->save(); // Save general values m_prof.setName( profName() ); m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); m_prof.setAutoConnect( m_autoConnect->isChecked() ); if (m_con ) m_con->save( m_prof ); if (m_term ) m_term->save( m_prof ); if (m_key) m_key->save( m_prof ); QDialog::accept(); } QString ProfileEditorDialog::profName()const { return m_name->text(); } QCString ProfileEditorDialog::profType()const { /*QStringList w = m_fact->configWidgets(); for(QStringList::Iterator it = w.begin(); it != w.end(); it++) if(device_box->currentText() == m_fact->name((*it))) return (*it); */ return QCString(); } /* * we need to switch the widget */ void ProfileEditorDialog::slotConActivated( const QString& str ) { delete m_con; m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); if ( !m_con ) { m_con = new NoOptions( str, m_svCon->viewport(), "name"); } // FIXME ugly hack right. Right solution would be to look into the layer and see if it // supports auto connect and then set it as prefered if ( m_conCmb ->currentText() == tr("Local Console") ) { m_autoConnect->setChecked( true ); m_prof.writeEntry("Terminal", Profile::Linux ); diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index 97bd650..e7a88e9 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h @@ -1,61 +1,61 @@ #ifndef PROFILE_EDITOR_DIALOG #define PROFILE_EDITOR_DIALOG #include <qdialog.h> #include <opie2/otabwidget.h> #include "profile.h" class MetaFactory; class EditBase; class QTabWidget; class QHBoxLayout; class QLineEdit; class QComboBox; class QCheckBox; class QLabel; class QScrollView; class ProfileDialogWidget; class ProfileEditorDialog : public QDialog { Q_OBJECT public: ProfileEditorDialog(MetaFactory* fact, const Profile& prof ); ProfileEditorDialog(MetaFactory* fact ); ~ProfileEditorDialog(); Profile profile()const; public slots: void accept(); private slots: void slotConActivated(const QString& ); void slotTermActivated( const QString& ); void slotKeyActivated(const QString&); private: void initUI(); QString profName()const; QCString profType()const; MetaFactory* m_fact; QHBoxLayout* m_lay; Profile m_prof; QLineEdit *m_name; QComboBox *m_conCmb, *m_termCmb; QCheckBox *m_autoConnect; QScrollView *m_svCon, *m_svTerm; QWidget *m_tabCon, *m_tabTerm, *m_tabKey; ProfileDialogWidget* m_con, *m_term, *m_key; QHBoxLayout *m_layCon, *m_layTerm, *m_layKey; - OTabWidget *tabWidget; + Opie::Ui::OTabWidget *tabWidget; QWidget *tabprof; int m_showconntab; }; #endif diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index 2f82417..5958e93 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp @@ -1,84 +1,86 @@ #include "sz_transfer.h" #include <qfile.h> #include <stdio.h> #include <sys/termios.h> +using namespace Opie::Core; +using namespace Opie::Core; SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) { } SzTransfer::~SzTransfer() { } void SzTransfer::sendFile(const QFile& file) { sendFile(file.name()); } void SzTransfer::sendFile(const QString& file) { //setcbreak(2); /* raw no echo */ proc = new OProcess; *proc << "sz"; *proc << "-v" << "-v" << "-b" << file; - connect(proc, SIGNAL(processExited(OProcess*)), + connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT(sent())); - connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), + connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), this, SLOT(SzReceivedStdout(OProcess*,char*,int))); - connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), + connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT(SzReceivedStderr(OProcess*,char*,int))); connect(layer(), SIGNAL(received(const QByteArray&)), this, SLOT(receivedStdin(const QByteArray&))); proc->start(OProcess::NotifyOnExit, OProcess::All); } void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { qWarning("recieved from sz on stdout %d bytes", buflen); QByteArray data(buflen); data.fill(*buffer, buflen); for (uint i = 0; i < data.count(); i++ ) { printf("%c", buffer[i] ); } printf("\n"); // send out through the io layer layer()->send(data); } void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { // parse and show data in a progress dialog/widget printf("stderr:\n"); //for (int i = 0; i < length; i++) // printf("%c", buffer[i]); //printf("\n"); } void SzTransfer::receivedStdin(const QByteArray &data) { qWarning("recieved from io_serial %d bytes", data.size()); // recieved data from the io layer goes to sz proc->writeStdin(data.data(), data.size()); } void SzTransfer::sent() { qWarning("sent file"); //setcbreak(0); /* default */ delete proc; disconnect(layer(), SIGNAL(received(const QByteArray&)), this, SLOT(receivedStdin(const QByteArray&))); } diff --git a/noncore/apps/opie-console/sz_transfer.h b/noncore/apps/opie-console/sz_transfer.h index aa97c32..0505215 100644 --- a/noncore/apps/opie-console/sz_transfer.h +++ b/noncore/apps/opie-console/sz_transfer.h @@ -1,40 +1,40 @@ #ifndef OPIE_FL_SZ_H #define OPIE_FL_SZ_H #include "file_layer.h" #include <opie2/oprocess.h> class SzTransfer : public FileTransferLayer { Q_OBJECT public: enum Type { SZ=0, SX, SY }; SzTransfer( Type t, IOLayer * ); ~SzTransfer(); public slots: /** * send a file over the layer */ void sendFile( const QString& file ) ; void sendFile( const QFile& ); void sent(); private slots: - void SzReceivedStdout(OProcess *, char *, int); - void SzReceivedStderr(OProcess *, char *, int); + void SzReceivedStdout(Opie::Core::OProcess *, char *, int); + void SzReceivedStderr(Opie::Core::OProcess *, char *, int); void receivedStdin(const QByteArray &); private: - OProcess *proc; + Opie::Core::OProcess *proc; Type m_t; }; #endif diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp index 419f8ac..6429e3c 100644 --- a/noncore/apps/opie-console/tabwidget.cpp +++ b/noncore/apps/opie-console/tabwidget.cpp @@ -1,44 +1,45 @@ #include "tabwidget.h" +using namespace Opie::Ui; TabWidget::TabWidget( QWidget* parent, const char* name ) : OTabWidget( parent, name ) { connect(this, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotCurChanged(QWidget*) ) ); } TabWidget::~TabWidget() { } void TabWidget::add( Session* ses ) { qWarning("session ses " + ses->name() ); if ( !ses->widgetStack() ) return; //reparent( ses->widgetStack(), QPoint() ); addTab( ses->widgetStack(), "console/konsole", ses->name() ); //addTab( ses->widgetStack(), ses->name() ); m_map.insert( ses->widgetStack(), ses ); } void TabWidget::remove( Session* ses ) { m_map.remove( ses->widgetStack() ); removePage( ses->widgetStack() ); } void TabWidget::slotCurChanged( QWidget* wid ) { QMap<QWidget*, Session*>::Iterator it; it = m_map.find( wid ); if ( it == m_map.end() ) { return; } emit activated( it.data() ); } void TabWidget::setCurrent( Session* ses ) { if (!ses ) return; //showPage( ses->widgetStack() ); setCurrentTab( ses->widgetStack() ); } diff --git a/noncore/apps/opie-console/tabwidget.h b/noncore/apps/opie-console/tabwidget.h index 98450a3..0138645 100644 --- a/noncore/apps/opie-console/tabwidget.h +++ b/noncore/apps/opie-console/tabwidget.h @@ -1,29 +1,29 @@ #ifndef OPIE_TAB_WIDGET_H #define OPIE_TAB_WIDGET_H #include <qmap.h> #include <opie2/otabwidget.h> #include "session.h" /** * This is our central tab widget * we can add sessions here */ -class TabWidget : public OTabWidget{ +class TabWidget : public Opie::Ui::OTabWidget{ Q_OBJECT public: TabWidget(QWidget *parent, const char* name ); ~TabWidget(); void add( Session* ); void remove( Session* ); void setCurrent( Session* ); signals: void activated(Session* ses ); private slots: void slotCurChanged( QWidget* wid ); private: QMap<QWidget*, Session*> m_map; }; #endif diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp index b1725db..df27055 100644 --- a/noncore/apps/opie-console/test/senderui.cpp +++ b/noncore/apps/opie-console/test/senderui.cpp @@ -1,77 +1,79 @@ #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <sys/termios.h> #include <qmultilineedit.h> #include <qsocketnotifier.h> #include "../profile.h" #include "../io_serial.h" #include "../filetransfer.h" #include "../filereceive.h" #include <opie2/oprocess.h> #include "senderui.h" +using namespace Opie::Core; +using namespace Opie::Core; SenderUI::SenderUI() : Sender() { /* we do that manually */ Profile prof; QString str = "/dev/bty0"; prof.writeEntry("Device",str ); prof.writeEntry("Baud", 19200 ); qWarning("prof " + prof.readEntry("Device") + " " + str); ser = new IOSerial(prof); connect(ser, SIGNAL(received(const QByteArray&) ), this, SLOT(got(const QByteArray&) ) ); if ( ser->open() ) qWarning("opened!!!"); else qWarning("could not open"); } SenderUI::~SenderUI() { } void SenderUI::slotSendFile() { sz = new FileTransfer(FileTransfer::SY, ser); sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); connect (sz, SIGNAL(sent()), this, SLOT(fileTransComplete())); } void SenderUI::slotSend() { QCString str = MultiLineEdit1->text().utf8(); qWarning("sending: %s", str.data() ); str = str.replace( QRegExp("\n"), "\r"); ser->send( str ); } void SenderUI::got(const QByteArray& ar) { qWarning("got:"); for ( uint i = 0; i < ar.count(); i++ ) { printf("%c", ar[i] ); } printf("\n"); } void SenderUI::fileTransComplete() { qWarning("file transfer complete"); } void SenderUI::send() { } void SenderUI::slotRev(){ qWarning("Going to receive!"); FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); rev->receive(); } diff --git a/noncore/apps/opie-console/test/senderui.h b/noncore/apps/opie-console/test/senderui.h index c130dcf..15f0743 100644 --- a/noncore/apps/opie-console/test/senderui.h +++ b/noncore/apps/opie-console/test/senderui.h @@ -1,34 +1,34 @@ #ifndef SENDER_UI_H #define SENDER_UI_H #include <qcstring.h> #include "sender.h" class IOSerial; class FileTransfer; class QSocketNotifier; -class OProcess; +namespace Opie {namespace Core {class Opie::Core::OProcess;}} class SenderUI : public Sender { Q_OBJECT public: SenderUI(); ~SenderUI(); public slots: void send(); void slotSendFile(); void slotSend(); void slotRev(); void got(const QByteArray& ); void fileTransComplete(); private: IOSerial* ser; FileTransfer* sz; int m_fd; QSocketNotifier* m_sock; - OProcess* m_proc; + Opie::Core::OProcess* m_proc; }; #endif diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index d494a6c..75eb443 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp @@ -1,275 +1,276 @@ #include <qlayout.h> #include <qcombobox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <opie2/ofiledialog.h> #include "metafactory.h" #include "mainwindow.h" #include "transferdialog.h" +using namespace Opie::Ui; TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *) : QDialog(parent, 0l, false), m_win(mainwindow) { m_lay = 0l; m_recvlay = 0l; QVBoxLayout *vbox, *vbox2; QHBoxLayout *hbox, *hbox2, *hbox3; QLabel *file, *mode, *progress, *status; QButtonGroup *group; QRadioButton *mode_send, *mode_receive; m_autocleanup = 0; m_running = true; group = new QButtonGroup(QObject::tr("Transfer mode"), this); mode_send = new QRadioButton(QObject::tr("Send"), group); mode_receive = new QRadioButton(QObject::tr("Receive"), group); group->insert(mode_send, id_send); group->insert(mode_receive, id_receive); vbox2 = new QVBoxLayout(group, 2); vbox2->addSpacing(10); hbox3 = new QHBoxLayout(vbox2, 2); hbox3->add(mode_send); hbox3->add(mode_receive); mode_send->setChecked(true); m_transfermode = id_send; file = new QLabel(QObject::tr("Send file"), this); mode = new QLabel(QObject::tr("Transfer protocol"), this); progress = new QLabel(QObject::tr("Progress"), this); status = new QLabel(QObject::tr("Status"), this); statusbar = new QLabel(QObject::tr("Ready"), this); statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); protocol = new QComboBox(this); QStringList list = m_win->factory()->fileTransferLayers(); for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) protocol->insertItem((*it)); filename = new QLineEdit(this); progressbar = new QProgressBar(this); progressbar->setProgress(0); selector = new QPushButton("...", this); ok = new QPushButton(QObject::tr("Start transfer"), this); cancel = new QPushButton(QObject::tr("Cancel"), this); vbox = new QVBoxLayout(this, 2); vbox->add(group); vbox->add(file); hbox = new QHBoxLayout(vbox, 0); hbox->add(filename); hbox->add(selector); vbox->add(mode); vbox->add(protocol); vbox->add(progress); vbox->add(progressbar); vbox->add(status); vbox->add(statusbar); vbox->addStretch(1); hbox2 = new QHBoxLayout(vbox, 2); hbox2->add(ok); hbox2->add(cancel); setCaption(QObject::tr("File transfer")); show(); connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); } TransferDialog::~TransferDialog() { } void TransferDialog::slotFilename() { QString f; - f = Opie::OFileDialog::getOpenFileName(0); + f = OFileDialog::getOpenFileName(0); if(!f.isNull()) filename->setText(f); } void TransferDialog::slotTransfer() { if((m_transfermode == id_send) && (filename->text().isEmpty())) { QMessageBox::information(this, QObject::tr("Attention"), QObject::tr("No file has been specified.")); return; } ok->setEnabled(false); cleanup(); m_autocleanup = 0; if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); else statusbar->setText(QObject::tr("Receiving...")); if(m_transfermode == id_send) { m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); m_lay->sendFile(filename->text()); connect(m_lay, SIGNAL(progress(const QString&,int,int,int,int,int)), SLOT(slotProgress(const QString&,int,int,int,int,int))); connect(m_lay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); } else { m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); m_recvlay->receive(); connect(m_recvlay, SIGNAL(progress(const QString&,int,int,int,int,int)), SLOT(slotProgress(const QString&,int,int,int,int,int))); connect(m_recvlay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); } } void TransferDialog::cleanup() { if(m_lay) { m_lay->cancel(); delete m_lay; m_lay = 0l; } if(m_recvlay) { m_recvlay->cancel(); delete m_recvlay; m_recvlay = 0l; } } void TransferDialog::slotCancel() { ok->setEnabled(true); statusbar->setText(QObject::tr("Ready")); if((m_lay) || (m_recvlay)) { cleanup(); if(m_autocleanup) { m_running = false; close(); } else { QMessageBox::information(this, QObject::tr("Cancelled"), QObject::tr("The file transfer has been cancelled.")); } } else { m_running = false; close(); } } void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) { progressbar->setProgress(progress); } void TransferDialog::slotError(int error, const QString& ) { statusbar->setText(QObject::tr("Ready")); switch(error) { case FileTransferLayer::NotSupported: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; case FileTransferLayer::StartError: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Transfer could not be started.")); break; case FileTransferLayer::NoError: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("No error.")); break; case FileTransferLayer::Undefined: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Undefined error occured.")); break; case FileTransferLayer::Incomplete: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Incomplete transfer.")); break; case FileTransferLayer::Unknown: default: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Unknown error occured.")); break; } m_autocleanup = 1; } void TransferDialog::slotSent() { progressbar->setProgress(100); QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); ok->setEnabled(true); progressbar->setProgress(0); statusbar->setText(QObject::tr("Ready")); m_autocleanup = 1; } void TransferDialog::slotReceived(const QString& ) { progressbar->setProgress(100); QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); ok->setEnabled(true); progressbar->setProgress(0); statusbar->setText(QObject::tr("Ready")); m_autocleanup = 1; } void TransferDialog::slotMode(int id) { if(id == id_send) { selector->setEnabled(true); filename->setEnabled(true); } else { selector->setEnabled(false); filename->setEnabled(false); } m_transfermode = id; } bool TransferDialog::isRunning() { return m_running; } diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index b0d589e..b072854 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp @@ -1,218 +1,218 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. Allrights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "useqpe.h" #include <qregexp.h> #include <qclipboard.h> #include <qwidgetstack.h> #ifdef USEQPE #include <qmenubar.h> -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> #endif #include <qmenubar.h> #include <qtoolbar.h> #ifdef USEQPE #include <qpe/menubutton.h> #include <qpe/fontdatabase.h> #endif #include <qcombobox.h> #include <qpopupmenu.h> #include <qaction.h> #include <qapplication.h> #include <qlineedit.h> #include <qtoolbutton.h> #include <qspinbox.h> #include <qobjectlist.h> #ifdef USEQPE #include <qpe/global.h> #include <qpe/applnk.h> #endif #include <qfileinfo.h> #include <stdlib.h> //getenv #include <qprogressbar.h> #ifdef USEQPE #include <qpe/config.h> #endif #include <qbuttongroup.h> #include <qradiobutton.h> #ifdef USEQPE #include <qpe/qcopenvelope_qws.h> #endif #include "QTReader.h" #include "GraphicWin.h" #include "Bkmks.h" #include "cbkmkselector.h" #include "infowin.h" #include "ToolbarPrefs.h" #include "Prefs.h" #include "CAnnoEdit.h" #include "QFloatBar.h" #include "FixedFont.h" #include "URLDialog.h" //#include <qpe/fontdatabase.h> #ifdef USEQPE #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include "fileBrowser.h" #else #include "qfiledialog.h" #endif #include "QTReaderApp.h" #include "CDrawBuffer.h" #include "Filedata.h" #include "opie.h" #include "names.h" #include "CEncoding_tables.h" #include "CloseDialog.h" bool CheckVersion(int&, int&, char&); #ifdef _WINDOWS #define PICDIR "c:\\uqtreader\\pics\\" #else #ifdef USEQPE #define PICDIR "opie-reader/" #else #define PICDIR "/home/tim/uqtreader/pics/" #endif #endif unsigned long QTReaderApp::m_uid = 0; void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } #ifdef USEQPE #define geticon(iconname) Resource::loadPixmap( iconname ) #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) #else #define geticon(iconname) QPixmap(PICDIR iconname ".png") #define getmyicon(iconname) geticon(iconname) //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) #endif #ifndef _WINDOWS #include <unistd.h> #endif #include <stddef.h> #ifndef _WINDOWS #include <dirent.h> #endif void QTReaderApp::listBkmkFiles() { bkmkselector->clear(); bkmkselector->setText("Cancel"); #ifndef USEQPE int cnt = 0; QDir d = QDir::home(); // "/" if ( !d.cd(APPDIR) ) { // "/tmp" qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); d = QDir::home(); d.mkdir(APPDIR); d.cd(APPDIR); } d.setFilter( QDir::Files | QDir::NoSymLinks ); // d.setSorting( QDir::Size | QDir::Reversed ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing while ( (fi=it.current()) ) { // for each file... bkmkselector->insertItem(fi->fileName()); cnt++; //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); ++it; // goto next list element } #else /* USEQPE */ int cnt = 0; DIR *d; d = opendir((const char *)Global::applicationFileName(APPDIR,"")); while(1) { struct dirent* de; struct stat buf; de = readdir(d); if (de == NULL) break; if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) { bkmkselector->insertItem(de->d_name); cnt++; } } closedir(d); #endif if (cnt > 0) { //tjw menu->hide(); editorStack->raiseWidget( bkmkselector ); hidetoolbars(); m_nBkmkAction = cRmBkmkFile; } else QMessageBox::information(this, PROGNAME, "No bookmark files"); } void QTReaderApp::hidetoolbars() { menubar->hide(); if (fileBar != NULL) fileBar->hide(); if (viewBar != NULL) viewBar->hide(); if (navBar != NULL) navBar->hide(); if (markBar != NULL) markBar->hide(); if (m_fontVisible) m_fontBar->hide(); if (regVisible) { #ifdef USEQPE Global::hideInputMethod(); #endif regBar->hide(); } if (searchVisible) { #ifdef USEQPE Global::hideInputMethod(); #endif searchBar->hide(); } } QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) { m_url_clipboard = false; m_url_localfile = false; m_url_globalfile = false; ftime(&m_lastkeytime); //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); diff --git a/noncore/apps/opie-sheet/main.cpp b/noncore/apps/opie-sheet/main.cpp index c7a7d88..861473e 100644 --- a/noncore/apps/opie-sheet/main.cpp +++ b/noncore/apps/opie-sheet/main.cpp @@ -1,20 +1,23 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ + #include "mainwindow.h" #include <opie2/oapplicationfactory.h> +using namespace Opie::Core; + OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/apps/opie-write/main.cpp b/noncore/apps/opie-write/main.cpp index 6a8aaaa..036fe48 100644 --- a/noncore/apps/opie-write/main.cpp +++ b/noncore/apps/opie-write/main.cpp @@ -1,28 +1,30 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** Licensees holding valid Qtopia Developer license may use this ** file in accordance with the Qtopia Developer License Agreement ** provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE. ** ** email sales@trolltech.com for information about Qtopia License ** Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ + #include "mainwindow.h" #include <opie2/oapplicationfactory.h> +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/apps/oxygen/main.cpp b/noncore/apps/oxygen/main.cpp index 276b90d..e2a602b 100644 --- a/noncore/apps/oxygen/main.cpp +++ b/noncore/apps/oxygen/main.cpp @@ -1,23 +1,25 @@ /*************************************************************************** application: : Oxygen begin : September 2002 copyright : ( C ) 2002 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include <opie2/oapplicationfactory.h> #include "oxygen.h" +using namespace Opie::Core; +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<Oxygen> ) diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp index 80a76e0..7ef281c 100644 --- a/noncore/apps/tableviewer/main.cpp +++ b/noncore/apps/tableviewer/main.cpp @@ -1,25 +1,27 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "tableviewer.h" #include <opie2/oapplicationfactory.h> +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<TableViewerWindow> ) +using namespace Opie::Core; diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index 4c6d809..102b94c 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp @@ -1,225 +1,225 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ /* local includes */ #include "tableviewer.h" #include "ui/tvbrowseview.h" #include "ui/tvfilterview.h" #include "ui/tvlistview.h" #include "ui/tveditview.h" #include "ui/tvkeyedit.h" #include "db/datacache.h" /* QPE includes */ #include <qpe/fileselector.h> #include <qpe/resource.h> -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> /* QTE includes */ #include <qmenubar.h> #include <qpopupmenu.h> #include <qapplication.h> #include <qwidgetstack.h> #include <qlayout.h> #include <qbuffer.h> /*! \class TableViewerWindow \brief The main window widget of the application This is the main widget of the table viewer application. It is the co-ordination point. */ /*! Constructs a new TableViewerWindow */ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { setCaption(tr("Table Viewer")); /* Build data */ ds = new DBStore(); doc.setType("text/x-xml-tableviewer"); doc.setName("table"); dirty = FALSE; ts.current_column = 0; ts.kRep = ds->getKeys(); /* build menus */ menu = new QMenuBar(this, 0); QPopupMenu *file_menu = new QPopupMenu; file_menu->insertItem("New", this, SLOT(newDocument())); file_menu->insertItem("Open", this, SLOT(selectDocument())); file_menu->insertSeparator(); file_menu->insertItem("Properties"); /* later will want to set this up to clean up first via this, SLOT(quit) */ menu->insertItem("Document", file_menu); QPopupMenu *edit_menu = new QPopupMenu; edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); menu->insertItem("Edit", edit_menu); QPopupMenu *view_menu = new QPopupMenu; view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); view_menu->insertItem("List View", this, SLOT(listViewSlot())); menu->insertItem("View", view_menu); QVBoxLayout *main_layout = new QVBoxLayout; /* Build tool bar */ navigation = new QToolBar(this, "navigation"); QToolButton *newItemButton = new QToolButton( QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, this, SLOT(newItemSlot()), navigation, "New Item"); QToolButton *editItemButton = new QToolButton( QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, this, SLOT(editItemSlot()), navigation, "Edit Item"); QToolButton *deleteItemButton = new QToolButton( QIconSet(Resource::loadPixmap("trash")), "Delete Item", QString::null, this, SLOT(deleteItemSlot()), navigation, "Delete Item"); navigation->addSeparator(); QToolButton *firstItemButton = new QToolButton( QIconSet(Resource::loadPixmap("fastback")), "First Item", QString::null, this, SLOT(firstItem()), navigation, "First Item"); QToolButton *previousItemButton = new QToolButton( QIconSet(Resource::loadPixmap("back")), "Previous Item", QString::null, this, SLOT(previousItem()), navigation, "Previous Item"); QToolButton *nextItemButton = new QToolButton( QIconSet(Resource::loadPixmap("forward")), "Next Item", QString::null, this, SLOT(nextItem()), navigation, "Next Item"); QToolButton *lastItemButton = new QToolButton( QIconSet(Resource::loadPixmap("fastforward")), "Last Item", QString::null, this, SLOT(lastItem()), navigation, "Last Item"); navigation->addSeparator(); QToolButton *browseButton = new QToolButton( QIconSet(Resource::loadPixmap("day")), "View Single Item", QString::null, this, SLOT(browseViewSlot()), navigation, "View Single Item"); QToolButton *listButton = new QToolButton( QIconSet(Resource::loadPixmap("month")), "View Multiple Items", QString::null, this, SLOT(listViewSlot()), navigation, "View Multiple Items"); setToolBarsMovable(FALSE); setToolBarsMovable(FALSE); setToolBarsMovable(FALSE); /* Build widgets */ browseView = new TVBrowseView(&ts, this, 0); listView = new TVListView(&ts, this, 0); filterView = new TVFilterView(&ts, this, 0); fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", this, "fileselector"); fileSelector->setNewVisible(FALSE); fileSelector->setCloseVisible(FALSE); cw = new QWidgetStack(this, 0); cw->addWidget(listView, ListState); cw->addWidget(browseView, BrowseState); cw->addWidget(filterView, FilterState); cw->addWidget(fileSelector, FileState); current_view = FileState; cw->raiseWidget(current_view); fileSelector->reread(); connect(browseView, SIGNAL(searchOnKey(int,TVVariant)), this, SLOT(searchOnKey(int,TVVariant))); connect(browseView, SIGNAL(sortChanged(int)), this, SLOT(setPrimaryKey(int))); connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(openDocument(const DocLnk&))); main_layout->addWidget(menu); main_layout->addWidget(cw); setCentralWidget(cw); } /*! Destroys the TableViewerWindow */ TableViewerWindow::~TableViewerWindow() { if(dirty) saveDocument(); } /*! Opens a file dialog and loads the file specified by the dialog */ void TableViewerWindow::selectDocument() { if(dirty) saveDocument(); current_view = FileState; cw->raiseWidget(current_view); fileSelector->reread(); } void TableViewerWindow::saveDocument() { if(!dirty) return; FileManager fm; QIODevice *dev = fm.saveFile(doc); if(!ds->saveSource(dev, doc.type())){ qWarning("Save unsuccessful"); return; } dev->close(); dirty = FALSE; } void TableViewerWindow::newDocument() { DocLnk nf; nf.setType("text/x-xml-tableviewer"); nf.setName("table"); delete ds; ds = new DBStore(); ts.current_column = 0; ts.kRep = ds->getKeys(); browseView->reset(); listView->reset(); filterView->reset(); diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp index 8e68262..c3a0a2e 100644 --- a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp +++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp @@ -1,241 +1,243 @@ /*************************************************************************** kateviewdialog.cpp - description ------------------- copyright : (C) 2001 by The Kate Team (C) 2002 by Joseph Wenninger email : kwrite-devel@kde.org jowenn@kde.org ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // Dialogs #include <stdio.h> #include <stdlib.h> #include <qgrid.h> #include <qlabel.h> #include <qlayout.h> #include <qlistbox.h> #include <qgroupbox.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qcollection.h> #include <qpushbutton.h> #include <qobjectlist.h> #include <qradiobutton.h> #include <qwhatsthis.h> #include <qstringlist.h> #include <klocale.h> #include <kcolorbtn.h> #include <kglobal.h> #include <qvbox.h> #include <qspinbox.h> #include <qcombobox.h> #include <kfontdialog.h> #include "../document/katedocument.h" #include "kateviewdialog.h" #include <opie2/ofontselector.h> +using namespace Opie::Ui; +using namespace Opie::Ui; SearchDialog::SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags ) : KDialogBase( parent, 0L, true, i18n( "Find Text" ), Ok | Cancel, Ok ) , m_replace( 0L ) { QWidget *page = new QWidget( this ); setMainWidget( page ); QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); m_search = new QComboBox( true, page ); m_search->insertStringList( searchFor ); m_search->setMinimumWidth( m_search->sizeHint().width() ); m_search->lineEdit()->selectAll(); QLabel *label = new QLabel( m_search, i18n( "&Text To Find:" ), page ); m_optRegExp = new QCheckBox( i18n( "Regular Expression" ), page ); topLayout->addWidget( label ); topLayout->addWidget( m_search ); topLayout->addWidget( m_optRegExp ); if( flags & KateView::sfReplace ) { // make it a replace dialog setCaption( i18n( "Replace Text" ) ); m_replace = new QComboBox( true, page ); m_replace->insertStringList( replaceWith ); m_replace->setMinimumWidth( m_search->sizeHint().width() ); label = new QLabel( m_replace, i18n( "&Replace With:" ), page ); //m_optPlaceholders = new QCheckBox( i18n( "&Use Placeholders" ), page ); topLayout->addWidget( label ); topLayout->addWidget( m_replace ); //topLayout->addWidget( m_optPlaceholders ); } QGroupBox *group = new QGroupBox( i18n( "Options" ), page ); topLayout->addWidget( group, 10 ); QGridLayout *gbox = new QGridLayout( group, 5, 2, spacingHint() ); gbox->addRowSpacing( 0, fontMetrics().lineSpacing() ); gbox->setRowStretch( 4, 10 ); m_opt1 = new QCheckBox( i18n( "C&ase Sensitive" ), group ); gbox->addWidget( m_opt1, 1, 0 ); m_opt2 = new QCheckBox(i18n("&Whole Words Only" ), group ); gbox->addWidget( m_opt2, 2, 0 ); m_opt3 = new QCheckBox(i18n("&From Beginning" ), group ); gbox->addWidget( m_opt3, 3, 0 ); m_opt4 = new QCheckBox(i18n("Find &Backwards" ), group ); gbox->addWidget( m_opt4, 1, 1 ); m_opt5 = new QCheckBox(i18n("&Selected Text" ), group ); gbox->addWidget( m_opt5, 2, 1 ); m_opt1->setChecked( flags & KateView::sfCaseSensitive ); m_opt2->setChecked( flags & KateView::sfWholeWords ); m_opt3->setChecked( flags & KateView::sfFromBeginning ); m_optRegExp->setChecked( flags & KateView::sfRegularExpression ); m_opt4->setChecked( flags & KateView::sfBackward ); m_opt5->setChecked( flags & KateView::sfSelected ); if( m_replace ) { m_opt6 = new QCheckBox( i18n( "&Prompt On Replace" ), group ); m_opt6->setChecked( flags & KateView::sfPrompt ); gbox->addWidget( m_opt6, 3, 1 ); } m_search->setFocus(); } QString SearchDialog::getSearchFor() { return m_search->currentText(); } QString SearchDialog::getReplaceWith() { return m_replace->currentText(); } int SearchDialog::getFlags() { int flags = 0; if( m_opt1->isChecked() ) flags |= KateView::sfCaseSensitive; if( m_opt2->isChecked() ) flags |= KateView::sfWholeWords; if( m_opt3->isChecked() ) flags |= KateView::sfFromBeginning; if( m_opt4->isChecked() ) flags |= KateView::sfBackward; if( m_opt5->isChecked() ) flags |= KateView::sfSelected; if( m_optRegExp->isChecked() ) flags |= KateView::sfRegularExpression; if( m_replace ) { if( m_opt6->isChecked() ) flags |= KateView::sfPrompt; flags |= KateView::sfReplace; } return flags; } void SearchDialog::slotOk() { if ( !m_search->currentText().isEmpty() ) { if ( !m_optRegExp->isChecked() ) { accept(); } else { // Check for a valid regular expression. QRegExp regExp( m_search->currentText() ); if ( regExp.isValid() ) accept(); } } } void SearchDialog::setSearchText( const QString &searchstr ) { m_search->insertItem( searchstr, 0 ); m_search->setCurrentItem( 0 ); m_search->lineEdit()->selectAll(); } // this dialog is not modal ReplacePrompt::ReplacePrompt( QWidget *parent ) : KDialogBase(parent, 0L, false, i18n( "Replace Text" ), User3 | User2 | User1 | Close, User3, true, i18n("&All"), i18n("&No"), i18n("&Yes")) { QWidget *page = new QWidget(this); setMainWidget(page); QBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); QLabel *label = new QLabel(i18n("Replace this occurence?"),page); topLayout->addWidget(label ); } void ReplacePrompt::slotUser1( void ) { // All done(KateView::srAll); } void ReplacePrompt::slotUser2( void ) { // No done(KateView::srNo); } void ReplacePrompt::slotUser3( void ) { // Yes accept(); } void ReplacePrompt::done(int r) { setResult(r); emit clicked(); } void ReplacePrompt::closeEvent(QCloseEvent *) { reject(); } GotoLineDialog::GotoLineDialog(QWidget *parent, int line, int max) : KDialogBase(parent, 0L, true, i18n("Goto Line"), Ok | Cancel, Ok) { QWidget *page = new QWidget(this); setMainWidget(page); QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); e1 = new QSpinBox(page); e1->setMinValue(1); e1->setMaxValue(max); e1->setValue((int)line); QLabel *label = new QLabel( e1,i18n("&Goto Line:"), page ); topLayout->addWidget(label); topLayout->addWidget(e1); topLayout->addSpacing(spacingHint()); // A little bit extra space topLayout->addStretch(10); e1->setFocus(); } int GotoLineDialog::getLine() { return e1->value(); } const int IndentConfigTab::flags[] = {KateView::cfAutoIndent, KateView::cfSpaceIndent, KateView::cfBackspaceIndents,KateView::cfTabIndents, KateView::cfKeepIndentProfile, KateView::cfKeepExtraSpaces}; diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.h b/noncore/apps/tinykate/libkate/view/kateviewdialog.h index 98d8799..d081152 100644 --- a/noncore/apps/tinykate/libkate/view/kateviewdialog.h +++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.h @@ -1,196 +1,196 @@ /*************************************************************************** kateviewdialog.h - description ------------------- copyright : (C) 2001 by The Kate Team (C) 2002 by Joseph Wenninger email : kwrite-devel@kde.org jowenn@kde.org ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // Dialogs #ifndef _KWDIALOG_H_ #define _KWDIALOG_H_ class QCheckBox; class QLineEdit; class QPushButton; class QRadioButton; class QSpinBox; class KColorButton; class QComboBox; #include <kdialogbase.h> #include <opie2/ofontselector.h> #include "kateview.h" class SearchDialog : public KDialogBase { Q_OBJECT public: SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags ); QString getSearchFor(); QString getReplaceWith(); int getFlags(); void setSearchText( const QString &searchstr ); protected slots: void slotOk(); protected: QComboBox *m_search; QComboBox *m_replace; QCheckBox *m_opt1; QCheckBox *m_opt2; QCheckBox *m_opt3; QCheckBox *m_optRegExp; QCheckBox *m_opt4; QCheckBox *m_opt5; QCheckBox *m_opt6; }; class ReplacePrompt : public KDialogBase { Q_OBJECT public: ReplacePrompt(QWidget *parent); signals: void clicked(); protected slots: void slotUser1( void ); // All void slotUser2( void ); // No void slotUser3( void ); // Yes virtual void done(int); protected: void closeEvent(QCloseEvent *); }; class GotoLineDialog : public KDialogBase { Q_OBJECT public: GotoLineDialog(QWidget *parent, int line, int max); int getLine(); protected: QSpinBox *e1; QPushButton *btnOK; }; class IndentConfigTab : public QWidget { Q_OBJECT public: IndentConfigTab(QWidget *parent, KateView *); void getData(KateView *); protected: static const int numFlags = 6; static const int flags[numFlags]; QCheckBox *opt[numFlags]; }; class SelectConfigTab : public QWidget { Q_OBJECT public: SelectConfigTab(QWidget *parent, KateView *); void getData(KateView *); protected: static const int numFlags = 6; static const int flags[numFlags]; QCheckBox *opt[numFlags]; }; class EditConfigTab : public QWidget { Q_OBJECT public: EditConfigTab(QWidget *parent, KateView *); void getData(KateView *); protected: static const int numFlags = 9; static const int flags[numFlags]; QCheckBox *opt[numFlags]; QComboBox *encoding; QSpinBox *e1; QSpinBox *e2; QSpinBox *e3; }; class ColorConfig : public QWidget { Q_OBJECT public: ColorConfig( QWidget *parent = 0, char *name = 0 ); ~ColorConfig(); void setColors( QColor * ); void getColors( QColor * ); private: KColorButton *m_back; KColorButton *m_selected; }; class FontConfig : public QWidget { Q_OBJECT public: FontConfig( QWidget *parent = 0, char *name = 0 ); ~FontConfig(); void setFont ( const QFont &font ); QFont getFont ( ) { return myFont; }; private: - Opie::OFontSelector *m_fontselect; + Opie::Opie::Ui::OFontSelector *m_fontselect; // class KFontChooser *m_fontchooser; QFont myFont; private slots: void slotFontSelected( const QFont &font ); }; #endif //_KWDIALOG_H_ diff --git a/noncore/apps/tinykate/main.cpp b/noncore/apps/tinykate/main.cpp index e62930c..c14d10a 100644 --- a/noncore/apps/tinykate/main.cpp +++ b/noncore/apps/tinykate/main.cpp @@ -1,22 +1,25 @@ /*************************************************************************** + main.cpp ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #include <opie2/oapplicationfactory.h> #include "tinykate.h" +using namespace Opie::Core; + OPIE_EXPORT_APP( OApplicationFactory<TinyKate> ) diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index 32c1eab..3c9a637 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp @@ -1,278 +1,279 @@ /*************************************************************************** tinykate.cpp Tiny KATE mainwindow ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free softwaSre; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #include <qaction.h> #include <qtoolbutton.h> #include <qmenubar.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <opie2/ofiledialog.h> #include "tinykate.h" #include <katedocument.h> #include <kglobal.h> +using namespace Opie::Ui; TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) { shutDown=false; nextUnnamed=0; currentView=0; viewCount=0; setCaption(tr("TinyKATE")); KGlobal::setAppName("TinyKATE"); QMenuBar *mb = new QMenuBar( this ); mb->setMargin( 0 ); tabwidget=new OTabWidget(this); setCentralWidget(tabwidget); connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*))); //FILE ACTIONS QPopupMenu *popup = new QPopupMenu( this ); // Action for creating a new document QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); a->addTo( popup ); connect(a, SIGNAL(activated()), this, SLOT(slotNew())); // Action for opening an exisiting document a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); // Action for saving document a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotSave())); // Action for saving document to a new name a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); // Action for closing the currently active document a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotClose())); mb->insertItem(tr("File"),popup); //EDIT ACTIONS // Action for cutting text editCut = new QToolButton( 0 ); editCut->setAutoRaise( true ); editCut->setIconSet( Resource::loadPixmap( "cut" ) ); // Action for Copying text editCopy = new QToolButton( 0 ); editCopy->setAutoRaise( true ); editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); // Action for pasting text editPaste = new QToolButton( 0 ); editPaste->setAutoRaise( true ); editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); // Action for finding / replacing text editFindReplace = new QToolButton( 0 ); editFindReplace->setAutoRaise( true ); editFindReplace->setIconSet( Resource::loadPixmap("find") ); // Action for undo editUndo = new QToolButton( 0 ); editUndo->setAutoRaise( true ); editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); // Action for redo editRedo = new QToolButton( 0 ); editRedo->setAutoRaise( true ); editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); //VIEW ACITONS popup = new QPopupMenu( this ); viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); viewIncFontSizes->addTo( popup ); viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); viewDecFontSizes->addTo( popup ); mb->insertItem(tr("View"),popup); popup = new QPopupMenu( this ); mb->insertItem(tr("Utils"),popup); mb->insertItem( editCut ); mb->insertItem( editCopy ); mb->insertItem( editPaste ); mb->insertItem( editFindReplace ); mb->insertItem( editUndo ); mb->insertItem( editRedo ); //Highlight management hlmenu=new QPopupMenu(this); HlManager *hlm=HlManager::self(); for (int i=0;i<hlm->highlights();i++) { hlmenu->insertItem(hlm->hlName(i),i); } popup->insertItem(tr("Highlighting"),hlmenu); utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); utilSettings->addTo( popup); if( qApp->argc() > 1) open(qApp->argv()[1]); else slotNew(); } TinyKate::~TinyKate( ) { qWarning("TinyKate destructor\n"); shutDown=true; while (currentView!=0) { slotClose(); } if( KGlobal::config() != 0 ) { qWarning("deleting KateConfig object..\n"); delete KGlobal::config(); } } void TinyKate::slotOpen( ) { - QString filename = Opie::OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, + QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QString::null); if (!filename.isEmpty()) { open(filename); } } void TinyKate::open(const QString & filename) { KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; QFileInfo fi(filename); QString filenamed = fi.fileName(); tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); qDebug(filename); kd->setDocName( filenamed); kd->open( filename ); viewCount++; } void TinyKate::setDocument(const QString& fileref) { open( fileref ); } void TinyKate::slotCurrentChanged( QWidget * view) { if (currentView) { disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); } currentView=(KTextEditor::View*)view; connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); } void TinyKate::slotNew( ) { KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), "tinykate/tinykate", tr("Unnamed %1").arg(nextUnnamed++)); viewCount++; } void TinyKate::slotClose( ) { if (currentView==0) return; KTextEditor::View *dv=currentView; currentView=0; tabwidget->removePage(dv); delete dv->document(); viewCount--; if ((!viewCount) && (!shutDown)) slotNew(); } void TinyKate::slotSave() { // feel free to make this how you want if (currentView==0) return; // KateView *kv = (KateView*) currentView; KateDocument *kd = (KateDocument*) currentView->document(); // qDebug("saving file "+kd->docName()); if( kd->docName().isEmpty()) slotSaveAs(); else kd->saveFile(); // kv->save(); // kd->saveFile(); } void TinyKate::slotSaveAs() { if (currentView==0) return; KateDocument *kd = (KateDocument*) currentView->document(); - QString filename= Opie::OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, - QString::null); + QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, + QString::null); if (!filename.isEmpty()) { qDebug("saving file "+filename); QFileInfo fi(filename); QString filenamed = fi.fileName(); kd->setDocFile( filename); kd->setDocName( filenamed); kd->saveFile(); // KTextEditor::View *dv = currentView; // tabwidget->changeTab( dv, filenamed); // need to change tab label here } } diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index f844c55..f435c03 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h @@ -1,66 +1,66 @@ /*************************************************************************** tinykate.h Tiny KATE mainwindow ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #ifndef __TINYKATE_H__ #define __TINYKATE_H__ #include <qmainwindow.h> #include <opie2/otabwidget.h> #include <ktexteditor.h> class QToolButton; class QAction; class QPopupMenu; class TinyKate : public QMainWindow { Q_OBJECT public: TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); ~TinyKate( ); static QString appName() { return QString::fromLatin1( "kate" ); }; public slots: void slotNew(); void setDocument(const QString& fileref); protected slots: void slotOpen(); void slotClose(); void slotCurrentChanged(QWidget *); void slotSave(); void slotSaveAs(); protected: void open(const QString&); private: QString currentFileName; - OTabWidget *tabwidget; + Opie::Ui::OTabWidget *tabwidget; KTextEditor::View *currentView; bool shutDown; QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; QPopupMenu *hlmenu; uint nextUnnamed; uint viewCount; }; #endif // __TINYKATE_H__ diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index a3467e5..3df55eb 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp @@ -1,226 +1,225 @@ /**************************************************************************** ** ** Created: Sat Apr 6 17:57:45 2002 ** ** Author: Carsten Schneider <CarstenSchneider@t-online.de> ** ** $Id$ ** ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html ** ** Compile Flags: ** Zaurus arm : -DNO_OPIE ** Zaurus Opie arm: none ** Linux Desktop : -DDESKTOP ** Windows Desktop: -DDESKTOP -DWIN32 ** ** for japanese version additional use: -DJPATCH_HDE ** ****************************************************************************/ #include "zsafe.h" #include "newdialog.h" #include "searchdialog.h" #include "categorydialog.h" #include "passworddialog.h" #include "infoform.h" #include "zlistview.h" #include "shadedlistitem.h" #ifndef DESKTOP #ifndef NO_OPIE #include <opie2/ofiledialog.h> -using Opie::OFileDialog; -using Opie::OFileSelector; +using namespace Opie::Ui; #else #include "scqtfileedit.h" #endif #endif #include <qclipboard.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> #ifndef WIN32 #include <unistd.h> #endif #include <string.h> #include <errno.h> #include <qmenubar.h> #include <qpopupmenu.h> #ifdef DESKTOP #include <qfiledialog.h> #ifndef WIN32 #include <qsettings.h> #else #include "qsettings.h" #endif #include <qapplication.h> #else #include <qfile.h> #include <qpe/fileselector.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #endif #include <qtimer.h> #include <qlayout.h> #include <qmessagebox.h> #include <qfile.h> #include <qtextstream.h> #include <qheader.h> #include <qlistview.h> #include <qtoolbutton.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qregexp.h> #include <qdir.h> #include <qtextbrowser.h> #include <qlabel.h> #include <qcombobox.h> #include "krc2.h" #include "wait.h" extern int DeskW, DeskH; #ifdef DESKTOP extern QApplication *appl; #else extern QPEApplication *appl; #endif #ifdef JPATCH_HDE #define tr(arg) arg #endif #ifdef DESKTOP #ifndef WIN32 const QString APP_KEY="/.zsafe/"; #else const QString APP_KEY=""; #endif #else const QString APP_KEY=""; #endif // include xmp images #include "pics/zsafe/copy.xpm" #include "pics/zsafe/cut.xpm" #include "pics/zsafe/edit.xpm" #include "pics/zsafe/editdelete.xpm" #include "pics/zsafe/find.xpm" #include "pics/zsafe/folder_open.xpm" #include "pics/zsafe/help_icon.xpm" #include "pics/zsafe/new.xpm" #include "pics/zsafe/paste.xpm" #include "pics/zsafe/quit_icon.xpm" #include "pics/zsafe/save.xpm" #include "pics/zsafe/trash.xpm" #include "pics/zsafe/expand.xpm" #include "pics/zsafe/export.xpm" #include "pics/zsafe/import.xpm" #include "pics/zsafe/zsafe.xpm" static const char* const bank_cards_data[] = { "14 14 16 1", ". c None", "# c #000000", "b c #0000de", "a c #0000e6", "j c #41de83", "k c #4acecd", "h c #4aced5", "g c #5a40cd", "d c #5a44d5", "l c #9440d5", "m c #b4ce4a", "n c #cd4883", "e c #d5ae10", "f c #de3ce6", "i c #e640e6", "c c #ffffff", "..............", ".###########..", ".#ababababa#..", ".#babbbabbb#..", ".#ccccccccc#..", ".#cdcefcghc#..", ".#ccccccccc#..", ".#cicjkclic#..", ".#ccccccccc#..", ".#cmchlcnec#..", ".#ccccccccc#..", ".###########..", "..............", ".............."}; static const char* const passwords_data[] = { "16 16 20 1", ". c None", "# c #000000", "r c #000083", "p c #0000c5", "q c #0000ff", "n c #008100", "l c #00c200", "m c #00ff00", "j c #838100", "a c #c55900", "h c #c5c200", "o c #c5c2ff", "k c #c5ffc5", "f c #ff0000", "d c #ff8100", "b c #ffaa5a", "e c #ffc2c5", "c c #ffdeac", "i c #ffff00", "g c #ffffc5", "............###.", "...........#abb#", "..........#cbab#", ".........#cbdd#.", "######..#cbdd#..", "#eeff#..#add#...", "#eeff#######....", "#ccdbdd#........", "#dddbdd###......", "#gghihhjj#......", "#hhhihhjj###....", "#kklmllnnnn#....", "#lllmllnnnn#....", "#oopqpprprr#....", "#oopqpprprr#....", "############...."}; static const char* const software_data[] = { "16 16 5 1", ". c None", "# c #000000", "b c #838183", "c c #c5ffff", "a c #ffffff", "................", ".##############.", "#aaaaaaaaaaaaaa#", "#abbbbbbbbbbbbb#", "#ab##########ab#", "#ab#c########ab#", "#ab#c#c######ab#", "#ab##########ab#", |