summaryrefslogtreecommitdiff
path: root/noncore/apps
Side-by-side diff
Diffstat (limited to 'noncore/apps') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp44
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro24
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp12
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp1681
-rw-r--r--noncore/apps/advancedfm/filePermissions.cpp2
-rw-r--r--noncore/apps/advancedfm/output.cpp23
-rw-r--r--noncore/apps/checkbook/checkbook.pro2
-rw-r--r--noncore/apps/checkbook/listedit.cpp11
-rw-r--r--noncore/apps/checkbook/tabledef.cpp6
-rw-r--r--noncore/apps/checkbook/transaction.cpp6
-rw-r--r--noncore/apps/confedit/confedit.pro24
-rw-r--r--noncore/apps/confedit/config.in2
-rw-r--r--noncore/apps/confedit/listviewconfdir.cpp12
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp24
-rw-r--r--noncore/apps/confedit/mainwindow.cpp19
-rw-r--r--noncore/apps/keyz-cfg/cfgfile.cpp12
-rw-r--r--noncore/apps/keyz-cfg/config.in2
-rw-r--r--noncore/apps/keyz-cfg/keyz-cfg.pro16
-rw-r--r--noncore/apps/keyz-cfg/zkb.cpp4
-rw-r--r--noncore/apps/keyz-cfg/zkbcfg.cpp15
-rw-r--r--noncore/apps/opie-bartender/bartender.cpp35
-rw-r--r--noncore/apps/opie-bartender/bartender.pro7
-rw-r--r--noncore/apps/opie-bartender/config.in3
-rw-r--r--noncore/apps/opie-console/MyPty.cpp14
-rw-r--r--noncore/apps/opie-console/TEWidget.cpp6
-rw-r--r--noncore/apps/opie-console/TEmulation.cpp8
-rw-r--r--noncore/apps/opie-console/atconfigdialog.cpp13
-rw-r--r--noncore/apps/opie-console/dialer.cpp27
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp14
-rw-r--r--noncore/apps/opie-console/emulation_widget.cpp10
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp9
-rw-r--r--noncore/apps/opie-console/io_bt.cpp7
-rw-r--r--noncore/apps/opie-console/io_irda.cpp8
-rw-r--r--noncore/apps/opie-console/io_modem.cpp8
-rw-r--r--noncore/apps/opie-console/main.cpp2
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp39
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp11
-rw-r--r--noncore/apps/opie-console/opie-console.pro4
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp6
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp7
-rw-r--r--noncore/apps/opie-console/terminalwidget.cpp11
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp14
-rw-r--r--noncore/apps/opie-console/widget.cpp6
-rw-r--r--noncore/apps/opie-console/widget_layer.cpp4
-rw-r--r--noncore/apps/opie-write/mainwindow.cpp12
-rw-r--r--noncore/apps/opie-write/opie-write.pro3
-rw-r--r--noncore/apps/opie-write/qcomplextext.cpp4
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp28
-rw-r--r--noncore/apps/opie-write/qrichtext_p.cpp15
-rwxr-xr-xnoncore/apps/qashmoney/accountdisplay.cpp13
-rw-r--r--noncore/apps/qashmoney/config.in2
-rwxr-xr-xnoncore/apps/qashmoney/qashmoney.pro2
-rw-r--r--noncore/apps/tableviewer/db/common.cpp28
-rw-r--r--noncore/apps/tableviewer/db/datacache.cpp12
-rw-r--r--noncore/apps/tableviewer/db/xmlsource.cpp30
-rw-r--r--noncore/apps/tableviewer/tableviewer.cpp14
-rw-r--r--noncore/apps/tableviewer/tableviewer.pro8
-rw-r--r--noncore/apps/tableviewer/ui/tvlistview.cpp9
-rw-r--r--noncore/apps/tinykate/libkate/libkate.pro147
-rw-r--r--noncore/apps/tinykate/tinykate.pro26
-rw-r--r--noncore/apps/zsafe/config.in2
-rw-r--r--noncore/apps/zsafe/scqtfiledlg.cpp29
-rw-r--r--noncore/apps/zsafe/zsafe.cpp15
-rw-r--r--noncore/apps/zsafe/zsafe.pro14
64 files changed, 1360 insertions, 1267 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index a60d6ce..a47edd8 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,479 +1,479 @@
/***************************************************************************
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");
+// owarn << "tab changed" << oendl;
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");
+// owarn << "PopulateView" << oendl;
QPixmap pm;
QListView *thisView = CurrentView();
QDir *thisDir = CurrentDir();
QString path = thisDir->canonicalPath();
-//qWarning("path is "+path);
+//owarn << "path is "+path << oendl;
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");
+ // odebug << " overlay link image" << oendl;
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);
+// odebug << mydirent->d_name << oendl;
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);
+// // odebug << "" << tmpTab << "" << oendl;
// for(int i =1; i < 3; i++) {
// TabWidget->setCurrentWidget(i - 1);
// populateView();
// }
// TabWidget->setCurrentWidget( tmpTab - 1);
}
void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
-//qWarning("listclicked");
+//owarn << "listclicked" << oendl;
if(selectedItem) {
QString strItem=selectedItem->text(0);
-// qWarning(strItem);
+// owarn << strItem << oendl;
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
bool isDirectory = false;
QString strItem2;
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
strItem2 = dealWithSymName((const QString&)strItem);
if(QDir(strItem2).exists() )
strItem = strItem2;
}
if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
if(QDir(strItem).exists())
isDirectory = true;
}
if( isDirectory ) {
CurrentDir()->cd( strItem, TRUE);
populateView();
CurrentView()->ensureItemVisible( CurrentView()->firstChild());
}
chdir( strItem.latin1());
}
}
void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
dealWithSchmooSchmaa( item->listView());
switch (mouse) {
case 1:
{
if(renameBox != 0 ) {
cancelRename();
}
}
break;
case 2:
menuTimer.start( 500, TRUE );
break;
};
}
void AdvancedFm::switchToLocalTab() {
-//qWarning("switch to local view");
+//owarn << "switch to local view" << oendl;
TabWidget->setCurrentWidget(0);
Local_View->setFocus();
}
void AdvancedFm::switchToRemoteTab() {
-//qWarning("switch to local view");
+//owarn << "switch to local view" << oendl;
TabWidget->setCurrentWidget(1);
Remote_View->setFocus();
}
void AdvancedFm::readConfig() {
Config cfg("AdvancedFm");
}
void AdvancedFm::writeConfig() {
Config cfg("AdvancedFm");
}
void AdvancedFm::currentPathComboChanged() {
if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
populateView();
} else {
QMessageBox::message(tr("Note"),tr("That directory does not exist"));
}
}
void AdvancedFm::fillCombo(const QString &currentPath) {
if ( whichTab == 1) {
currentPathCombo->lineEdit()->setText( currentPath);
if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
localDirPathStringList.prepend( currentPath );
currentPathCombo->insertStringList( localDirPathStringList,-1);
}
} else {
currentPathCombo->lineEdit()->setText( currentPath);
if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
remoteDirPathStringList.prepend( currentPath );
currentPathCombo->insertStringList( remoteDirPathStringList,-1);
}
}
}
void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
chdir( currentPath.latin1() );
CurrentDir()->cd( currentPath, TRUE);
populateView();
update();
}
QStringList AdvancedFm::getPath() {
QStringList strList;
QListView *thisView=CurrentView();
QList<QListViewItem> * getSelectedItems( QListView * thisView );
QListViewItemIterator it( thisView );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
strList << it.current()->text(0);
-// qDebug(it.current()->text(0));
+// odebug << it.current()->text(0) << oendl;
}
}
return strList;
}
void AdvancedFm::homeButtonPushed() {
QString current = QDir::homeDirPath();
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
void AdvancedFm::docButtonPushed() {
QString current = QPEApplication::documentDir();
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
void AdvancedFm::SDButtonPushed() {
QString current = "/mnt/card";// this can change so fix
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
void AdvancedFm::CFButtonPushed() {
QString current;
if(zaurusDevice)
current= "/mnt/cf"; //zaurus
else
current = "/mnt/hda"; //ipaq
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
void AdvancedFm::doAbout() {
QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
"is copyright 2002-2003 by\n"
"L.J.Potter<llornkcor@handhelds.org>\n"
"and is licensed by the GPL"));
}
void AdvancedFm::keyPressEvent( QKeyEvent *e) {
-// qWarning("key %d", e->key());
+// owarn << "key " << e->key() << "" << oendl;
// if( CurrentView()->hasFocus() )
{
switch ( e->key() ) {
case Key_Left:
upDir();
break;
case Key_Next:
break;
case Key_Return:
case Key_Enter:
navigateToSelected();
break;
case Key_Tab: {
setOtherTabCurrent();
}
break;
case Key_Delete:
del();
break;
case Key_A:
copyAs();
break;
case Key_C:
copy();
break;
case Key_E:
runThis();
break;
case Key_G:
{
currentPathCombo->lineEdit()->setFocus();
}
break;
case Key_H:
showHidden();
break;
case Key_I:
fileStatus();
break;
case Key_M:
move();
break;
case Key_N:
mkDir();
break;
case Key_P:
filePerms();
break;
case Key_R:
rn();
break;
case Key_U:
upDir();
break;
case Key_1:
switchToLocalTab();
break;
case Key_2:
switchToRemoteTab();
break;
case Key_3:
CFButtonPushed();
break;
case Key_4:
SDButtonPushed();
break;
case Key_5:
homeButtonPushed();
break;
case Key_6:
docButtonPushed();
break;
case Key_7:
break;
case Key_8:
break;
case Key_9:
break;
case Key_0:
break;
};
e->accept();
}
}
void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
if( CurrentView()->hasFocus() )
e->ignore();
}
void AdvancedFm::QPEButtonPushed() {
QString current = QPEApplication::qpeDir();
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
@@ -545,341 +545,341 @@ void AdvancedFm::showFileMenu() {
MimeType mt( curApp );
const AppLnk* app = mt.application();
QFile fi(curApp);
QPopupMenu *m = new QPopupMenu(0);
QPopupMenu *n = new QPopupMenu(0);
// QPopupMenu *o = new QPopupMenu(0);
m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
if ( QFileInfo(fi).isDir() ) {
m->insertSeparator();
m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
} else {
if ( app )
m->insertItem( app->pixmap(), tr( "Open in "
+ app->name() ), this, SLOT( runThis() ) );
else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
}
m->insertItem(tr("Actions"),n);
n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
n->insertSeparator();
n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
n->insertItem( tr( "Move" ), this, SLOT( move() ));
n->insertSeparator();
n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
m->insertSeparator();
m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
#if defined(QT_QWS_OPIE)
m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
#endif
m->setCheckable(TRUE);
if (!b)
m->setItemChecked(m->idAt(0),TRUE);
else
m->setItemChecked(m->idAt(0),FALSE);
if(Ir::supported())
m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
if(m) delete m;
}
void AdvancedFm::cancelMenuTimer() {
if( menuTimer.isActive() )
menuTimer.stop();
}
QString AdvancedFm::checkDiskSpace(const QString &path) {
struct statfs fss;
if ( !statfs( path.latin1(), &fss ) ) {
int blkSize = fss.f_bsize;
// int totalBlks = fs.f_blocks;
int availBlks = fss.f_bavail;
long mult = blkSize / 1024;
long div = 1024 / blkSize;
if ( !mult ) mult = 1;
if ( !div ) div = 1;
return QString::number(availBlks * mult / div);
}
return "";
}
void AdvancedFm::addToDocs() {
QStringList strListPaths = getPath();
QDir *thisDir = CurrentDir();
if( strListPaths.count() > 0) {
QString curFile;
for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
curFile = thisDir->canonicalPath()+"/"+(*it);
-// qDebug(curFile);
+// odebug << curFile << oendl;
QFileInfo fi(curFile);
DocLnk f;
// curFile.replace(QRegExp("\\..*"),"");
f.setName(fi.baseName() );
f.setFile( curFile);
f.writeLink();
}
}
}
void AdvancedFm::customDirsToMenu() {
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QStringList list = cfg.readListEntry( "CustomDir", ',');
menuButton->insertItems(list );
// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
// {
// customDirMenu->insertItem(*it );
// }
}
void AdvancedFm::dirMenuSelected(int item) {
switch(item)
{
case -21:
case 0:
addCustomDir();
break;
case -22:
case 1:
removeCustomDir();
break;
default:
{
// gotoCustomDir( menuButton->text(item));
// gotoCustomDir( customDirMenu->text(item));
}
break;
};
}
void AdvancedFm::addCustomDir() {
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QString dir;
QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
dir = CurrentDir()->canonicalPath();
bool addIt=true;
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
if( dir == (*it)) {
addIt=false;
}
}
if(addIt) {
menuButton->insertItem(dir);
// customDirMenu->insertItem(dir);
list << dir;
}
cfg.writeEntry("CustomDir", list, ',');
cfg.write();
}
void AdvancedFm::removeCustomDir() {
-// qDebug("remove custom dir");
+// odebug << "remove custom dir" << oendl;
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QString dir;
QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
QStringList list2;
dir = CurrentDir()->canonicalPath();
int ramble=2;
// int ramble=-24;
//first remove list
if(list.grep(dir,true).isEmpty()) {
QMessageBox::message(tr( "AdvancedFm" ),
tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
} else {
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
if((*it) != dir) {
//current item is not our current dir, so add it to temp list
list2 <<(*it);
} else {
// customDirMenu->removeItem( ramble);
menuButton->remove( ramble);
}
ramble++;
// ramble--;
}
cfg.writeEntry("CustomDir", list2, ',');
cfg.write();
}
// customDirsToMenu();
}
void AdvancedFm::gotoCustomDir(const QString &dir) {
-// qDebug("gotoCustomDir(const QString &dir) " +dir );
+// odebug << "gotoCustomDir(const QString &dir) " +dir << oendl;
// QString curDir = dir;
// QDir *thisDir = CurrentDir();
// if( curDir.isEmpty()) {
// }
if( dir == s_addBookmark) {
addCustomDir();
}
if( dir == s_removeBookmark) {
removeCustomDir( );
} else {
gotoDirectory( dir);
// if(QDir( curDir).exists() )
// {
// thisDir->setPath( curDir );
// chdir( curDir.latin1() );
// thisDir->cd( curDir, TRUE);
// populateView();
// }
}
}
QDir *AdvancedFm::CurrentDir() {
if ( whichTab == 1) {
return &currentDir;
} else {
return &currentRemoteDir;
}
}
QDir *AdvancedFm::OtherDir() {
if ( whichTab == 1) {
return &currentRemoteDir;
} else {
return &currentDir;
}
}
QListView * AdvancedFm::CurrentView() {
if ( whichTab == 1) {
-// qWarning("CurrentView Tab 1");
+// owarn << "CurrentView Tab 1" << oendl;
return Local_View;
} else {
-// qWarning("CurrentView Tab 2");
+// owarn << "CurrentView Tab 2" << oendl;
return Remote_View;
}
}
QListView * AdvancedFm::OtherView() {
if ( whichTab == 1)
return Remote_View;
else
return Local_View;
}
void AdvancedFm::setOtherTabCurrent() {
-// qWarning("setOtherTabCurrent() %d", whichTab);
+// owarn << "setOtherTabCurrent() " << whichTab << "" << oendl;
if ( whichTab == 1) {
TabWidget->setCurrentWidget(1);
} else {
TabWidget->setCurrentWidget(0);
}
OtherView()->setFocus();
OtherView()->setSelected( CurrentView()->firstChild(), true);
}
void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
-// qDebug("qcop message "+msg );
+// odebug << "qcop message "+msg << oendl;
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "openDirectory(QString)" ) {
-// qDebug("received");
+// odebug << "received" << oendl;
QString file;
stream >> file;
gotoDirectory( (const QString &) file);
}
}
void AdvancedFm::setDocument(const QString &file) {
gotoDirectory( file);
}
void AdvancedFm::gotoDirectory(const QString &file) {
-// qWarning("goto dir "+file);
+// owarn << "goto dir "+file << oendl;
QString curDir = file;
QDir *thisDir = CurrentDir();
if(QDir( curDir).exists() ) {
thisDir->setPath( curDir );
chdir( curDir.latin1() );
thisDir->cd( curDir, TRUE);
populateView();
}
else if(QFileInfo(curDir).exists()) {
QFileInfo fileInfo(curDir);
curDir=fileInfo.dirPath();
if(QDir( curDir).exists() ) {
thisDir->setPath( curDir );
chdir( curDir.latin1() );
thisDir->cd( curDir, TRUE);
populateView();
}
findFile(file);
}
}
void AdvancedFm::findFile(const QString &fileName) {
QFileInfo fi(fileName);
QListView *thisView = CurrentView();
QListViewItemIterator it( thisView );
for ( ; it.current(); ++it ) {
if(it.current()->text(0) == fi.fileName()) {
it.current()->setSelected(true);
thisView->ensureItemVisible(it.current());
}
}
}
void AdvancedFm::slotSwitchMenu(int ) {
-// qDebug("Switch %d", item);
+// odebug << "Switch " << item << "" << oendl;
// viewMenu->setItemChecked(item, true);
}
void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
tabChanged( w);
if( w == Local_View) {
Remote_View->clearFocus();
} else {
Local_View->clearFocus();
}
}
void AdvancedFm::navigateToSelected() {
if( !CurrentView()->currentItem()) return;
doDirChange();
}
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index 716343d..f1c518e 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,35 +1,15 @@
TEMPLATE = app
-CONFIG += qt warn_on quick-app
-# CONFIG += qt warn_on
+CONFIG += qt warn_on quick-app
HEADERS = advancedfm.h filePermissions.h output.h
SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp
TARGET = advancedfm
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopiecore2 -lopieui2
-
-TRANSLATIONS = ../../../i18n/de/advancedfm.ts \
- ../../../i18n/nl/advancedfm.ts \
- ../../../i18n/da/advancedfm.ts \
- ../../../i18n/xx/advancedfm.ts \
- ../../../i18n/en/advancedfm.ts \
- ../../../i18n/es/advancedfm.ts \
- ../../../i18n/fr/advancedfm.ts \
- ../../../i18n/hu/advancedfm.ts \
- ../../../i18n/ja/advancedfm.ts \
- ../../../i18n/ko/advancedfm.ts \
- ../../../i18n/no/advancedfm.ts \
- ../../../i18n/pl/advancedfm.ts \
- ../../../i18n/pt/advancedfm.ts \
- ../../../i18n/pt_BR/advancedfm.ts \
- ../../../i18n/sl/advancedfm.ts \
- ../../../i18n/zh_CN/advancedfm.ts \
- ../../../i18n/zh_TW/advancedfm.ts
-
+LIBS += -lqpe -lopiecore2 -lopieui2
!contains(CONFIG,quick-app) {
DESTDIR = $(OPIEDIR)/bin
DEFINES += NOQUICKLAUNCH
}
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index 2997c55..29335f8 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -1,290 +1,294 @@
/***************************************************************************
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"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/storage.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/menubutton.h>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+/* QT */
#include <qlayout.h>
#include <qhbox.h>
#include <qmenubar.h>
#include <qcombobox.h>
#include <qtoolbutton.h>
#include <qlineedit.h>
#include <qlistview.h>
+/* STD */
#include <sys/utsname.h>
-
-using namespace Opie::Ui;
void AdvancedFm::init() {
b = false;
setCaption( tr( "AdvancedFm" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 2);
layout->setMargin( 0); // squeeze
QMenuBar *menuBar = new QMenuBar(this);
menuBar->setMargin( 0 ); // squeeze
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 );
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();
QHBoxLayout *CBHB = new QHBoxLayout(); // parent layout will be set later
CBHB->setMargin( 0 );
CBHB->setSpacing( 1 );
menuButton = new MenuButton( this );
menuButton->setUseLabel(false);
menuButton->setMaximumWidth( 20 );
menuButton->insertItem( s_addBookmark);
menuButton->insertItem( s_removeBookmark);
menuButton->insertSeparator();
menuButton->setFocusPolicy(NoFocus);
CBHB->addWidget( menuButton );
customDirsToMenu();
currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
currentPathCombo->setEditable(TRUE);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
currentPathCombo->setFocusPolicy(NoFocus);
CBHB->addWidget( currentPathCombo );
layout->addLayout( CBHB );
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");
+ odebug << "not have sd" << oendl;
sdButton->hide();
}
if( !StorageInfo::hasCf() ) {
- qDebug("not have cf");
+ odebug << "not have cf" << oendl;
cfButton->hide();
}
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
currentDir.setPath( QDir::currentDirPath());
currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
currentRemoteDir.setPath( QDir::currentDirPath());
// b = TRUE;
filterStr="*";
showMenuHidden();
TabWidget->setCurrentWidget(0);
}
void AdvancedFm::initConnections()
{
connect( qApp,SIGNAL( aboutToQuit()),
this, SLOT( cleanUp()) );
connect( qpeDirButton ,SIGNAL(released()),
this,SLOT( QPEButtonPushed()) );
connect( cfButton ,SIGNAL(released()),
this,SLOT( CFButtonPushed()) );
connect( sdButton ,SIGNAL(released()),
this,SLOT( SDButtonPushed()) );
connect( cdUpButton ,SIGNAL(released()),
this,SLOT( upDir()) );
connect( docButton,SIGNAL(released()),
this,SLOT( docButtonPushed()) );
connect( homeButton,SIGNAL(released()),
this,SLOT( homeButtonPushed()) );
connect( currentPathCombo, SIGNAL( activated(const QString&) ),
this, SLOT( currentPathComboActivated(const QString&) ) );
connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
this,SLOT(currentPathComboChanged()));
connect( Local_View, SIGNAL( clicked(QListViewItem*)),
this,SLOT( ListClicked(QListViewItem*)) );
connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) );
connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) );
connect( Remote_View, SIGNAL( clicked(QListViewItem*)),
this,SLOT( ListClicked(QListViewItem*)) );
connect( Remote_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) );
connect( TabWidget,SIGNAL(currentChanged(QWidget*)),
this,SLOT(tabChanged(QWidget*)));
connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
connect( menuButton, SIGNAL( selected(const QString&)), SLOT(gotoCustomDir(const QString&)));
// connect( menuButton, SIGNAL( selected(int)), SLOT( dirMenuSelected(int)));
connect( viewMenu, SIGNAL( activated(int)), this, SLOT(slotSwitchMenu(int)));
// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int)));
}
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 81a4318..d34f330 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,839 +1,842 @@
-/***************************************************************************
- 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 ) {
- filePermissions *filePerm;
- filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
- QPEApplication::execDialog( filePerm );
- if( filePerm )
- delete filePerm;
- }
- populateView();
-}
-
-void AdvancedFm::doProperties() {
-#if defined(QT_QWS_OPIE)
-
- QStringList curFileList = getPath();
-
- QString filePath;
- filePath = CurrentDir()->canonicalPath()+"/";
-
-// qDebug("%d",curFileList.count());
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
-// qDebug((filePath+*it));
- DocLnk lnk( (filePath+*it));
- LnkProperties prop( &lnk );
- QPEApplication::execDialog( &prop );
- }
-#endif
-
-}
-
-void AdvancedFm::upDir() {
- QDir *thisDir = CurrentDir();
- QString current = thisDir->canonicalPath();
- QDir dir(current);
- dir.cdUp();
- current = dir.canonicalPath();
- chdir( current.latin1() );
- thisDir->cd( current, TRUE);
-
- populateView();
- update();
-}
-
-void AdvancedFm::copy() {
- qApp->processEvents();
- QStringList curFileList = getPath();
-
- QDir *thisDir = CurrentDir();
- QDir *thatDir = OtherDir();
-
- bool doMsg=true;
- int count=curFileList.count();
- if( count > 0) {
- if(count > 1 ){
- QString msg;
- msg=tr("Really copy\n%1 files?").arg(count);
- switch ( QMessageBox::warning(this,tr("Copy"),msg
- ,tr("Yes"),tr("No"),0,0,1) )
- {
- case 0:
- doMsg=false;
- break;
- case 1:
- return;
- break;
- };
- }
-
- QString curFile, item, destFile;
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- item=(*it);
- if(item.find("->",0,TRUE)) //symlink
- item = item.left(item.find("->",0,TRUE));
-
- curFile = thisDir->canonicalPath()+"/"+ item;
- destFile = thatDir->canonicalPath()+"/"+ item;
-
-// qDebug("Destination file is "+destFile);
-// qDebug("CurrentFile file is " + curFile);
-
- QFile f(destFile);
- if( f.exists()) {
- if(doMsg) {
- switch ( QMessageBox::warning(this,tr("File Exists!"),
- tr("%1 exists. Ok to overwrite?").arg( item ),
- tr("Yes"),tr("No"),0,0,1) ) {
- case 1:
- return;
- break;
- };
- }
- f.remove();
- }
-
- if( !copyFile( curFile, destFile) ) {
- QMessageBox::message("AdvancedFm",
- tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
- return;
- }
- }
- setOtherTabCurrent();
- rePopulate();
- }
-}
-
-void AdvancedFm::copyAs() {
- qApp->processEvents();
-
- QStringList curFileList = getPath();
- QString curFile, item;
- InputDialog *fileDlg;
-
- QDir *thisDir = CurrentDir();
- QDir *thatDir = OtherDir();
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- QString destFile;
- item=(*it);
- curFile = thisDir->canonicalPath()+"/"+(*it);
- fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
-
- fileDlg->setInputText((const QString &) destFile );
- fileDlg->exec();
-
- if( fileDlg->result() == 1 ) {
- QString filename = fileDlg->LineEdit1->text();
- destFile = thatDir->canonicalPath()+"/"+filename;
-
- QFile f( destFile);
- if( f.exists()) {
- switch (QMessageBox::warning(this,tr("File Exists!"),
- item+tr("\nexists. Ok to overwrite?"),
- tr("Yes"),tr("No"),0,0,1) ) {
- case 0:
- f.remove();
- break;
- case 1:
- return;
- break;
- };
- }
- if( !copyFile( curFile, destFile) ) {
- QMessageBox::message("AdvancedFm",tr("Could not copy\n")
- +curFile +tr("to\n")+destFile);
- return;
- }
- }
- delete fileDlg;
-
- }
- rePopulate();
- setOtherTabCurrent();
-}
-
-void AdvancedFm::copySameDir() {
- qApp->processEvents();
- QStringList curFileList = getPath();
- QString curFile, item, destFile;
- InputDialog *fileDlg;
-
- QDir *thisDir = CurrentDir();
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- item=(*it);
- curFile = thisDir->canonicalPath()+"/"+ item;
-
- fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
- fileDlg->setInputText((const QString &) destFile );
- fileDlg->exec();
-
- if( fileDlg->result() == 1 ) {
-
- QString filename = fileDlg->LineEdit1->text();
- destFile = thisDir->canonicalPath()+"/"+filename;
-
- QFile f(destFile);
- if( f.exists()) {
- switch (QMessageBox::warning(this,tr("Delete"),
- destFile+tr(" already exists.\nDo you really want to delete it?"),
- tr("Yes"),tr("No"),0,0,1) ) {
- case 0:
-
- f.remove();
- break;
- case 1:
- return;
- break;
- };
- }
- if(!copyFile( curFile,destFile) ) {
- QMessageBox::message("AdvancedFm",tr("Could not copy\n")
- +curFile +tr("to\n")+destFile);
- return;
- }
-
-// qDebug("copy "+curFile+" as "+destFile);
- }
- delete fileDlg;
- }
- rePopulate();
-}
-
-void AdvancedFm::move() {
- qApp->processEvents();
-
- QStringList curFileList = getPath();
- if( curFileList.count() > 0) {
- QString curFile, destFile, item;
-
- QDir *thisDir = CurrentDir();
- QDir *thatDir = OtherDir();
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- item=(*it);
- QString destFile = thatDir->canonicalPath();
-
- if(destFile.right(1).find("/",0,TRUE) == -1)
- destFile+="/";
- destFile += item;
-// qDebug("Destination file is "+destFile);
-
- curFile = thisDir->canonicalPath();
- if(curFile.right(1).find("/",0,TRUE) == -1)
- curFile +="/";
- curFile+= item;
-// qDebug("CurrentFile file is " + curFile);
-
- if(QFileInfo(curFile).isDir()) {
- moveDirectory( curFile, destFile );
- rePopulate();
- return;
- }
-
- QFile f( curFile);
- if( f.exists()) {
- if( !copyFile( curFile, destFile) ) {
- QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
- return;
- } else
- QFile::remove(curFile);
- }
- }
-
- }
- rePopulate();
- setOtherTabCurrent();
-}
-
-bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
- int err = 0;
- if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
- err = system((const char*)cmd);
- } else
- err = -1;
-
- if(err!=0) {
- QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
- return false;
- }
- return true;
-}
-
-bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
-
- QString cmd = "/bin/cp -fpR " + src + " " + dest;
- qWarning(cmd);
- int err = system( (const char *) cmd );
- if ( err != 0 ) {
- QMessageBox::message("AdvancedFm",
- tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
- return false;
- }
-
- return true;
-}
-
-
-bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
-
-
- if(QFileInfo(src).isDir()) {
- if( copyDirectory( src, dest )) {
- setOtherTabCurrent();
- populateView();
- return true;
- }
- else
- return false;
- }
-
-
- 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(Opie::Core::OProcess*)),
- this, SLOT( processEnded(Opie::Core::OProcess*)));
-
- connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
- this, SLOT( oprocessStderr(Opie::Core::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( !renameBox) 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 = "";
- QListViewItem *item = view->currentItem();
- view->takeItem( item );
- delete item;
- rePopulate();
-}
-
-void AdvancedFm::openSearch() {
- QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
-}
+/***************************************************************************
+ 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"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/lnkproperties.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/applnk.h>
+using namespace Opie::Core;
+
+/* QT*/
+
+#include <qmessagebox.h>
+#include <qpopupmenu.h>
+#include <qlistview.h>
+
+/* STD */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <sys/sendfile.h>
+#include <fcntl.h>
+
+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)+"/";
+// owarn << pathItem << oendl;
+ 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);
+// odebug << fileInfo.owner() << oendl;
+
+ 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();
+// odebug << execStr << oendl;
+ 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) {
+// odebug << "remove link files "+myFile << oendl;
+
+// DocLnk lnk(f);
+ DocLnk *lnk;
+ lnk = new DocLnk(f);
+// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
+ 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 ) {
+ filePermissions *filePerm;
+ filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
+ QPEApplication::execDialog( filePerm );
+ if( filePerm )
+ delete filePerm;
+ }
+ populateView();
+}
+
+void AdvancedFm::doProperties() {
+#if defined(QT_QWS_OPIE)
+
+ QStringList curFileList = getPath();
+
+ QString filePath;
+ filePath = CurrentDir()->canonicalPath()+"/";
+
+// odebug << "" << curFileList.count() << "" << oendl;
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+// odebug << (filePath+*it) << oendl;
+ DocLnk lnk( (filePath+*it));
+ LnkProperties prop( &lnk );
+ QPEApplication::execDialog( &prop );
+ }
+#endif
+
+}
+
+void AdvancedFm::upDir() {
+ QDir *thisDir = CurrentDir();
+ QString current = thisDir->canonicalPath();
+ QDir dir(current);
+ dir.cdUp();
+ current = dir.canonicalPath();
+ chdir( current.latin1() );
+ thisDir->cd( current, TRUE);
+
+ populateView();
+ update();
+}
+
+void AdvancedFm::copy() {
+ qApp->processEvents();
+ QStringList curFileList = getPath();
+
+ QDir *thisDir = CurrentDir();
+ QDir *thatDir = OtherDir();
+
+ bool doMsg=true;
+ int count=curFileList.count();
+ if( count > 0) {
+ if(count > 1 ){
+ QString msg;
+ msg=tr("Really copy\n%1 files?").arg(count);
+ switch ( QMessageBox::warning(this,tr("Copy"),msg
+ ,tr("Yes"),tr("No"),0,0,1) )
+ {
+ case 0:
+ doMsg=false;
+ break;
+ case 1:
+ return;
+ break;
+ };
+ }
+
+ QString curFile, item, destFile;
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ item=(*it);
+ if(item.find("->",0,TRUE)) //symlink
+ item = item.left(item.find("->",0,TRUE));
+
+ curFile = thisDir->canonicalPath()+"/"+ item;
+ destFile = thatDir->canonicalPath()+"/"+ item;
+
+// odebug << "Destination file is "+destFile << oendl;
+// odebug << "CurrentFile file is " + curFile << oendl;
+
+ QFile f(destFile);
+ if( f.exists()) {
+ if(doMsg) {
+ switch ( QMessageBox::warning(this,tr("File Exists!"),
+ tr("%1 exists. Ok to overwrite?").arg( item ),
+ tr("Yes"),tr("No"),0,0,1) ) {
+ case 1:
+ return;
+ break;
+ };
+ }
+ f.remove();
+ }
+
+ if( !copyFile( curFile, destFile) ) {
+ QMessageBox::message("AdvancedFm",
+ tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
+ return;
+ }
+ }
+ setOtherTabCurrent();
+ rePopulate();
+ }
+}
+
+void AdvancedFm::copyAs() {
+ qApp->processEvents();
+
+ QStringList curFileList = getPath();
+ QString curFile, item;
+ InputDialog *fileDlg;
+
+ QDir *thisDir = CurrentDir();
+ QDir *thatDir = OtherDir();
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ QString destFile;
+ item=(*it);
+ curFile = thisDir->canonicalPath()+"/"+(*it);
+ fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
+
+ fileDlg->setInputText((const QString &) destFile );
+ fileDlg->exec();
+
+ if( fileDlg->result() == 1 ) {
+ QString filename = fileDlg->LineEdit1->text();
+ destFile = thatDir->canonicalPath()+"/"+filename;
+
+ QFile f( destFile);
+ if( f.exists()) {
+ switch (QMessageBox::warning(this,tr("File Exists!"),
+ item+tr("\nexists. Ok to overwrite?"),
+ tr("Yes"),tr("No"),0,0,1) ) {
+ case 0:
+ f.remove();
+ break;
+ case 1:
+ return;
+ break;
+ };
+ }
+ if( !copyFile( curFile, destFile) ) {
+ QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+ +curFile +tr("to\n")+destFile);
+ return;
+ }
+ }
+ delete fileDlg;
+
+ }
+ rePopulate();
+ setOtherTabCurrent();
+}
+
+void AdvancedFm::copySameDir() {
+ qApp->processEvents();
+ QStringList curFileList = getPath();
+ QString curFile, item, destFile;
+ InputDialog *fileDlg;
+
+ QDir *thisDir = CurrentDir();
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ item=(*it);
+ curFile = thisDir->canonicalPath()+"/"+ item;
+
+ fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
+ fileDlg->setInputText((const QString &) destFile );
+ fileDlg->exec();
+
+ if( fileDlg->result() == 1 ) {
+
+ QString filename = fileDlg->LineEdit1->text();
+ destFile = thisDir->canonicalPath()+"/"+filename;
+
+ QFile f(destFile);
+ if( f.exists()) {
+ switch (QMessageBox::warning(this,tr("Delete"),
+ destFile+tr(" already exists.\nDo you really want to delete it?"),
+ tr("Yes"),tr("No"),0,0,1) ) {
+ case 0:
+
+ f.remove();
+ break;
+ case 1:
+ return;
+ break;
+ };
+ }
+ if(!copyFile( curFile,destFile) ) {
+ QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+ +curFile +tr("to\n")+destFile);
+ return;
+ }
+
+// odebug << "copy "+curFile+" as "+destFile << oendl;
+ }
+ delete fileDlg;
+ }
+ rePopulate();
+}
+
+void AdvancedFm::move() {
+ qApp->processEvents();
+
+ QStringList curFileList = getPath();
+ if( curFileList.count() > 0) {
+ QString curFile, destFile, item;
+
+ QDir *thisDir = CurrentDir();
+ QDir *thatDir = OtherDir();
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ item=(*it);
+ QString destFile = thatDir->canonicalPath();
+
+ if(destFile.right(1).find("/",0,TRUE) == -1)
+ destFile+="/";
+ destFile += item;
+// odebug << "Destination file is "+destFile << oendl;
+
+ curFile = thisDir->canonicalPath();
+ if(curFile.right(1).find("/",0,TRUE) == -1)
+ curFile +="/";
+ curFile+= item;
+// odebug << "CurrentFile file is " + curFile << oendl;
+
+ if(QFileInfo(curFile).isDir()) {
+ moveDirectory( curFile, destFile );
+ rePopulate();
+ return;
+ }
+
+ QFile f( curFile);
+ if( f.exists()) {
+ if( !copyFile( curFile, destFile) ) {
+ QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
+ return;
+ } else
+ QFile::remove(curFile);
+ }
+ }
+
+ }
+ rePopulate();
+ setOtherTabCurrent();
+}
+
+bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
+ int err = 0;
+ if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
+ err = system((const char*)cmd);
+ } else
+ err = -1;
+
+ if(err!=0) {
+ QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
+ return false;
+ }
+ return true;
+}
+
+bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
+
+ QString cmd = "/bin/cp -fpR " + src + " " + dest;
+ owarn << cmd << oendl;
+ int err = system( (const char *) cmd );
+ if ( err != 0 ) {
+ QMessageBox::message("AdvancedFm",
+ tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
+ return false;
+ }
+
+ return true;
+}
+
+
+bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
+
+
+ if(QFileInfo(src).isDir()) {
+ if( copyDirectory( src, dest )) {
+ setOtherTabCurrent();
+ populateView();
+ return true;
+ }
+ else
+ return false;
+ }
+
+
+ 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)) {
+// owarn << "open failed" << oendl;
+ return success = false;
+ }
+ read_fd = srcFile.handle();
+ if(read_fd != -1) {
+ fstat (read_fd, &stat_buf);
+ if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
+// owarn << "destfile open failed" << oendl;
+ 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;
+// owarn << msg << oendl;
+ }
+ } 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 ) {
+// odebug << fileDlg->LineEdit1->text() << oendl;
+ 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;
+// odebug << cmd << oendl;
+ 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(Opie::Core::OProcess*)),
+ this, SLOT( processEnded(Opie::Core::OProcess*)));
+
+ connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
+ this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
+
+ command << "/bin/sh";
+ command << "-c";
+ command << cmd.latin1();
+ *process << command;
+ if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
+ odebug << "could not start process" << oendl;
+}
+
+void AdvancedFm::processEnded(OProcess *) {
+ rePopulate();
+}
+
+void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
+// owarn << "received stderrt " << buflen << " bytes" << oendl;
+
+ 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() {
+// odebug << "cancel rename" << oendl;
+ 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( !renameBox) 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 = "";
+ QListViewItem *item = view->currentItem();
+ view->takeItem( item );
+ delete item;
+ rePopulate();
+}
+
+void AdvancedFm::openSearch() {
+ QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
+}
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp
index 9698de7..b7d48e8 100644
--- a/noncore/apps/advancedfm/filePermissions.cpp
+++ b/noncore/apps/advancedfm/filePermissions.cpp
@@ -1,131 +1,131 @@
/****************************************************************************
** copyright 2002 ljp ljp@llornkcor.com
** Created: Sat Feb 23 19:44:40 2002 L.J. Potter
**
** 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.
**
****************************************************************************/
#include "filePermissions.h"
#include <qfileinfo.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qmessagebox.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( tr("filePermissions") );
-// qDebug("FilePermissions "+fileName);
+// odebug << "FilePermissions "+fileName << oendl;
/* resize( 236, 210 );
setMaximumSize( QSize( 236, 210 ) );
*/ setCaption( tr( "Set File Permissions" ) );
TextLabel1 = new QLabel( this, "TextLabel1" );
TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
TextLabel1->setText( tr( "Set file permissions for:" ) );
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) );
LineEdit1->setReadOnly(true);
TextLabel4 = new QLabel( this, "TextLabel4" );
TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) );
TextLabel4->setText( tr( "owner" ) );
TextLabel4_2 = new QLabel( this, "TextLabel4_2" );
TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) );
TextLabel4_2->setText( tr( "group" ) );
TextLabel4_3 = new QLabel( this, "TextLabel4_3" );
TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) );
TextLabel4_3->setText( tr( "others" ) );
CheckBox1 = new QCheckBox( this, "CheckBox1" );
CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) );
connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck()));
CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" );
CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) );
connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck()));
CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" );
CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) );
connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck()));
CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" );
CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) );
connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck()));
CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" );
CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) );
connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck()));
CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" );
CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) );
connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck()));
CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" );
CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) );
connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck()));
CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" );
CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) );
connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck()));
CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" );
CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) );
connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck()));
GroupLineEdit = new QLineEdit( this, "GroupLineEdit" );
GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) );
OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" );
OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) );
TextLabel5 = new QLabel( this, "TextLabel5" );
TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) );
TextLabel5->setText( tr( "Owner" ) );
TextLabel5_2 = new QLabel( this, "TextLabel5_2" );
TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) );
TextLabel5_2->setText( tr( "Group" ) );
ModeLine = new QLineEdit( this, "TextLabelMode" );
ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) );
TextLabel3_2 = new QLabel( this, "TextLabel3_2" );
TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) );
TextLabel3_2->setText( tr( "read" ) );
TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" );
TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) );
TextLabel3_2_2->setText( tr( "write" ) );
TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
TextLabel3 = new QLabel( this, "TextLabel3" );
TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) );
TextLabel3->setText( tr( "execute" ) );
TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
struct stat buf;
mode_t mode;
file = fileName;
QFileInfo fi(file);
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 6906298..8c585f4 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,278 +1,281 @@
/****************************************************************************
** outputEdit.cpp
**
** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
****************************************************************************/
#include "output.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
+using namespace Opie::Core;
+/* QT */
#include <qfile.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
+/* STD */
#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());
+// odebug << "count " << cmmds.count() << "" << oendl;
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(Opie::Core::OProcess*)),
this, SLOT( processFinished()));
connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int)));
connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
this, SLOT(commandStderr(Opie::Core::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() );
+ odebug << "" << (*it).latin1() << "" << oendl;
* 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);
+ odebug << filename << oendl;
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");
+ odebug << "Writing doclink did not work" << oendl;
}
} else
- qWarning("Could not write file");
+ owarn << "Could not write file" << oendl;
f.close();
}
}
void Output::commandStdout(OProcess*, char *buffer, int buflen) {
- qWarning("received stdout %d bytes", buflen);
+ owarn << "received stdout " << buflen << " bytes" << oendl;
// 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());
+ owarn << "received stdin " << data.size() << " bytes" << oendl;
// 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);
+ owarn << "received stderrt " << buflen << " bytes" << oendl;
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/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro
index 34641f4..1472df6 100644
--- a/noncore/apps/checkbook/checkbook.pro
+++ b/noncore/apps/checkbook/checkbook.pro
@@ -1,32 +1,32 @@
-CONFIG = qt warn_on quick-app
+CONFIG = qt warn_on quick-app
HEADERS = mainwindow.h \
cbinfo.h \
traninfo.h \
graphinfo.h \
configuration.h \
password.h \
checkbook.h \
transaction.h \
tabledef.h \
listedit.h \
cfg.h \
graph.h
SOURCES = main.cpp \
mainwindow.cpp \
cbinfo.cpp \
traninfo.cpp \
graphinfo.cpp \
configuration.cpp \
password.cpp \
checkbook.cpp \
transaction.cpp \
tabledef.cpp \
listedit.cpp \
cfg.cpp \
graph.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopiecore2 -lopieui2
TARGET = checkbook
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp
index d00e305..5026c9d 100644
--- a/noncore/apps/checkbook/listedit.cpp
+++ b/noncore/apps/checkbook/listedit.cpp
@@ -1,133 +1,138 @@
/*
                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 "listedit.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/resource.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qwidgetstack.h>
#include <qcombobox.h>
#include <qpushbutton.h>
-#include <qpe/resource.h>
-
// --- ListEdit ---------------------------------------------------------------
ListEdit::ListEdit( QWidget *parent, const char *sName )
: QWidget(parent, sName), TableDef(sName)
{
// get font height
int fh = fontMetrics().height();
// create layout
QGridLayout *layout=new QGridLayout(this);
layout->setSpacing( 2 );
layout->setMargin( 4 );
// type table
_typeTable = new QListView( this );
ColumnDef *def=first();
while( def ) {
_typeTable->addColumn( def->getName() );
def=next();
}
connect( _typeTable, SIGNAL( clicked(QListViewItem*,const QPoint&,int) ), this, SLOT( slotClick(QListViewItem*,const QPoint&,int) ) );
layout->addMultiCellWidget(_typeTable, 0,4,0,4);
_currentItem=NULL;
// edit field
_stack=new QWidgetStack( this );
_stack->setMaximumHeight(fh+5);
layout->addMultiCellWidget(_stack, 5,5,0,2);
_typeEdit = new QLineEdit( _stack );
_stack->raiseWidget(_typeEdit );
connect( _typeEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotEditChanged(const QString&) ) );
// combo box
_box=new QComboBox( _stack );
connect( _box, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) );
// add button
QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
layout->addWidget( btn, 5, 3 );
// delete button
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) );
layout->addWidget( btn, 5, 4 );
}
// --- ~ListEdit --------------------------------------------------------------
ListEdit::~ListEdit()
{
}
// --- slotEditTypeChanged ----------------------------------------------------
void ListEdit::slotEditChanged(const QString &str)
{
if( !_currentItem || _currentColumn<0 ) return;
_currentItem->setText(_currentColumn, str);
}
// --- slotAddType ------------------------------------------------------------
void ListEdit::slotAdd()
{
// construct new row
QString args[8];
ColumnDef *pCol=this->first();
int i=0;
while( pCol && i<8 ) {
args[i++]=pCol->getNewValue();
pCol=this->next();
}
_currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] );
// fix uniques
fixTypes();
// display col 0 of new value
QPoint pnt;
slotClick(_currentItem, pnt, 0);
_typeTable->setSelected( _currentItem, true );
// make it selected
_typeEdit->setCursorPosition(0);
_typeEdit->setSelection(0, _typeEdit->text().length() );
}
// --- slotDel -------------------------------------------------------------
void ListEdit::slotDel()
{
if( !_currentItem ) return;
delete _currentItem;
_currentItem=NULL;
_typeEdit->setText("");
_stack->raiseWidget(_typeEdit);
}
@@ -209,136 +214,136 @@ void ListEdit::fixTypes(int iColumn)
bDup=true;
break;
}
iChk++;
}
if( !bDup ) {
*lst.at(iNext)=repl;
break;
}
}
}
}
lst.sort();
// copy back clean up col map
for(int i=0; i<_typeTable->childCount(); i++) {
colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue());
delete colMap[i];
}
delete colMap;
}
void ListEdit::fixTypes()
{
int i;
ColumnDef *pDef;
for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
if( pDef->hasFlag(ColumnDef::typeUnique) )
fixTypes(i);
}
_typeTable->sort();
}
// --- storeInList ------------------------------------------------------------
void ListEdit::storeInList(QStringList &lst)
{
// delete old content
lst.clear();
// add new one
fixTypes();
QListViewItem *itm=_typeTable->firstChild();
while( itm ) {
int i=0;
QString sAdd;
ColumnDef *pDef;
for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
if( i>=1 ) sAdd+=";";
sAdd += itm->text(i);
}
lst.append( sAdd );
itm=itm->nextSibling();
}
}
// --- slotClicked ------------------------------------------------------------
void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col)
{
(void)pnt; // get rid of unused warning;
// save values
_currentItem=itm;
_currentColumn=col;
if( itm==NULL ) {
_typeEdit->setText("");
_stack->raiseWidget(_typeEdit);
return;
}
// display value
if( _currentColumn<0 ) _currentColumn=0;
ColumnDef *pDef=this->at(_currentColumn);
if( pDef->isType(ColumnDef::typeString) ) {
_typeEdit->setText( _currentItem->text(_currentColumn) );
_stack->raiseWidget(_typeEdit);
} else if( pDef->isType(ColumnDef::typeList) ){
_box->clear();
_box->insertStringList( pDef->getValueList() );
QStringList::Iterator itr;
int i=0;
for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) {
if( (*itr)==_currentItem->text(_currentColumn) ) {
_box->setCurrentItem(i);
i=-1;
break;
}
i++;
}
if( i>=0 ) {
_box->insertItem( _currentItem->text(_currentColumn) );
_box->setCurrentItem(i);
}
_stack->raiseWidget(_box);
} else {
- qDebug( "Unsupported column type for column %s", (const char *)pDef->getName() );
+ odebug << "Unsupported column type for column " << (const char *)pDef->getName() << "" << oendl;
_typeEdit->setText("");
_stack->raiseWidget(_typeEdit);
}
}
// --- addColumnDef -----------------------------------------------------------
void ListEdit::addColumnDef(ColumnDef *pDef)
{
_typeTable->addColumn( pDef->getName() );
_vColumns.append(pDef);
}
// --- addData ----------------------------------------------------------------
void ListEdit::addData(QStringList &lst)
{
// run through list
QStringList::Iterator itr;
for(itr=lst.begin(); itr!=lst.end(); itr++) {
QStringList split=QStringList::split(";", *itr, true);
QStringList::Iterator entry;
QString args[8];
int i=0;
for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) {
args[i]= (*entry);
}
while(i<8) {
args[i++]="";
}
new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
}
}
// --- slotActivated ----------------------------------------------------------
void ListEdit::slotActivated(const QString &str)
{
if( _currentItem==NULL || _currentColumn<0 ) return;
_currentItem->setText(_currentColumn, str);
}
diff --git a/noncore/apps/checkbook/tabledef.cpp b/noncore/apps/checkbook/tabledef.cpp
index 9a42308..745cd80 100644
--- a/noncore/apps/checkbook/tabledef.cpp
+++ b/noncore/apps/checkbook/tabledef.cpp
@@ -1,74 +1,76 @@
/*
                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 "tabledef.h"
+#include <opie2/odebug.h>
+using namespace Opie::Core;
// --- ColumnDef --------------------------------------------------------------
ColumnDef::ColumnDef(const char *sName, ColumnType type, const char *sNewValue)
{
_sName=sName;
_type=type;
_sNewValue=sNewValue;
}
// --- addColumnValue ---------------------------------------------------------
void ColumnDef::addColumnValue(const QString &sValue)
{
if( (_type & 0x00ffffff) !=typeList )
- qDebug("Column %s is not a list", (const char *)_sName);
+ odebug << "Column " << (const char *)_sName << " is not a list" << oendl;
else
_valueList.append(sValue);
}
void ColumnDef::addColumnValue(const char *sValue)
{
if( (_type & 0x00ffffff)!=typeList )
- qDebug("Column %s is not a list", (const char *)_sName);
+ odebug << "Column " << (const char *)_sName << " is not a list" << oendl;
else
_valueList.append(sValue);
}
// --- TableDef ---------------------------------------------------------------
TableDef::TableDef(const char *sName)
{
_sName=sName;
_vColumns.setAutoDelete(TRUE);
}
// --- ~TableDef --------------------------------------------------------------
TableDef::~TableDef()
{
}
// --- addColumnDef -----------------------------------------------------------
void TableDef::addColumnDef(ColumnDef *pDef)
{
_vColumns.append(pDef);
}
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
index 1b08b24..aafb588 100644
--- a/noncore/apps/checkbook/transaction.cpp
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -1,131 +1,135 @@
/*
                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 "transaction.h"
#include "traninfo.h"
#include "cfg.h"
#include "checkbook.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/datebookmonth.h>
+using namespace Opie::Core;
+/* QT */
#include <qbuttongroup.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qradiobutton.h>
#include <qwhatsthis.h>
Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname,
TranInfo *info, Cfg *pCfg )
: QDialog( parent, 0, TRUE, WStyle_ContextHelp )
{
QString tempstr = tr( "Transaction for " );
tempstr.append( acctname );
setCaption( tempstr );
_bNew=bNew;
tran = info;
_pCfg=pCfg;
QVBoxLayout *vb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
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 );
// Withdrawal/Deposit
QButtonGroup *btngrp = new QButtonGroup( container );
btngrp->setColumnLayout(0, Qt::Vertical );
btngrp->layout()->setSpacing( 0 );
btngrp->layout()->setMargin( 0 );
btngrp->setMaximumWidth( 220 );
QGridLayout *layout2 = new QGridLayout( btngrp->layout() );
layout2->setSpacing( 2 );
layout2->setMargin( 2 );
withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp );
QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) );
layout2->addWidget( withBtn, 0, 0 );
connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) );
depBtn = new QRadioButton( tr( "Deposit" ), btngrp );
QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) );
layout2->addWidget( depBtn, 0, 1 );
btngrp->setMaximumSize( 320, withBtn->height() );
connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) );
layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 );
// Date
QLabel *label = new QLabel( tr( "Date:" ), container );
QWhatsThis::add( label, tr( "Select date of transaction here." ) );
layout->addWidget( label, 1, 0 );
dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ),
container );
QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) );
QPopupMenu *m1 = new QPopupMenu( container );
datePicker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( datePicker );
dateBtn->setPopup( m1 );
connect( datePicker, SIGNAL( dateClicked(int,int,int) ),
this, SLOT( slotDateChanged(int,int,int) ) );
layout->addWidget( dateBtn, 1, 1 );
// Check number
label = new QLabel( tr( "Number:" ), container );
QWhatsThis::add( label, tr( "Enter check number here." ) );
layout->addWidget( label, 1, 2 );
numEdit = new QLineEdit( container );
QWhatsThis::add( numEdit, tr( "Enter check number here." ) );
numEdit->setMaximumWidth( 40 );
layout->addWidget( numEdit, 1, 3 );
// Description
label = new QLabel( tr( "Description:" ), container );
QWhatsThis::add( label, tr( "Enter description of transaction here." ) );
layout->addWidget( label, 2, 0 );
_cbDesc=new QComboBox( true, container );
_cbDesc->insertStringList( _pCfg->getPayees() );
QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) );
layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 );
connect( _cbDesc, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) );
// Category
label = new QLabel( tr( "Category:" ), container );
QWhatsThis::add( label, tr( "Select transaction category here." ) );
layout->addWidget( label, 3, 0 );
catList = new QComboBox( container );
QWhatsThis::add( catList, tr( "Select transaction category here." ) );
@@ -239,99 +243,99 @@ void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld)
noteEdit->setText( info->notes() );
}
else
{
withBtn->setChecked( TRUE );
}
}
// --- ~Transaction -----------------------------------------------------------
Transaction::~Transaction()
{
}
// --- accept -----------------------------------------------------------------
void Transaction::accept()
{
tran->setDesc( _cbDesc->currentText() );
tran->setDate( datePicker->selectedDate() );
tran->setWithdrawal( withBtn->isChecked() );
tran->setType( typeList->currentText() );
tran->setCategory( catList->currentText() );
bool ok;
tran->setAmount( amtEdit->text().toFloat( &ok ) );
tran->setFee( feeEdit->text().toFloat( &ok ) );
tran->setNumber( numEdit->text() );
tran->setNotes( noteEdit->text() );
QDialog::accept();
}
void Transaction::slotWithdrawalClicked()
{
catList->clear();
CategoryList *pCatList=_pCfg->getCategoryList();
for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) {
if( !pCat->isIncome() )
catList->insertItem( pCat->getName() );
}
catList->setCurrentItem(0);
typeList->clear();
typeList->insertItem( tr( "Debit Charge" ) );
typeList->insertItem( tr( "Written Check" ) );
typeList->insertItem( tr( "Transfer" ) );
typeList->insertItem( tr( "Credit Card" ) );
}
void Transaction::slotDepositClicked()
{
catList->clear();
CategoryList *pCatList=_pCfg->getCategoryList();
for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) {
if( pCat->isIncome() )
catList->insertItem( pCat->getName() );
}
catList->setCurrentItem( 0 );
typeList->clear();
typeList->insertItem( tr( "Written Check" ) );
typeList->insertItem( tr( "Automatic Payment" ) );
typeList->insertItem( tr( "Transfer" ) );
typeList->insertItem( tr( "Cash" ) );
}
// --- slotDateChanged --------------------------------------------------------
void Transaction::slotDateChanged( int y, int m, int d )
{
QDate date;
date.setYMD( y, m, d );
dateBtn->setText( TimeString::shortDate( date ) );
}
// --- slotActivated ----------------------------------------------------------
// Search for the most recent transaction with this description/payee and
// fill amount etc here, as long the new flag is set
void Transaction::slotActivated(const QString &arg )
{
if( !_bNew ) return;
TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList();
if( pTl ) {
TranInfo *pTi=pTl->findMostRecentByDesc( arg );
if( pTi ) {
initFromInfo( pTi, true );
amtEdit->setFocus();
amtEdit->setSelection(0, amtEdit->text().length() );
amtEdit->setCursorPosition(0);
}
}
}
// slotNotNew -----------------------------------------------------------------
void Transaction::slotNotNew()
{
- qDebug("Not new");
+ odebug << "Not new" << oendl;
_bNew=false;
}
diff --git a/noncore/apps/confedit/confedit.pro b/noncore/apps/confedit/confedit.pro
index 5a71680..785c588 100644
--- a/noncore/apps/confedit/confedit.pro
+++ b/noncore/apps/confedit/confedit.pro
@@ -1,21 +1,9 @@
-CONFIG = qt warn_on quick-app
-HEADERS = mainwindow.h listviewconfdir.h listviewitemconffile.h listviewitemconfigentry.h editwidget.h listviewitemconf.h
-SOURCES = main.cpp mainwindow.cpp listviewconfdir.cpp listviewitemconffile.cpp listviewitemconfigentry.cpp editwidget.cpp listviewitemconf.cpp
-INCLUDEPATH += $(OPIEDIR)/include
+CONFIG = qt warn_on quick-app
+HEADERS = mainwindow.h listviewconfdir.h listviewitemconffile.h listviewitemconfigentry.h editwidget.h listviewitemconf.h
+SOURCES = main.cpp mainwindow.cpp listviewconfdir.cpp listviewitemconffile.cpp listviewitemconfigentry.cpp editwidget.cpp listviewitemconf.cpp
+INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-INTERFACES =
-LIBS += -lopiecore2
+LIBS += -lqpe -lopiecore2
TARGET = confedit
-!contains( platform, x11 ) {
-
- include ( $(OPIEDIR)/include.pro )
- LIBS += -lqpe
-}
-
-contains( platform, x11 ) {
- LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
-}
-
-
-
+include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/confedit/config.in b/noncore/apps/confedit/config.in
index e377307..d7682dc 100644
--- a/noncore/apps/confedit/config.in
+++ b/noncore/apps/confedit/config.in
@@ -1,4 +1,4 @@
config CONFEDIT
- boolean "opie-confeditor (generic editor for all Opie settings)"
+ boolean "opie-confedit (generic editor for all Opie settings)"
default "y"
depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp
index 0c2feeb..33bffe1 100644
--- a/noncore/apps/confedit/listviewconfdir.cpp
+++ b/noncore/apps/confedit/listviewconfdir.cpp
@@ -1,61 +1,65 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
#include "listviewconfdir.h"
+#include "listviewitemconffile.h"
-#include <qmessagebox.h>
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
-#include "listviewitemconffile.h"
+/* QT */
+#include <qmessagebox.h>
ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name )
: QListView(parent,name), confDir(settingsPath)
{
setRootIsDecorated( true );
addColumn(tr("Files"));
if (!confDir.isReadable())
QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0);
readConfFiles();
connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
}
ListViewConfDir::~ListViewConfDir()
{
}
void ListViewConfDir::readConfFiles()
{
- confDir.setFilter( QDir::Files | QDir::NoSymLinks );
+ confDir.setFilter( QDir::Files | QDir::NoSymLinks );
confDir.setSorting( QDir::Name );
confDir.setNameFilter("*.conf");
const QFileInfoList *list = confDir.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
ListViewItemConfFile *fileEntry;
while ( (fi=it.current()) )
{
- qDebug( "opening: >%s<", fi->fileName().data() );
+ odebug << "opening: >" << fi->fileName().data() << "<" << oendl;
fileEntry = new ListViewItemConfFile( fi, this );
QListViewItem *dummy = new QListViewItem(fileEntry, "dummy");
++it;
}
}
void ListViewConfDir::expand(QListViewItem *item)
{
((ListViewItemConf*)item)->expand();
}
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp
index 1ff2c44..2958cf5 100644
--- a/noncore/apps/confedit/listviewitemconffile.cpp
+++ b/noncore/apps/confedit/listviewitemconffile.cpp
@@ -1,159 +1,165 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#include "listviewitemconffile.h"
+#include "listviewitemconfigentry.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qmessagebox.h>
#include <qtextstream.h>
-#include "listviewitemconfigentry.h"
#define tr QObject::tr
ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent)
: ListViewItemConf(parent), _valid(false)
{
confFileInfo = file;
-// parseFile();
+ // parseFile();
displayText();
}
ListViewItemConfFile::~ListViewItemConfFile()
{
}
void ListViewItemConfFile::displayText()
{
setText(0,(_changed?"*":"")+confFileInfo->fileName());
}
QString ListViewItemConfFile::fileName()
{
return confFileInfo->fileName();
}
void ListViewItemConfFile::parseFile()
{
- //qDebug("ListViewItemConfFile::parseFile BEGIN");
- QFile confFile(confFileInfo->absFilePath());
+ //odebug << "ListViewItemConfFile::parseFile BEGIN" << oendl;
+ QFile confFile(confFileInfo->absFilePath());
if(! confFile.open(IO_ReadOnly))
QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0);
QTextStream t( &confFile );
QString s;
QString group;
ListViewItemConfigEntry *groupItem;
ListViewItemConfigEntry *item;
while ( !t.atEnd() )
{
s = t.readLine().stripWhiteSpace();
- //qDebug( "line: >%s<\n", s.latin1() );
+ //odebug << "line: >" << s.latin1() << "<\n" << oendl;
if (s.contains("<?xml"))
{
_valid = false;
break;
}else
if ( s[0] == '[' && s[s.length()-1] == ']' )
{
- // qDebug("got group"+s);
+ // odebug << "got group"+s << oendl;
group = s.mid(1,s.length()-2);
if (!groupItem) groupItem = new ListViewItemConfigEntry(this, tr("no group") );
groupItem = new ListViewItemConfigEntry(this, group );
insertItem( groupItem );
} else
if ( int pos = s.find('=') )
{
-// qDebug("got key"+s);
- if (!groupItem) qDebug("PANIK NO GROUP! >%s<",group.latin1());
+// odebug << "got key"+s << oendl;
+ if (!groupItem) odebug << "PANIK NO GROUP! >" << group.latin1() << "<" << oendl;
item = new ListViewItemConfigEntry(this, group, s );
groupItem->insertItem( item );
}
}
confFile.close();
setExpandable( _valid );
-// qDebug("ListViewItemConfFile::parseFile END");
+// odebug << "ListViewItemConfFile::parseFile END" << oendl;
}
void ListViewItemConfFile::remove()
{
QFile::remove(confFileInfo->absFilePath());
QFile::remove(backupFileName());
delete this;
}
void ListViewItemConfFile::revert()
{
if (!_changed)
{
// read the backup file
QFile conf(confFileInfo->absFilePath());
QFile back(backupFileName());
if (!back.open(IO_ReadOnly)) return;
if (!conf.open(IO_WriteOnly)) return;
#define SIZE 124
char buf[SIZE];
while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c);
conf.close();
back.close();
}
parseFile();
expand();
}
void ListViewItemConfFile::save()
{
if (!_changed) return;
QFile conf(confFileInfo->absFilePath());
QFile back(backupFileName());
if (!conf.open(IO_ReadOnly)) return;
if (!back.open(IO_WriteOnly)) return;
char buf[SIZE];
while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c);
conf.close();
back.close();
if (!conf.open(IO_WriteOnly)) return;
QTextStream *t = new QTextStream( &conf );
for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling())
{
((ListViewItemConfigEntry*)it)->save(t);
}
conf.close();
unchanged();
}
bool ListViewItemConfFile::revertable()
{
return _changed || QFile(backupFileName()).exists();
}
QString ListViewItemConfFile::backupFileName()
{
return confFileInfo->absFilePath()+"~";
}
void ListViewItemConfFile::expand()
{
QListViewItem *subItem = firstChild();
QListViewItem *toDel;
while(subItem)
{
toDel = subItem;
subItem = subItem->nextSibling();
delete toDel;
}
parseFile();
}
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index 6ef1043..4b04c97 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -1,189 +1,192 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#include "mainwindow.h"
+#include "listviewconfdir.h"
+#include "listviewitemconfigentry.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
-#include "listviewconfdir.h"
-#include "listviewitemconfigentry.h"
-
-
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0)
{
setCaption( tr("Conf File Editor") );
// setBaseSize( qApp->globalStrut() );
setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
mainLayout = new QVBoxLayout( this );
mainLayout->setSpacing( 0 );
mainLayout->setMargin( 0 );
- qDebug("creating settingList");
+ odebug << "creating settingList" << oendl;
settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist");
settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
mainLayout->addWidget( settingList, 0);
- qDebug("creating editor");
+ odebug << "creating editor" << oendl;
editor = new EditWidget(this);
editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) );
mainLayout->addWidget( editor, 1 );
editor->layoutType( ListViewItemConf::File );
makeMenu();
connect(settingList, SIGNAL( pressed(QListViewItem*) ),
this, SLOT(setCurrent(QListViewItem*)));
connect( settingList, SIGNAL( clicked(QListViewItem*) ),
this, SLOT( stopTimer(QListViewItem*) ) );
connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ),
SLOT( groupChanged(const QString&) ) );
connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
SLOT( keyChanged(const QString&) ) );
connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
SLOT( valueChanged(const QString&) ) );
setCurrent(0);
editor->layoutType(EditWidget::File);
}
void MainWindow::makeMenu()
{
popupTimer = new QTimer(this);
popupMenuFile = new QPopupMenu(this);
popupMenuEntry = new QPopupMenu(this);
popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 );
popupActionSave->addTo( popupMenuFile );
// popupActionSave->addTo( popupMenuEntry );
connect( popupActionSave, SIGNAL( activated() ),
this , SLOT( saveConfFile() ) );
popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 );
popupActionRevert->addTo( popupMenuFile );
popupActionRevert->addTo( popupMenuEntry );
connect( popupActionRevert, SIGNAL( activated() ),
this , SLOT( revertConfFile() ) );
popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 );
popupActionDelete->addTo( popupMenuFile );
popupActionDelete->addTo( popupMenuEntry );
connect( popupActionDelete, SIGNAL( activated() ),
this , SLOT( removeConfFile() ) );
connect( popupTimer, SIGNAL(timeout()),
this, SLOT(showPopup()) );
}
MainWindow::~MainWindow()
{
}
void MainWindow::setCurrent(QListViewItem *item)
{
-// qDebug("MainWindow::setCurrent");
+// odebug << "MainWindow::setCurrent" << oendl;
if (!item) return;
_item = (ListViewItemConf*) item;
if (!_item) return;
popupTimer->start( 750, true );
if (_item->getType() == ListViewItemConf::File)
{
editor->layoutType(EditWidget::File);
_currentItem=0;
_fileItem = (ListViewItemConfFile*)item;
return;
}
_fileItem = 0;
_currentItem = (ListViewItemConfigEntry*)item;
if (!_currentItem) return;
QString file = _currentItem->getFile();
QString group = _currentItem->getGroup();
QString key = _currentItem->getKey();
QString val = _currentItem->getValue();
editor->TextFileName->setText(file);
editor->LineEditGroup->setText(group);
if (!key.isEmpty())
{
editor->layoutType(EditWidget::Entry);
editor->LineEditKey->setText(key);
editor->LineEditValue->setText(val);
}else{
editor->layoutType(EditWidget::Group);
}
}
void MainWindow::groupChanged(const QString &g)
{
if (!_currentItem) return;
_currentItem->setGroup(g);
}
void MainWindow::keyChanged(const QString &k)
{
if (!_currentItem) return;
_currentItem->keyChanged(k);
}
void MainWindow::valueChanged(const QString &v)
{
if (!_currentItem) return;
_currentItem->valueChanged(v);
}
void MainWindow::stopTimer( QListViewItem* )
{
popupTimer->stop();
}
void MainWindow::saveConfFile()
{
if (!_fileItem) return;
_fileItem->save();
}
void MainWindow::revertConfFile()
{
if (!_item) return;
_item->revert();
}
void MainWindow::removeConfFile()
{
if (!_item) return;
_item->remove();
}
void MainWindow::showPopup()
{
-qDebug("showPopup");
+odebug << "showPopup" << oendl;
if (!_item) return;
popupActionRevert->setEnabled(_item->revertable());
popupActionSave->setEnabled(_item->isChanged());
if (_fileItem)
{
popupActionSave->setEnabled(_fileItem->isChanged());
popupMenuFile->popup( QCursor::pos() );
}else if(_currentItem)
{
popupMenuEntry->popup( QCursor::pos() );
}
}
diff --git a/noncore/apps/keyz-cfg/cfgfile.cpp b/noncore/apps/keyz-cfg/cfgfile.cpp
index b0dc968..81d1ee1 100644
--- a/noncore/apps/keyz-cfg/cfgfile.cpp
+++ b/noncore/apps/keyz-cfg/cfgfile.cpp
@@ -1,205 +1,211 @@
-#include <qmessagebox.h>
#include "cfgfile.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
+#include <qmessagebox.h>
+
// CfgEntry implementation
CfgEntry::CfgEntry() {
}
CfgEntry::CfgEntry(const QString& f, const QString& l):
file(f), label(l) {
}
const QString& CfgEntry::getFile() const {
return file;
}
void CfgEntry::setFile(const QString& f) {
file = f;
}
const QString& CfgEntry::getLabel() const {
return label;
}
void CfgEntry::setLabel(const QString& f) {
label = f;
}
// CfgFile implementation
CfgFile::CfgFile():ardelay(400), arperiod(80) {
}
CfgFile::~CfgFile() {
}
QList<CfgEntry>& CfgFile::getEntries() {
return entries;
}
bool CfgFile::replaceEntry(const QString& file, const QString& label, int index) {
deleteEntry(file);
CfgEntry* entry = new CfgEntry(file, label);
if (index >= 0) {
entries.insert(index, entry);
} else {
entries.append(entry);
}
return true;
}
bool CfgFile::deleteEntry(const QString& file) {
for(int i = 0; i < (int) entries.count(); i++) {
CfgEntry* entry = entries.at(i);
if (entry->getFile() == file) {
entries.remove(i);
return true;
}
}
return false;
}
int CfgFile::getAutorepeatDelay() const {
return ardelay;
}
void CfgFile::setAutorepeatDelay(int n) {
ardelay = n;
}
int CfgFile::getAutorepeatPeriod() const {
return arperiod;
}
void CfgFile::setAutorepeatPeriod(int n) {
arperiod = n;
}
// CfgParser implementation
CfgParser::CfgParser() {
}
bool CfgParser::load(QString file, CfgFile& cfg) {
QFile f(file);
QXmlInputSource is(f);
QXmlSimpleReader reader;
CfgHandler p(*this);
reader.setErrorHandler(this);
reader.setContentHandler(&p);
err = "";
ardelay = -1;
arperiod = -1;
reader.parse(is);
if (!err.isEmpty()) {
- qDebug(err);
+ odebug << err << oendl;
return false;
}
QMap<QString, QString>::Iterator fit, lit;
for(uint i = 0; i < includeList.count(); i++) {
QString file = *includeList.at(i);
fit = includes.find(file);
QString prefix = fit.data();
QString label = "";
- qDebug("include: file=" + fit.key() + ", prefix=" + fit.data());
+ odebug << "include: file=" + fit.key() + ", prefix=" + fit.data() << oendl;
lit = labels.find(prefix+":*");
if (lit != labels.end()) {
label = lit.data();
}
cfg.replaceEntry(file, label);
}
if (ardelay != -1) {
cfg.setAutorepeatDelay(ardelay);
}
if (arperiod != -1) {
cfg.setAutorepeatPeriod(arperiod);
}
return true;
}
bool CfgParser::save(QString file, CfgFile& cfg) {
FILE* f = fopen((const char*) file.local8Bit(), "w");
fprintf(f, "<keymap autorepeat-delay=\"%d\" autorepeat-period=\"%d\" "
"author=\"keyzcfg\">\n", cfg.getAutorepeatDelay(),
cfg.getAutorepeatPeriod());
QList<CfgEntry>& entries = cfg.getEntries();
int n;
for(n=0; n < (int) entries.count(); n++) {
CfgEntry* entry = entries.at(n);
QString l = entry->getLabel();
if (!l.isEmpty()) {
fprintf(f, "\t<label name=\"%s\" state=\"km%d:*\"/>\n",
(const char*) l.utf8(), n);
}
}
for(n=0; n < (int) entries.count(); n++) {
CfgEntry* entry = entries.at(n);
fprintf(f, "\t<include file=\"%s\" prefix=\"km%d\"/>\n",
(const char*) entry->getFile().utf8(), n);
}
int k = n-1;
char* states[] = { "LShift", "LShift-Caps", "LShift-Num",
"LShift-Num-Caps", 0};
for(n=0; n < (int) entries.count(); n++) {
QString nstate = "km" + QString::number(n+1);
if (n == k) {
nstate = "km" + QString::number(0);
}
for(int i = 0; states[i] != 0; i++) {
fprintf(f, "\t<state name=\"km%d:%s\">\n",
n, states[i]);
fprintf(f, "\t\t<map keycode=\"Middle\" pressed=\"true\">\n");
fprintf(f, "\t\t\t<next-state name=\"%s:%s\"/>\n",
(const char*) nstate.utf8(), states[i]);
fprintf(f, "\t\t</map>\n\t</state>\n\n");
}
}
fprintf(f, "\t<state name=\"km0:Normal\" default=\"true\"/>\n");
fprintf(f, "</keymap>");
fclose(f);
return true;
}
CfgParser::~CfgParser() {
}
int CfgParser::getAutorepeatDelay() const {
return ardelay;
}
void CfgParser::setAutorepeatDelay(int n) {
ardelay = n;
}
int CfgParser::getAutorepeatPeriod() const {
return arperiod;
}
void CfgParser::setAutorepeatPeriod(int n) {
arperiod = n;
}
void CfgParser::addLabel(const QString& name, const QString& state) {
labels.insert(state, name);
labelList.append(&labels.find(state).data());
}
void CfgParser::addFile(const QString& file, const QString& prefix) {
diff --git a/noncore/apps/keyz-cfg/config.in b/noncore/apps/keyz-cfg/config.in
index 29a10f5..8e1be2d 100644
--- a/noncore/apps/keyz-cfg/config.in
+++ b/noncore/apps/keyz-cfg/config.in
@@ -1,4 +1,4 @@
config KEYZCFG
boolean "keyz-cfg (configuration tool for keyz applet)"
default "n"
- depends ( LIBQPE || LIBQPE-X11 )
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/apps/keyz-cfg/keyz-cfg.pro b/noncore/apps/keyz-cfg/keyz-cfg.pro
index 44bbb5f..7ac604b 100644
--- a/noncore/apps/keyz-cfg/keyz-cfg.pro
+++ b/noncore/apps/keyz-cfg/keyz-cfg.pro
@@ -1,24 +1,24 @@
TEMPLATE = app
DESTDIR = $(OPIEDIR)/bin
CONFIG = qt warn_on
HEADERS = zkb.h \
- zkbcfg.h \
- zkbnames.h \
- zkbxml.h \
- cfgdlg.h \
- cfgfile.h
+ zkbcfg.h \
+ zkbnames.h \
+ zkbxml.h \
+ cfgdlg.h \
+ cfgfile.h
SOURCES = main.cpp \
cfgdlg.cpp \
cfgfile.cpp \
zkb.cpp \
zkbcfg.cpp \
- zkbnames.cpp \
- zkbxml.cpp
+ zkbnames.cpp \
+ zkbxml.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lopiecore2
TARGET = keyz-cfg
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/keyz-cfg/zkb.cpp b/noncore/apps/keyz-cfg/zkb.cpp
index f315d4b..8382615 100644
--- a/noncore/apps/keyz-cfg/zkb.cpp
+++ b/noncore/apps/keyz-cfg/zkb.cpp
@@ -271,245 +271,245 @@ bool Keymap::filter(int unicode, int keycode, int modifiers,
Action* action = currentState->get(keycode, isPress, true);
if (action==0 || !action->isDefined()) {
return true;
}
if (action->hasEvent()) {
qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, "
"ispressed=%x\n", action->getUnicode(),
action->getKeycode(), action->getModifiers(),
action->isPressed());
QWSServer::sendKeyEvent(action->getUnicode(),
action->getKeycode(), action->getModifiers(),
action->isPressed(), false);
}
if (action->isAutorepeat()) {
autoRepeatAction = action;
repeater.start(repeatDelay, TRUE);
} else {
autoRepeatAction = 0;
}
State* nstate = action->getState();
if (nstate != 0) {
setCurrentState(nstate);
QString lbl = getCurrentLabel();
if (!lbl.isEmpty()) {
emit stateChanged(lbl);
}
}
return true;
}
void Keymap::enable() {
enabled = true;
}
void Keymap::disable() {
enabled = false;
}
QStringList Keymap::listStates() {
QStringList ret;
QMap<QString, State*>::Iterator it;
for(it = states.begin(); it != states.end(); ++it) {
ret.append(it.key());
}
return ret;
}
State* Keymap::getStateByName(const QString& name) {
QMap<QString, State*>::Iterator it = states.find(name);
if (it == states.end()) {
return 0;
}
return it.data();
}
QStringList Keymap::listLabels() {
QStringList ret;
for(uint i = 0; i < labelList.count(); i++) {
ret.append(*labelList.at(i));
}
return ret;
}
State* Keymap::getStateByLabel(const QString& label) {
QMap<QString, QString>::Iterator lit = labels.find(label);
State* state = 0;
if (lit == labels.end()) {
return 0;
}
QString name = lit.data();
int n = name.find(":*");
if (n>=0 && n==(int)(name.length()-2)) {
name=name.left(name.length() - 1);
n = currentStateName.findRev(":");
if (n >= 0) {
name += currentStateName.mid(n+1);
}
}
-// qDebug("look for: %s\n", (const char*) name.utf8());
+// odebug << "look for: " << (const char*) name.utf8() << "\n" << oendl;
QMap<QString, State*>::Iterator sit = states.find(name);
if (sit != states.end()) {
state = sit.data();
}
return state;
}
bool Keymap::addState(const QString& name, State* state) {
if (states.find(name) != states.end()) {
return false;
}
states.insert(name, state);
lsmapInSync = false;
if (currentState == 0) {
setCurrentState(state);
}
return true;
}
State* Keymap::getCurrentState() const {
return currentState;
}
QString Keymap::getCurrentLabel() {
return currentLabel;
}
bool Keymap::setCurrentState(State* state) {
QMap<QString, State*>::Iterator it;
for(it = states.begin(); it != states.end(); ++it) {
State* s = it.data();
if (s == state) {
currentState = s;
currentStateName = it.key();
qDebug("state changed: %s\n", (const char*)
currentStateName.utf8());
if (!lsmapInSync) {
generateLabelStateMaps();
}
QMap<State*, QString>::Iterator tit;
tit = stateLabelMap.find(state);
if (tit != stateLabelMap.end()) {
currentLabel = tit.data();
} else {
-// qDebug("no label for: " + currentStateName + "\n");
+// odebug << "no label for: " + currentStateName + "\n" << oendl;
currentLabel = "";
}
return true;
}
}
return false;
}
bool Keymap::removeState(const QString& name, bool force) {
QMap<QString, State*>::Iterator it = states.find(name);
if (it == states.end()) {
return false;
}
State* state = it.data();
QList<Action> acts = findStateUsage(state);
if (!acts.isEmpty()) {
if (!force) {
return false;
} else {
for(Action* a = acts.first(); a != 0; a = acts.next()) {
a->setState(0);
}
}
}
if (state == currentState) {
if (states.begin() != states.end()) {
setCurrentState(states.begin().data());
}
}
states.remove(it);
delete state;
lsmapInSync = false;
return true;
}
void Keymap::autoRepeat() {
if (autoRepeatAction != 0) {
qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, "
"ispressed=%x\n", autoRepeatAction->getUnicode(),
autoRepeatAction->getKeycode(),
autoRepeatAction->getModifiers(),
autoRepeatAction->isPressed());
QWSServer::sendKeyEvent(autoRepeatAction->getUnicode(),
autoRepeatAction->getKeycode(),
autoRepeatAction->getModifiers(),
autoRepeatAction->isPressed(), true);
}
repeater.start(repeatPeriod, TRUE);
}
bool Keymap::addLabel(const QString& label, const QString& state, int index) {
if (labels.find(label) != labels.end()) {
return false;
}
labels.insert(label, state);
const QString& l = labels.find(label).key();
if (index == -1) {
labelList.append(l);
} else {
labelList.insert(labelList.at(index), l);
}
lsmapInSync = false;
return true;
}
bool Keymap::removeLabel(const QString& label) {
if (labels.find(label) == labels.end()) {
return false;
}
labels.remove(label);
labelList.remove(label);
lsmapInSync = false;
if (label == currentLabel) {
currentLabel = "";
}
return true;
}
diff --git a/noncore/apps/keyz-cfg/zkbcfg.cpp b/noncore/apps/keyz-cfg/zkbcfg.cpp
index 0992b9a..f1d53ba 100644
--- a/noncore/apps/keyz-cfg/zkbcfg.cpp
+++ b/noncore/apps/keyz-cfg/zkbcfg.cpp
@@ -1,221 +1,224 @@
-#include <qfileinfo.h>
-
#include "zkbcfg.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
+#include <qfileinfo.h>
// Implementation of XkbConfig class
ZkbConfig::ZkbConfig(const QString& dir):path(dir) {
}
ZkbConfig::~ZkbConfig() {
}
bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) {
bool ret;
QFile f(path+"/"+file);
QFileInfo fi(f);
- qDebug("start loading file=%s\n", (const char*) file.utf8());
+ odebug << "start loading file=" << (const char*) file.utf8() << "\n" << oendl;
if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) {
return false;
}
includedFiles.insert(fi.absFilePath(), 1);
QXmlInputSource is(f);
QXmlSimpleReader reader;
ZkbHandler h(*this, keymap, prefix);
reader.setContentHandler(&h);
reader.setErrorHandler(this);
ret = reader.parse(is);
includedFiles.remove(fi.absFilePath());
- qDebug("end loading file=%s : status=%s\n", (const char*) file.utf8(),
- (const char*) err.utf8());
+ odebug << "end loading file=" << file.utf8() << ": status=" << err.utf8() << oendl;
return ret;
}
bool ZkbConfig::warning(const QXmlParseException& e) {
QString tmp;
tmp.sprintf("%d: warning: %s\n", e.lineNumber(),
(const char*) e.message().utf8());
err += tmp;
return true;
}
bool ZkbConfig::error(const QXmlParseException& e) {
QString tmp;
tmp.sprintf("%d: error: %s\n", e.lineNumber(),
(const char*) e.message().utf8());
err += tmp;
return true;
}
bool ZkbConfig::fatalError(const QXmlParseException& e) {
QString tmp;
tmp.sprintf("%d: fatal error: %s\n", e.lineNumber(),
(const char*) e.message().utf8());
err += tmp;
return false;
}
QString ZkbConfig::errorString() {
return err;
}
// Implementation of ZkbHandler
ZkbHandler::ZkbHandler(ZkbConfig& z, Keymap& k, const QString& p):zkc(z), keymap(k),
prefix(p), ardelay(-1), arperiod(-1), currentState(0), currentAction(0) {
}
ZkbHandler::~ZkbHandler() {
}
bool ZkbHandler::startKeymapElement(int ard, int arp, const QString&) {
ardelay = ard;
arperiod = arp;
return true;
}
bool ZkbHandler::startIncludeElement(const QString& file,
const QString& pref) {
QString p = prefix;
if (!pref.isNull()) {
p += pref + ":";
}
bool ret = zkc.load(file, keymap, p);
if (!ret) {
setError("Error including file: " + file);
}
return ret;
}
bool ZkbHandler::startLabelElement(const QString& label,
const QString& state) {
if (!keymap.addLabel(label, prefix + state)) {
err = "label " + label + " already defined";
return false;
}
return true;
}
bool ZkbHandler::startStateElement(const QString& name,
const QString& parentName, bool dflt) {
currentStateName = prefix + name;
currentState = keymap.getStateByName(currentStateName);
-// qDebug("state name=%s\n", (const char*) currentStateName.utf8());
+// odebug << "state name=" << (const char*) currentStateName.utf8() << "\n" << oendl;
State* parent = 0;
if (!parentName.isEmpty()) {
QString pn = prefix + parentName;
parent = keymap.getStateByName(pn);
if (parent == 0) {
err = currentStateName +
": undefined parent state: " + pn;
return false;
}
}
if (currentState == 0) {
currentState = new State(parent);
keymap.addState(currentStateName, currentState);
} else {
if (parent!=0) {
currentState->setParent(parent);
}
}
if (dflt) {
keymap.setCurrentState(currentState);
}
return true;
}
bool ZkbHandler::startMapElement(int keycode, bool pressed) {
currentAction = currentState->get(keycode, pressed);
if (currentAction == 0) {
setError("keycode " + QString::number(keycode) + " not supported");
return false;
}
currentAction->setEvent(false);
currentAction->setState(0);
return true;
}
bool ZkbHandler::startEventElement(int keycode, int unicode, int modifiers,
bool pressed, bool autorepeat) {
currentAction->setEvent(true);
currentAction->setKeycode(keycode);
currentAction->setUnicode(unicode);
currentAction->setModifiers(modifiers);
currentAction->setPressed(pressed);
currentAction->setAutorepeat(autorepeat);
return true;
}
bool ZkbHandler::startNextStateElement(const QString& state) {
State* s = keymap.getStateByName(prefix + state);
if (s == 0) {
setError("undefine state: " + prefix + state);
return false;
}
currentAction->setState(s);
return true;
}
bool ZkbHandler::endKeymapElement() {
if (ardelay > 0) {
keymap.setAutorepeatDelay(ardelay);
}
if (arperiod > 0) {
keymap.setAutorepeatPeriod(arperiod);
}
return true;
}
bool ZkbHandler::endIncludeElement() {
return true;
}
bool ZkbHandler::endLabelElement() {
return true;
}
bool ZkbHandler::endStateElement() {
currentState = 0;
return true;
}
bool ZkbHandler::endMapElement() {
currentAction = 0;
return true;
}
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp
index e6cb515..59fc242 100644
--- a/noncore/apps/opie-bartender/bartender.cpp
+++ b/noncore/apps/opie-bartender/bartender.cpp
@@ -1,432 +1,435 @@
/****************************************************************************
**
** 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 <qtoolbar.h>
-#include <qmenubar.h>
-//#include <opie2/colorpopupmenu.h>
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
+using namespace Opie::Core;
+/* QT */
#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 <qtoolbar.h>
+#include <qmenubar.h>
+/* STD */
#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));
+// odebug << s.right(s.length()-2) << oendl;
item= new QListViewItem( DrinkView, 0 );
item->setText( 0, s.right(s.length()-2));
i++;
}
}
- qDebug("there are currently %d of drinks", i);
+ odebug << "there are currently " << i << " of drinks" << oendl;
}
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);
+ odebug << "writing "+newDrink << oendl;
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);
+// odebug << s2 << oendl;
showDrinks->MultiLineEdit1->append(s2);
}
if( dbFile.atEnd() ) break;
}
}
}
QPEApplication::execDialog( showDrinks );
if(showDrinks ->result() ==0) {
doEdit();
}
delete showDrinks;
}
void Bartender::askSearch() {
switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+
"\nor alcohol ?"
,tr("Drink Name"),tr("Alcohol"),0,0,1) ) {
case 0:
doSearchByName();
break;
case 1:
doSearchByDrink();
break;
};
}
/* search by name */
void Bartender::doSearchByName() {
// if( DrinkView->currentItem() == NULL) return;
QStringList searchList;
QString searchForDrinkName;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
searchForDrinkName = fileDlg->LineEdit1->text();
QListViewItemIterator it( DrinkView );
for ( ; it.current(); ++it ) {
if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) {
-// qDebug( it.current()->text(0));
+// odebug << it.current()->text(0) << oendl;
searchList.append(it.current()->text(0));
}
}
if(searchList.count() >0)
showSearchResult(searchList);
else
QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName);
}//end Inputdialog
delete fileDlg;
}
void Bartender::doSearchByDrink() {
// if( DrinkView->currentItem() == NULL) return;
QStringList searchList;
QString searchForDrinkName, lastDrinkName, tempName;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
searchForDrinkName = fileDlg->LineEdit1->text();
dbFile.at(0);
QTextStream t( &dbFile);
QString s, s2;
while ( !t.eof()) {
s = t.readLine();
if(s.find("#",0,TRUE) != -1) {
lastDrinkName=s.right(s.length()-2);
-// qDebug("last drink name "+lastDrinkName);
+// odebug << "last drink name "+lastDrinkName << oendl;
}
else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) {
-// qDebug("appending "+lastDrinkName);
+// odebug << "appending "+lastDrinkName << oendl;
searchList.append( lastDrinkName);
tempName=lastDrinkName;
}
// if( dbFile.atEnd() ) break;
} //oef
if(searchList.count() >0)
showSearchResult(searchList);
else
QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName);
}
delete fileDlg;
}
void Bartender::showSearchResult(QStringList &searchList) {
QString result;
Search_Results *searchDlg;
searchList.sort();
searchDlg = new Search_Results(this, "Search Results", TRUE);
searchDlg->ListBox1->insertStringList( searchList,-1);
QPEApplication::execDialog( searchDlg );
if( searchDlg->result() == 1 ) {
result= searchDlg->ListBox1->currentText();
}
QListViewItemIterator it2( DrinkView );
for ( ; it2.current(); ++it2 ) {
if ( it2.current()->text(0)== result ) {
-// qDebug( it2.current()->text(0));
+// odebug << it2.current()->text(0) << oendl;
showDrink(it2.current());
}
}
delete searchDlg;
}
void Bartender::doEdit() {
if(DrinkView->currentItem() == NULL) {
fileNew();
}
QString myDrink;
myDrink= DrinkView->currentItem()->text(0);
dbFile.at(0);
int foundAt=0;
New_Drink *newDrinks;
newDrinks = new New_Drink(this,"Edit Drink....", TRUE);
QString newName, newIng;
QPEApplication::showDialog( newDrinks );
QTextStream t( &dbFile);
QString s, s2;
while ( !t.eof()) {
s = t.readLine();
if(s.find( myDrink, 0, TRUE) != -1) {
foundAt = dbFile.at() - (s.length()+1);
for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
s2 = t.readLine();
if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
-// qDebug(s2);
+// odebug << s2 << oendl;
newDrinks->MultiLineEdit1->append(s2);
newDrinks->LineEdit1->setText(myDrink);
}
if( dbFile.atEnd() ) break;
}
}
}
newDrinks->exec();
newName = newDrinks->LineEdit1->text();
newIng= newDrinks->MultiLineEdit1->text();
if( newDrinks ->result() == 1 ) {
if(dbFile.isOpen())
dbFile.close();
if ( !dbFile.open( IO_ReadWrite )) {
QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
return;
}
int fd = dbFile.handle();
lseek( fd, foundAt, SEEK_SET);
// dbFile.at( foundAt);
#warning FIXME problems with editing drinks db
////////// FIXME write to user file
QString newDrink="# "+newName+"\n";
newDrink.append(newIng+"\n");
- qDebug("writing "+newDrink);
+ odebug << "writing "+newDrink << oendl;
dbFile.writeBlock( newDrink.latin1(), newDrink.length());
clearList();
dbFile.flush();
initDrinkDb();
}
}
void Bartender::clearList() {
DrinkView->clear();
}
void Bartender::doBac() {
BacDialog *bacDlg;
bacDlg = new BacDialog(this,"BAC",TRUE);
QPEApplication::execDialog( bacDlg );
delete bacDlg;
}
void Bartender::openCurrentDrink() {
if(DrinkView->currentItem() == NULL) return;
showDrink(DrinkView->currentItem());
}
void Bartender::fileMenuActivated( int item) {
- qDebug("Item %d", item);
+ odebug << "Item " << item << "" << oendl;
switch(item) {
case -3: // new -3
fileNew();
break;
case -4:// open -4
openCurrentDrink();
break;
case -5:// drink -5
doSearchByName();
break;
case -6:// alcohol -6
doSearchByDrink();
break;
}
}
void Bartender::editMenuActivated(int item) {
- qDebug("Item %d", item);
+ odebug << "Item " << item << "" << oendl;
/*
edit -8
*/
switch(item) {
case -8:
doEdit() ;
break;
}
}
diff --git a/noncore/apps/opie-bartender/bartender.pro b/noncore/apps/opie-bartender/bartender.pro
index 4ad3c31..41fc0e5 100644
--- a/noncore/apps/opie-bartender/bartender.pro
+++ b/noncore/apps/opie-bartender/bartender.pro
@@ -1,12 +1,11 @@
TEMPLATE = app
-#CONFIG = qt warn_on
CONFIG = qt warn_on
HEADERS = bartender.h newdrinks.h showdrinks.h inputDialog.h searchresults.h bac.h
SOURCES = main.cpp bartender.cpp newdrinks.cpp showdrinks.cpp inputDialog.cpp searchresults.cpp bac.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
-DESTDIR = $(OPIEDIR)/bin
-TARGET = bartender
+LIBS += -lqpe -lopiecore2
+DESTDIR = $(OPIEDIR)/bin
+TARGET = bartender
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-bartender/config.in b/noncore/apps/opie-bartender/config.in
index c6ca2e6..c39a7d6 100644
--- a/noncore/apps/opie-bartender/config.in
+++ b/noncore/apps/opie-bartender/config.in
@@ -1,4 +1,5 @@
config BARTENDER
boolean "bartender - bar receipe and blood alcohol estimator"
default "n"
- depends ( LIBQPE || LIBQPE-X11 )
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
+
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index a37f980..6d57703 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -1,196 +1,200 @@
/* -------------------------------------------------------------------------- */
/* */
/* [MyPty.C] Pseudo Terminal Device */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* -------------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
/* If you're compiling konsole on non-Linux platforms and find
problems that you can track down to this file, please have
a look into ../README.ports, too.
*/
/*! \file
*/
/*! \class TEPty
\brief Ptys provide a pseudo terminal connection to a program.
Although closely related to pipes, these pseudo terminal connections have
some ability, that makes it nessesary to uses them. Most importent, they
know about changing screen sizes and UNIX job control.
Within the terminal emulation framework, this class represents the
host side of the terminal together with the connecting serial line.
One can create many instances of this class within a program.
As a side effect of using this class, a signal(2) handler is
installed on SIGCHLD.
\par FIXME
[NOTE: much of the technical stuff below will be replaced by forkpty.]
publish the SIGCHLD signal if not related to an instance.
clearify TEPty::done vs. TEPty::~TEPty semantics.
check if pty is restartable via run after done.
\par Pseudo terminals
Pseudo terminals are a unique feature of UNIX, and always come in form of
pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
other by the operating system. One may think of them as two serial devices
linked by a null-modem cable. Being based on devices the number of
simultanous instances of this class is (globally) limited by the number of
those device pairs, which is 256.
Another technic are UNIX 98 PTY's. These are supported also, and prefered
over the (obsolete) predecessor.
There's a sinister ioctl(2), signal(2) and job control stuff
nessesary to make everything work as it should.
*/
+#include "procctl.h"
+#include "MyPty.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qsocketnotifier.h>
#include <qfile.h>
+/* STD */
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#ifdef HAVE_OPENPTY
#include <pty.h>
#endif
-#include "procctl.h"
-#include "MyPty.h"
-
-
#undef VERBOSE_DEBUG
/* -------------------------------------------------------------------------- */
/*!
Informs the client program about the
actual size of the window.
*/
void MyPty::setSize(int lines, int columns)
{
- qWarning("setting size");
+ owarn << "setting size" << oendl;
struct winsize wsize;
wsize.ws_row = (unsigned short)lines;
wsize.ws_col = (unsigned short)columns;
if(m_fd < 0) return;
ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
}
void MyPty::donePty()
{
// This is code from the Qt DumbTerminal example
::close(m_fd);
if (m_cpid) {
kill(m_cpid, SIGHUP);
//waitpid(m_cpid, &status, 0);
delete m_sn_e;
delete m_sn_r;
m_sn_e = 0l;
m_sn_r = 0l;
}
m_cpid = 0;
m_fd = -1;
// emit done(status);
}
const char* MyPty::deviceName()
{
return m_ttynam;
}
void MyPty::error()
{
// This is code from the Qt DumbTerminal example
donePty();
}
void MyPty::start() {
QStrList lis;
int r =run(m_cmd.latin1(), lis, 0, 0);
r = r;
}
/*!
start the client program.
*/
int MyPty::run(const char* cmd, QStrList &, const char*, int)
{
// This is code from the Qt DumbTerminal example
m_cpid = fork();
if ( !m_cpid ) {
// child - exec shell on tty
for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
int ttyfd = ::open(m_ttynam, O_RDWR);
dup2(ttyfd, STDIN_FILENO);
dup2(ttyfd, STDOUT_FILENO);
dup2(ttyfd, STDERR_FILENO);
// should be done with tty, so close it
::close(ttyfd);
static struct termios ttmode;
if ( setsid() < 0 )
perror( "failed to set process group" );
#if defined (TIOCSCTTY)
// grabbed from APUE by Stevens
ioctl(STDIN_FILENO, TIOCSCTTY, 0);
#endif
tcgetattr( STDIN_FILENO, &ttmode );
ttmode.c_cc[VINTR] = 3;
ttmode.c_cc[VERASE] = 8;
tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
setenv("TERM",m_term,1);
setenv("COLORTERM","0",1);
EnvironmentMap::Iterator it;
for (it = m_env.begin(); it != m_env.end(); it++) {
setenv(it.key().latin1(), it.data().latin1(), 1);
}
if (getuid() == 0) {
char msg[] = "WARNING: You are running this shell as root!\n";
write(ttyfd, msg, sizeof(msg));
}
execl(cmd, cmd, 0);
donePty();
exit(-1);
}
// parent - continue as a widget
delete m_sn_r;
m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
delete m_sn_e;
m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp
index e535296..d168a5e 100644
--- a/noncore/apps/opie-console/TEWidget.cpp
+++ b/noncore/apps/opie-console/TEWidget.cpp
@@ -936,236 +936,236 @@ void TEWidget::setMouseMarks(bool on)
/* ------------------------------------------------------------------------- */
/* */
/* Clipboard */
/* */
/* ------------------------------------------------------------------------- */
#undef KeyPress
void TEWidget::emitSelection()
// Paste Clipboard by simulating keypress events
{
#ifndef QT_NO_CLIPBOARD
QString text = QApplication::clipboard()->text();
if ( ! text.isNull() )
{
text.replace(QRegExp("\n"), "\r");
QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
emit keyPressedSignal(&e); // expose as a big fat keypress event
emit clearSelectionSignal();
}
#endif
}
void TEWidget::emitText(QString text)
{
QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
emit keyPressedSignal(&e); // expose as a big fat keypress event
}
void TEWidget::pasteClipboard( )
{
emitSelection();
}
void TEWidget::setSelection(const QString& t)
{
#ifndef QT_NO_CLIPBOARD
// Disconnect signal while WE set the clipboard
QObject *cb = QApplication::clipboard();
QObject::disconnect( cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
QApplication::clipboard()->setText(t);
QObject::connect( cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
#endif
}
void TEWidget::onClearSelection()
{
emit clearSelectionSignal();
}
/* ------------------------------------------------------------------------- */
/* */
/* Keyboard */
/* */
/* ------------------------------------------------------------------------- */
//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
// due to a bug in `QT' or the ignorance of the author to prevent
// repaint events being emitted to the screen whenever one leaves
// or reenters the screen to/from another application.
//
// Troll says one needs to change focusInEvent() and focusOutEvent(),
// which would also let you have an in-focus cursor and an out-focus
// cursor like xterm does.
// for the auto-hide cursor feature, I added empty focusInEvent() and
// focusOutEvent() so that update() isn't called.
// For auto-hide, we need to get keypress-events, but we only get them when
// we have focus.
void TEWidget::doScroll(int lines)
{
scrollbar->setValue(scrollbar->value()+lines);
}
bool TEWidget::eventFilter( QObject *obj, QEvent *e )
{
if ( (e->type() == QEvent::Accel ||
e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
static_cast<QKeyEvent *>( e )->ignore();
return true;
}
if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
return FALSE; // not us
if ( e->type() == QEvent::Wheel) {
QApplication::sendEvent(scrollbar, e);
}
#ifdef FAKE_CTRL_AND_ALT
static bool control = FALSE;
static bool alt = FALSE;
-// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
+// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
bool dele=FALSE;
if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
QKeyEvent* ke = (QKeyEvent*)e;
bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
switch (ke->key()) {
case Key_F9: // let this be "Control"
control = keydown;
e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
dele=TRUE;
break;
case Key_F13: // let this be "Alt"
alt = keydown;
e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
dele=TRUE;
break;
default:
if ( control ) {
int a = toupper(ke->ascii())-64;
if ( a >= 0 && a < ' ' ) {
e = new QKeyEvent(e->type(), ke->key(),
a, ke->state()|ControlButton, QChar(a,0));
dele=TRUE;
}
}
if ( alt ) {
e = new QKeyEvent(e->type(), ke->key(),
ke->ascii(), ke->state()|AltButton, ke->text());
dele=TRUE;
}
}
}
#endif
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent* ke = (QKeyEvent*)e;
actSel=0; // Key stroke implies a screen update, so TEWidget won't
// know where the current selection is.
-// qDebug("key pressed is 0x%x",ke->key());
+// odebug << "key pressed is 0x" << ke->key() << "" << oendl;
if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
-// qDebug("key pressed 2 is 0x%x",ke->key());
+// odebug << "key pressed 2 is 0x" << ke->key() << "" << oendl;
emitText("\\"); // expose
} else
emit keyPressedSignal(ke); // expose
ke->accept();
#ifdef FAKE_CTRL_AND_ALT
if ( dele ) delete e;
#endif
return true; // stop the event
}
if ( e->type() == QEvent::Enter ) {
QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
}
if ( e->type() == QEvent::Leave ) {
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
}
return QFrame::eventFilter( obj, e );
}
/* ------------------------------------------------------------------------- */
/* */
/* Frame */
/* */
/* ------------------------------------------------------------------------- */
void TEWidget::frameChanged()
{
propagateSize();
update();
}
/* ------------------------------------------------------------------------- */
/* */
/* Sound */
/* */
/* ------------------------------------------------------------------------- */
void TEWidget::Bell()
{
QApplication::beep();
}
/* ------------------------------------------------------------------------- */
/* */
/* Auxiluary */
/* */
/* ------------------------------------------------------------------------- */
void TEWidget::clearImage()
// initialize the image
// for internal use only
{
for (int y = 0; y < lines; y++)
for (int x = 0; x < columns; x++)
{
image[loc(x,y)].c = 0xff; //' ';
image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
}
}
// Create Image ///////////////////////////////////////////////////////
void TEWidget::calcGeometry()
{
//FIXME: set rimX == rimY == 0 when running in full screen mode.
int showhscrollbar = 1;
int hwidth = 0;
int dcolumns;
if(vcolumns == 0) showhscrollbar = 0;
if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
scrollbar->resize(QApplication::style().scrollBarExtent().width(),
contentsRect().height() - hwidth);
if(!showhscrollbar) cornerButton()->move(0, 0);
else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth);
switch(scrollLoc)
{
case SCRNONE :
columns = ( contentsRect().width() - 2 * rimX ) / font_w;
dcolumns = columns;
if(vcolumns) columns = vcolumns;
blX = (contentsRect().width() - (columns*font_w) ) / 2;
if(showhscrollbar)
blX = -hposition * font_w;
brX = blX;
scrollbar->hide();
break;
case SCRLEFT :
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp
index d0169d7..6ff73af 100644
--- a/noncore/apps/opie-console/TEmulation.cpp
+++ b/noncore/apps/opie-console/TEmulation.cpp
@@ -1,303 +1,309 @@
/* -------------------------------------------------------------------------- */
/* */
/* [TEmulation.cpp] Terminal Emulation Decoder */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
/*! \class TEmulation
\brief Mediator between TEWidget and TEScreen.
This class is responsible to scan the escapes sequences of the terminal
emulation and to map it to their corresponding semantic complements.
Thus this module knows mainly about decoding escapes sequences and
is a stateless device w.r.t. the semantics.
It is also responsible to refresh the TEWidget by certain rules.
\sa TEWidget \sa TEScreen
\par A note on refreshing
Although the modifications to the current screen image could immediately
be propagated via `TEWidget' to the graphical surface, we have chosen
another way here.
The reason for doing so is twofold.
First, experiments show that directly displaying the operation results
in slowing down the overall performance of emulations. Displaying
individual characters using X11 creates a lot of overhead.
Second, by using the following refreshing method, the screen operations
can be completely separated from the displaying. This greatly simplifies
the programmer's task of coding and maintaining the screen operations,
since one need not worry about differential modifications on the
display affecting the operation of concern.
We use a refreshing algorithm here that has been adoped from rxvt/kvt.
By this, refreshing is driven by a timer, which is (re)started whenever
a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'.
As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger
refresh. This rule suits both bulk display operation as done by curses as
well as individual characters typed.
(BULK_TIMEOUT < 1000 / max characters received from keyboard per second).
Additionally, we trigger refreshing by newlines comming in to make visual
snapshots of lists as produced by `cat', `ls' and likely programs, thereby
producing the illusion of a permanent and immediate display operation.
As a sort of catch-all needed for cases where none of the above
conditions catch, the screen refresh is also triggered by a count
of incoming bulks (`bulk_incnt').
*/
/* FIXME
- evtl. the bulk operations could be made more transparent.
*/
#include "TEmulation.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* STD */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* ------------------------------------------------------------------------- */
/* */
/* TEmulation */
/* */
/* ------------------------------------------------------------------------- */
#define CNTL(c) ((c)-'@')
/*!
*/
TEmulation::TEmulation(TEWidget* gui)
: decoder((QTextDecoder*)NULL)
{
this->gui = gui;
screen[0] = new TEScreen(gui->Lines(),gui->Columns());
screen[1] = new TEScreen(gui->Lines(),gui->Columns());
scr = screen[0];
bulk_nlcnt = 0; // reset bulk newline counter
bulk_incnt = 0; // reset bulk counter
connected = FALSE;
QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) );
QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)),
this,SLOT(onImageSizeChange(int,int)));
QObject::connect(gui,SIGNAL(changedHistoryCursor(int)),
this,SLOT(onHistoryCursorChange(int)));
QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)),
this,SLOT(onKeyPress(QKeyEvent*)));
QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)),
this,SLOT(onSelectionBegin(const int,const int)) );
QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)),
this,SLOT(onSelectionExtend(const int,const int)) );
QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)),
this,SLOT(setSelection(const BOOL)) );
QObject::connect(gui,SIGNAL(clearSelectionSignal()),
this,SLOT(clearSelection()) );
}
/*!
*/
TEmulation::~TEmulation()
{
delete screen[0];
delete screen[1];
bulk_timer.stop();
}
/*! change between primary and alternate screen
*/
void TEmulation::setScreen(int n)
{
scr = screen[n&1];
}
void TEmulation::setHistory(bool on)
{
screen[0]->setScroll(on);
if (!connected) return;
showBulk();
}
bool TEmulation::history()
{
return screen[0]->hasScroll();
}
void TEmulation::setCodec(int c)
{
//FIXME: check whether we have to free codec
codec = c ? QTextCodec::codecForName("utf8")
: QTextCodec::codecForLocale();
if (decoder) delete decoder;
decoder = codec->makeDecoder();
}
void TEmulation::setKeytrans(int no)
{
keytrans = KeyTrans::find(no);
}
void TEmulation::setKeytrans(const char * no)
{
keytrans = KeyTrans::find(no);
}
// Interpreting Codes ---------------------------------------------------------
/*
This section deals with decoding the incoming character stream.
Decoding means here, that the stream is first seperated into `tokens'
which are then mapped to a `meaning' provided as operations by the
`Screen' class.
*/
/*!
*/
void TEmulation::onRcvChar(int c)
// process application unicode input to terminal
// this is a trivial scanner
{
c &= 0xff;
switch (c)
{
case '\b' : scr->BackSpace(); break;
case '\t' : scr->Tabulate(); break;
case '\n' : scr->NewLine(); break;
case '\r' : scr->Return(); break;
case 0x07 : gui->Bell(); break;
default : scr->ShowCharacter(c); break;
};
}
/* ------------------------------------------------------------------------- */
/* */
/* Keyboard Handling */
/* */
/* ------------------------------------------------------------------------- */
/*!
*/
void TEmulation::onKeyPress( QKeyEvent* ev )
{
- qWarning("onKeyPress,....");
+ owarn << "onKeyPress,...." << oendl;
if (!connected) return; // someone else gets the keys
if (scr->getHistCursor() != scr->getHistLines());
scr->setHistCursor(scr->getHistLines());
if (!ev->text().isEmpty())
{ // A block of text
// Note that the text is proper unicode.
// We should do a conversion here, but since this
// routine will never be used, we simply emit plain ascii.
emit sndBlock(ev->text().ascii(),ev->text().length());
}
else if (ev->ascii()>0)
{ unsigned char c[1];
c[0] = ev->ascii();
emit sndBlock((char*)c,1);
}
}
// Unblocking, Byte to Unicode translation --------------------------------- --
/*
We are doing code conversion from locale to unicode first.
*/
void TEmulation::onRcvBlock(const char *s, int len)
{
bulkStart();
bulk_incnt += 1;
for (int i = 0; i < len; i++)
{
QString result = decoder->toUnicode(&s[i],1);
int reslen = result.length();
for (int j = 0; j < reslen; j++)
onRcvChar(result[j].unicode());
if (s[i] == '\n') bulkNewline();
}
bulkEnd();
}
// Selection --------------------------------------------------------------- --
void TEmulation::onSelectionBegin(const int x, const int y) {
if (!connected) return;
scr->setSelBeginXY(x,y);
showBulk();
}
void TEmulation::onSelectionExtend(const int x, const int y) {
if (!connected) return;
scr->setSelExtentXY(x,y);
showBulk();
}
void TEmulation::setSelection(const BOOL preserve_line_breaks) {
if (!connected) return;
QString t = scr->getSelText(preserve_line_breaks);
if (!t.isNull()) gui->setSelection(t);
}
void TEmulation::clearSelection() {
if (!connected) return;
scr->clearSelection();
showBulk();
}
void TEmulation::streamHistory(QTextStream* stream) {
*stream << scr->getHistory();
}
// Refreshing -------------------------------------------------------------- --
#define BULK_TIMEOUT 20
/*!
called when \n comes in. Evtl. triggers showBulk at endBulk
*/
void TEmulation::bulkNewline()
{
bulk_nlcnt += 1;
bulk_incnt = 0; // reset bulk counter since `nl' rule applies
}
/*!
*/
void TEmulation::showBulk()
{
bulk_nlcnt = 0; // reset bulk newline counter
bulk_incnt = 0; // reset bulk counter
if (connected)
{
ca* image = scr->getCookedImage(); // get the image
gui->setImage(image,
scr->getLines(),
scr->getColumns()); // actual refresh
free(image);
//FIXME: check that we do not trigger other draw event here.
gui->setScroll(scr->getHistCursor(),scr->getHistLines());
diff --git a/noncore/apps/opie-console/atconfigdialog.cpp b/noncore/apps/opie-console/atconfigdialog.cpp
index 8e91b9e..c998f96 100644
--- a/noncore/apps/opie-console/atconfigdialog.cpp
+++ b/noncore/apps/opie-console/atconfigdialog.cpp
@@ -1,215 +1,218 @@
+#include "atconfigdialog.h"
+#include "io_modem.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qlineedit.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qcombobox.h>
#include <qtabwidget.h>
#include <qlabel.h>
#include <qscrollview.h>
-#include "atconfigdialog.h"
-#include "io_modem.h"
-
-
ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
setCaption( tr( "Dialing parameter setup" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
QTabWidget *tabWidget = new QTabWidget( this );
tabWidget->addTab( tab0( this ), tr("Settings1") );
tabWidget->addTab( tab1( this ), tr("Settings2") );
layout->addWidget( tabWidget );
}
QWidget* ATConfigDialog::tab0( QWidget* parent) {
QScrollView* sv = new QScrollView( parent );
QWidget *returnWidget = new QWidget( sv->viewport() );
sv->setResizePolicy( QScrollView::AutoOneFit );
// sv->setHScrollBarMode( QScrollView::AlwaysOff );
// sv->setFrameShape( QFrame::NoFrame );
QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 );
QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget );
initStringLine = new QLineEdit( returnWidget );
layout->addWidget( initStringLabel, 0, 0 );
layout->addWidget( initStringLine, 0, 1 );
QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget );
resetStringLine = new QLineEdit( returnWidget );
layout->addWidget( resetStringLabel, 1, 0 );
layout->addWidget( resetStringLine, 1, 1 );
QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget );
dialPref1Line = new QLineEdit( returnWidget );
layout->addWidget( dialPref1Label, 2, 0 );
layout->addWidget( dialPref1Line, 2, 1 );
QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget );
dialSuf1Line = new QLineEdit( returnWidget );
layout->addWidget( dialSuf1Label, 3, 0 );
layout->addWidget( dialSuf1Line, 3, 1 );
QLabel *dialPref2Label = new QLabel( tr("Dialing prefix #2 " ), returnWidget );
dialPref2Line = new QLineEdit( returnWidget );
layout->addWidget( dialPref2Label, 4, 0 );
layout->addWidget( dialPref2Line, 4, 1 );
QLabel *dialSuf2Label = new QLabel( tr("Dialing suffix #2 " ), returnWidget );
dialSuf2Line = new QLineEdit( returnWidget );
layout->addWidget( dialSuf2Label, 5, 0 );
layout->addWidget( dialSuf2Line, 5, 1 );
QLabel *dialPref3Label = new QLabel( tr("Dialing prefix #3 " ), returnWidget );
dialPref3Line = new QLineEdit( returnWidget );
layout->addWidget( dialPref3Label, 6, 0 );
layout->addWidget( dialPref3Line, 6, 1 );
QLabel *dialSuf3Label = new QLabel( tr("Dialing suffix #3 " ), returnWidget );
dialSuf3Line = new QLineEdit( returnWidget );
layout->addWidget( dialSuf3Label, 7, 0 );
layout->addWidget( dialSuf3Line, 7, 1 );
QLabel *connectLabel = new QLabel( tr("Connect string " ), returnWidget );
connectLine = new QLineEdit( returnWidget );
layout->addWidget( connectLabel, 8, 0 );
layout->addWidget( connectLine, 8, 1 );
QLabel *hangupLabel = new QLabel( tr("Hang-up string " ), returnWidget );
hangupLine = new QLineEdit( returnWidget );
layout->addWidget( hangupLabel, 9, 0 );
layout->addWidget( hangupLine, 9, 1 );
sv->addChild( returnWidget );
return sv;
}
QWidget* ATConfigDialog::tab1( QWidget* parent ) {
QWidget *returnWidget = new QWidget( parent );
QGridLayout *layout = new QGridLayout( returnWidget, 8, 2 );
QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget );
dialTimeSpin = new QSpinBox( returnWidget );
layout->addWidget( dialTimeLabel, 0, 0 );
layout->addWidget( dialTimeSpin, 0, 1 );
QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget );
delayRedialSpin = new QSpinBox( returnWidget );
layout->addWidget( delayRedialLabel, 1, 0 );
layout->addWidget( delayRedialSpin, 1, 1 );
QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget );
numberTriesSpin = new QSpinBox( returnWidget );
layout->addWidget( numberTriesLabel, 2, 0 );
layout->addWidget( numberTriesSpin, 2, 1 );
QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget );
dtrDropTimeSpin = new QSpinBox( returnWidget );
layout->addWidget( dtrDropTimeLabel, 3, 0 );
layout->addWidget( dtrDropTimeSpin, 3, 1 );
QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget );
bpsDetectBox = new QComboBox( returnWidget );
layout->addWidget( bpsDetectLabel, 4, 0 );
layout->addWidget( bpsDetectBox, 4, 1 );
bpsDetectBox->insertItem( tr("No") );
bpsDetectBox->insertItem( tr("Yes") );
QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget );
dcdLinesBox = new QComboBox( returnWidget );
layout->addWidget( dcdLinesLabel, 5, 0 );
layout->addWidget( dcdLinesBox, 5, 1 );
dcdLinesBox->insertItem( tr("No") );
dcdLinesBox->insertItem( tr("Yes") );
QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget );
multiLineUntagBox = new QComboBox( returnWidget );
layout->addWidget( multiLineUntagLabel, 6, 0 );
layout->addWidget( multiLineUntagBox, 6, 1 );
multiLineUntagBox->insertItem( tr("No") );
multiLineUntagBox->insertItem( tr("Yes") );
return returnWidget;
}
void ATConfigDialog::readConfig( const Profile& config ) {
- qWarning("config in atconfigdialog");
+ owarn << "config in atconfigdialog" << oendl;
initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) );
hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) );
delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) );
numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) );
dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) );
bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) );
dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) );
multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) );
// Not implemented yet
resetStringLine->setEnabled(false);
dialSuf1Line->setEnabled(false);
dialPref2Line->setEnabled(false);
dialSuf2Line->setEnabled(false);
dialPref3Line->setEnabled(false);
dialSuf3Line->setEnabled(false);
dialTimeSpin->setEnabled(false);
delayRedialSpin->setEnabled(false);
numberTriesSpin->setEnabled(false);
dtrDropTimeSpin->setEnabled(false);
bpsDetectBox->setEnabled(false);
dcdLinesBox->setEnabled(false);
multiLineUntagBox->setEnabled(false);
}
void ATConfigDialog::writeConfig( Profile& config ) {
config.writeEntry( "InitString", initStringLine->text() );
config.writeEntry( "ResetString", resetStringLine->text() );
config.writeEntry( "DialPrefix1", dialPref1Line->text() );
config.writeEntry( "DialSuffix1", dialSuf1Line->text() );
config.writeEntry( "DialPrefix2", dialPref2Line->text() );
config.writeEntry( "DialSuffix2", dialSuf2Line->text() );
config.writeEntry( "DialPrefix3", dialPref3Line->text() );
config.writeEntry( "DialSuffix3", dialSuf3Line->text() );
config.writeEntry( "DefaultConnect", connectLine->text() );
config.writeEntry( "HangupString", hangupLine->text() );
config.writeEntry( "DialTime", dialTimeSpin->value() );
config.writeEntry( "DelayRedial", delayRedialSpin->value() );
config.writeEntry( "NumberTries", numberTriesSpin->value() );
config.writeEntry( "DTRDRopTime", dtrDropTimeSpin->value() );
config.writeEntry( "BPSDetect", bpsDetectBox->currentItem() );
config.writeEntry( "DCDLines", dcdLinesBox->currentItem() );
config.writeEntry( "MultiLineUntag", multiLineUntagBox->currentItem() );
}
ATConfigDialog::~ATConfigDialog() {
}
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 67ad10e..7010594 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -1,315 +1,320 @@
#include "dialer.h"
+#include "io_modem.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+/* QT */
#include <qlayout.h>
#include <qprogressbar.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qapp.h>
#include <qtimer.h>
#include <qmessagebox.h>
+/* STD */
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
-#include "io_modem.h"
-
// State machine: | When an error occurs, we don't have to
// | reset everything.
// (init) <------+ | But if the user wants to reset,
// | | | we stop dialing immediately.
// v | |
// (options) ----+ | Following the state machine is necessary
// | \ | to get determinable results.
// v ^ |
// (dial) ----+ |
// | ^ |
// v | |
// (online) --+ |
// | |
// v |
// from atconfigdialog
//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) );
//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
// from modemconfigwidget
//int rad_flow = prof.readNumEntry("Flow");
//int rad_parity = prof.readNumEntry("Parity");
//int speed = prof.readNumEntry("Speed");
//QString number = prof.readEntry("Number");
Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name)
: QDialog(parent, name, true), m_fd(fd), m_profile(profile)
{
QVBoxLayout *vbox;
QLabel *desc;
usercancel = 0;
cleanshutdown = 0;
desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
progress = new QProgressBar(this);
status = new QLabel("", this);
status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
cancel = new QPushButton(QObject::tr("Cancel"), this);
vbox = new QVBoxLayout(this, 2);
vbox->add(desc);
vbox->add(progress);
vbox->add(status);
vbox->add(cancel);
connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
show();
QTimer::singleShot(500, this, SLOT(slotAutostart()));
}
Dialer::~Dialer()
{
}
void Dialer::setHangupOnly()
{
state = state_cancel;
usercancel = 1;
send( m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING )+"\r" );
}
void Dialer::slotCancel()
{
if(state != state_online)
{
usercancel = 1;
reset();
}
else {
accept();
}
}
void Dialer::reset()
{
- qWarning("reset");
+ owarn << "reset" << oendl;
switchState(state_cancel);
}
void Dialer::slotAutostart()
{
//state = state_preinit;
dial(m_profile.readEntry("Number"));
}
void Dialer::dial(const QString& number)
{
while(state != state_online)
{
if(!usercancel)
{
state = state_preinit;
trydial(number);
}
else break;
}
if(usercancel)
{
// modem hangup
trydial(QString::null);
reject();
}
}
void Dialer::trydial(const QString& number)
{
- qWarning("TryDial:%s", number.latin1() );
+ owarn << "TryDial:" << number.latin1() << "" << oendl;
if(state != state_cancel) switchState(state_preinit);
if(cleanshutdown)
{
- qWarning("HangupString " + m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING));
+ owarn << "HangupString " << m_profile.readEntry("HangupString") << oendl;
send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r");
}
if(state != state_cancel)
{
switchState(state_init);
-// qWarning("Init String " + m_profile.readEntry("InitString") );
+// owarn << "Init String " + m_profile.readEntry("InitString") << oendl;
send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r");
QString response2 = receive();
if(!response2.contains("\nOK\r"))
reset();
}
/* if(state != state_cancel)
{
switchState(state_options);
- qWarning("ATM3l3");
+ owarn << "ATM3l3" << oendl;
send("ATM3L3\r");
QString response3 = receive();
if(!response3.contains("\nOK\r"))
reset();
}
*/
if(state != state_cancel)
{
switchState(state_dialtone);
send("ATX1\r");
QString response4 = receive();
if(!response4.contains("\nOK\r"))
reset();
}
if(state != state_cancel)
{
- qWarning("progress");
+ owarn << "progress" << oendl;
switchState(state_dialing);
// send(QString("ATDT %1\r").arg(number));
send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ))
.arg(number));
QString response5 = receive();
if(!response5.contains("CONNECT") )
{
if(response5.contains("BUSY"))
switchState(state_dialing);
else
{
QMessageBox::warning(this,
QObject::tr("Failure"),
QObject::tr("Dialing the number failed."));
slotCancel();
}
}
}
if(state != state_cancel)
{
state = state_online;
slotCancel();
}
}
void Dialer::send(const QString& msg)
{
QString m = msg;
int bytes;
QString termination;
- qWarning("Sending: %s", m.latin1());
+ owarn << "Sending: " << m.latin1() << "" << oendl;
/* termination = "\r";
//termination = m_profile.readEntry("Termination");
if(termination == "\n") m = m + "\n";
else if(termination == "\r") m = m + "\r";
else m = m + "\r\n";
*/
m = m.replace(QRegExp("\n"), "\r");
bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
if(bytes < 0)
{
reset();
}
}
QString Dialer::receive()
{
QString buf;
char buffer[1024];
int ret;
int counter = 0;
while(1)
{
ret = ::read(m_fd, buffer, sizeof(buffer));
if(ret > 0)
{
for(int i = 0; i < ret; i++)
buffer[i] = buffer[i] & 0x7F;
buffer[ret] = 0;
- qWarning("Got: %s", buffer);
+ owarn << "Got: " << buffer << "" << oendl;
buf.append(QString(buffer));
if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY")))
{
- //qWarning("Receiving: '%s'", buf.latin1());
+ //owarn << "Receiving: '" << buf.latin1() << "'" << oendl;
cleanshutdown = 1;
return buf;
}else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) {
cleanshutdown = 1;
return QString::null;
}
}
else if(ret < 0)
{
if(errno != EAGAIN) reset();
else if(!(counter++ % 100)) qApp->processEvents();
}
else if(!(counter++ % 100)) qApp->processEvents();
if(usercancel) return QString::null;
}
cleanshutdown = 1;
return QString::null;
}
void Dialer::switchState(int newstate)
{
int oldstate = state;
state = newstate;
switch(state)
{
case state_cancel:
status->setText(QObject::tr("Cancelling..."));
progress->setProgress(0);
break;
case state_preinit:
status->setText(QObject::tr("Searching modem"));
progress->setProgress(10);
break;
case state_init:
status->setText(QObject::tr("Initializing..."));
progress->setProgress(20);
break;
case state_options:
status->setText(QObject::tr("Reset speakers"));
progress->setProgress(30);
break;
case state_dialtone:
status->setText(QObject::tr("Turning off dialtone"));
progress->setProgress(40);
break;
case state_dialing:
if(oldstate != state_dialing) status->setText(QObject::tr("Dial number"));
else status->setText(QObject::tr("Line busy, redialing number"));
progress->setProgress(50);
break;
case state_online:
status->setText(QObject::tr("Connection established"));
progress->setProgress(100);
cancel->setText(QObject::tr("Dismiss"));
break;
}
}
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 99d069f..89b70c6 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,206 +1,208 @@
-
#include "TEmuVt102.h"
-
#include "profile.h"
#include "emulation_handler.h"
#include "script.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
: QObject(0, name )
{
m_teWid = new TEWidget( parent, "TerminalMain");
// use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
// use setWrapAt(80) for normal console with scrollbar
setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
m_teWid->setMinimumSize(150, 70 );
m_script = 0;
parent->resize( m_teWid->calcSize(80, 24 ) );
m_teEmu = new TEmuVt102(m_teWid );
connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
this, SIGNAL(changeSize(int,int) ) );
connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
this, SLOT(recvEmulation(const char*,int) ) );
m_teEmu->setConnect( true );
m_teEmu->setHistory( TRUE );
load( prof );
}
TEmulation* EmulationHandler::emulation() {
return m_teEmu;
}
EmulationHandler::~EmulationHandler() {
if (isRecording())
clearScript();
delete m_teEmu;
delete m_teWid;
}
void EmulationHandler::load( const Profile& prof) {
m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
int num = prof.readNumEntry("Color");
setColor( foreColor(num), backColor(num) );
m_teWid->setBackgroundColor(backColor(num) );
int term = prof.readNumEntry("Terminal", 0) ;
switch(term) {
default:
case Profile::VT102:
case Profile::VT100:
m_teEmu->setKeytrans("vt100.keytab");
break;
case Profile::Linux:
m_teEmu->setKeytrans("linux.keytab");
break;
case Profile::XTerm:
m_teEmu->setKeytrans("default.Keytab");
break;
}
}
void EmulationHandler::recv( const QByteArray& ar) {
m_teEmu->onRcvBlock(ar.data(), ar.count() );
}
void EmulationHandler::recvEmulation(const char* src, int len ) {
QByteArray ar(len);
memcpy(ar.data(), src, sizeof(char) * len );
if (isRecording())
m_script->append(ar);
emit send(ar);
}
QWidget* EmulationHandler::widget() {
return m_teWid;
}
/*
* allocate a new table of colors
*/
void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
ColorEntry table[TABLE_COLORS];
const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
for (int i = 0; i < TABLE_COLORS; i++ ) {
if ( i == 0 || i == 10 ) {
table[i].color = fore;
}else if ( i == 1 || i == 11 ) {
table[i].color = back;
table[i].transparent = 0;
}else {
table[i].color = defaultCt[i].color;
}
}
m_teWid->setColorTable(table );
m_teWid->update();
}
QFont EmulationHandler::font( int id ) {
QString name;
int size = 0;
switch(id ) {
default: // fall through
case 0:
name = QString::fromLatin1("Micro");
size = 4;
break;
case 1:
name = QString::fromLatin1("Fixed");
size = 7;
break;
case 2:
name = QString::fromLatin1("Fixed");
size = 12;
break;
}
QFont font(name, size, QFont::Normal );
font.setFixedPitch(TRUE );
return font;
}
QColor EmulationHandler::foreColor(int col) {
QColor co;
/* we need to switch it */
switch( col ) {
default:
case Profile::White:
/* color is black */
co = Qt::white;
break;
case Profile::Black:
co = Qt::black;
break;
case Profile::Green:
- qWarning("Foreground green");
+ owarn << "Foreground green" << oendl;
co = Qt::green;
break;
case Profile::Orange:
- qWarning("Foreground orange");
+ owarn << "Foreground orange" << oendl;
co.setRgb( 231, 184, 98 );
break;
}
return co;
}
QColor EmulationHandler::backColor(int col ) {
QColor co;
/* we need to switch it */
switch( col ) {
default:
case Profile::White:
/* color is white */
co = Qt::black;
break;
case Profile::Black:
co = Qt::white;
break;
case Profile::Green:
- qWarning("Background black");
+ owarn << "Background black" << oendl;
co = Qt::black;
break;
case Profile::Orange:
- qWarning("Background black");
+ owarn << "Background black" << oendl;
co = Qt::black;
break;
}
return co;
}
QPushButton* EmulationHandler::cornerButton() {
return m_teWid->cornerButton();
}
Script *EmulationHandler::script() {
return m_script;
}
bool EmulationHandler::isRecording() {
return (m_script != 0);
}
void EmulationHandler::startRecording() {
if (!isRecording())
m_script = new Script();
}
void EmulationHandler::clearScript() {
if (isRecording()) {
delete m_script;
m_script = 0;
}
}
void EmulationHandler::runScript(const Script *script) {
emit send(script->script());
}
void EmulationHandler::copy() {
m_teWid->emitSelection();
}
void EmulationHandler::paste() {
m_teWid->pasteClipboard();
}
void EmulationHandler::setWrap(int columns) {
m_teWid->setWrapAt(columns);
}
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp
index ad8ecba..4688551 100644
--- a/noncore/apps/opie-console/emulation_widget.cpp
+++ b/noncore/apps/opie-console/emulation_widget.cpp
@@ -131,171 +131,171 @@ void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int c
for ( int y = 0; y < lins; ++y )
{ int len;
const Character* lcl = &m_image[y * m_columns];
const Character* ext = &newimg[y * m_columns];
if ( ! m_resizing )
for ( int x = 0; x < cols; ++x )
{
// disable, till widget works, WITHOUT blinking
//hasBlinker |= ( ext[x].r & RE_BLINK );
if ( ext[x] != lcl[x] )
{
cr = ext[x].r;
cb = ext[x].b;
if ( ext[x].f != cf ) cf = ext[x].f;
int lln = cols - x;
disstrU[0] = vt100extended( ext[x+0].c );
for ( len = 1; len < lln; ++len )
{
if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] )
break;
disstrU[len] = vt100extended( ext[x+len].c );
}
QString unistr( disstrU, len );
drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true );
x += len -1;
}
}
// make image become newimg
memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) );
}
drawFrame( &paint );
paint.end();
setUpdatesEnabled( true );
/*if ( hasBlinker && !blinkT->isActive() )
blinkT->start(1000); //ms
if ( ! hasBlinker && blinkT->isActive() )
{
blinkT->stop();
blinking = false;
}*/
delete [] disstrU;
}
void EmulationWidget::paintEvent( QPaintEvent* pe )
{
QPainter painter;
const QPixmap* pm = backgroundPixmap();
painter.begin( this );
painter.setBackgroundMode( TransparentMode );
QRect rect = pe->rect().intersect( contentsRect() );
QPoint tL = contentsRect().topLeft();
int tLx = tL.x();
int tLy = tL.y();
int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width));
int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height));
int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width));
int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height));
QChar *disstrU = new QChar[m_columns];
for (int y = luy; y <= rly; y++)
for (int x = lux; x <= rlx; x++)
{
int len = 1;
disstrU[0] = vt100extended(m_image[loc(x,y)].c);
int cf = m_image[loc(x,y)].f;
int cb = m_image[loc(x,y)].b;
int cr = m_image[loc(x,y)].r;
while (x+len <= rlx &&
m_image[loc(x+len,y)].f == cf &&
m_image[loc(x+len,y)].b == cb &&
m_image[loc(x+len,y)].r == cr )
{
disstrU[len] = vt100extended(m_image[loc(x+len,y)].c);
len += 1;
}
QString unistr(disstrU,len);
drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != 0l, false );
x +=len -1;
}
delete [] disstrU;
drawFrame( &painter );
painter.end();
}
void EmulationWidget::calcGeometry()
{
m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() );
- qDebug( QString(" TEST").arg( contentsRect().width() ) );
- qDebug( QString(" TEST").arg( contentsRect().height() ) );
- qDebug("NEUER TESTT!!!!!!!!");
+ odebug << QString(" TEST").arg( contentsRect().width() ) << oendl;
+ odebug << QString(" TEST").arg( contentsRect().height() ) << oendl;
+ odebug << "NEUER TESTT!!!!!!!!" << oendl;
switch( scrollLoc )
{
case SCRNONE :
m_columns = ( contentsRect().width() -2 * rimX ) / f_width;
m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2;
m_brX = m_blX;
m_scrollbar->hide();
break;
case SCRLEFT :
m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
m_blX = m_brX + m_scrollbar->width();
m_scrollbar->move( contentsRect().topLeft() );
m_scrollbar->show();
break;
case SCRIGHT:
m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width;
m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2;
m_brX = m_blX;
m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) );
m_scrollbar->show();
break;
}
m_lines = ( contentsRect().height() - 2 * rimY ) / f_height;
m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2;
}
void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear )
{
- qWarning("Color1 %s", color_table[attr.b].color.name().latin1() );
+ owarn << "Color1 " << color_table[attr.b].color.name().latin1() << "" << oendl;
if ( usePixmap && color_table[attr.b].transparent )
{
painter.setBackgroundMode( TransparentMode );
if ( clear )
erase( rect );
}
else
{
if ( blinking )
painter.fillRect( rect, color_table[attr.b].color );
else
{
painter.setBackgroundMode( OpaqueMode );
- qWarning("Color %s", color_table[attr.b].color.name().latin1() );
+ owarn << "Color " << color_table[attr.b].color.name().latin1() << "" << oendl;
painter.setBackgroundColor( color_table[attr.b].color );
}
}
if ( color_table[attr.f].bold )
painter.setPen( QColor( 0x8F, 0x00, 0x00 ) );
else
painter.setPen( color_table[attr.f].color );
painter.drawText( rect.x(), rect.y() + f_ascent, string );
}
///////////////////////
// scrollbar
// ////////////////////
void EmulationWidget::scroll( int value )
{
}
void EmulationWidget::setScroll( int cursor, int slines )
{
}
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index eb32551..6613183 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,136 +1,141 @@
#include "function_keyboard.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qlayout.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <qdir.h>
#define DEFAULT_ROWS 2
#define DEFAULT_COLS 12
/* FunctionKeyboard {{{1 */
FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS),
pressedRow(0), pressedCol(0) {
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
/*
* all the saving/loading is now done in a profile. downside is that you cant modify
* the keyboard for all profiles, but must do it on a profile-basis
*
Config conf("opie-console-keys");
conf.setGroup("keys");
for (uint r = 0; r < numRows; r++)
for (uint c = 0; c < numCols; c++) {
QString handle = "r" + QString::number(r) + "c" + QString::number(c);
QStringList value_list = conf.readListEntry( handle, '|');
if (value_list.isEmpty()) continue;
keys.insert(
handle,
FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort())
);
}
- //qWarning("loaded %d keys", keys.count());
+ //owarn << "loaded " << keys.count() << " keys" << oendl;
*/
if (keys.isEmpty()) loadDefaults();
}
FunctionKeyboard::~FunctionKeyboard() {}
void FunctionKeyboard::changeRows(int r) {
numRows = r;
// have to do this so the whole thing gets redrawn
hide(); show();
}
void FunctionKeyboard::changeCols(int c) {
numCols = c;
keyWidth = (double)width()/numCols; // have to reset this thing too
repaint(false);
}
void FunctionKeyboard::load (const Profile& prof) {
keys.clear();
numRows = prof.readNumEntry("keb_rows", 2);
numCols = prof.readNumEntry("keb_cols", 10);
keyWidth = (double)width()/numCols; // have to reset this thing too
/* load all the keys to the keyboard */
for (ushort i = 0; i <= numRows - 1; i++)
for (ushort j = 0; j <= numCols - 1; j++) {
QString h = "r" + QString::number(i) + "c" + QString::number(j);
QString values = prof.readEntry("keb_" + h);
if (!values.isEmpty()) {
QStringList l = QStringList::split(QChar('|'), values, TRUE);
keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
// load pixmap if used
if (!l[1].isEmpty()) {
keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
}
}
}
if (keys.isEmpty()) loadDefaults();
hide();
show();
}
void FunctionKeyboard::paintEvent(QPaintEvent *e) {
QPainter p(this);
p.setClipRect(e->rect());
p.fillRect(0, 0, width(), height(), QColor(255,255,255));
p.setPen(QColor(0,0,0));
/* those decimals do count! becomes short if use plain int */
for (double i = 0; i <= width(); i += keyWidth) {
p.drawLine((int)i, 0, (int)i, height());
}
// sometimes the last line doesnt get drawn
p.drawLine(width() -1, 0, width() -1, height());
for (int i = 0; i <= height(); i += keyHeight) {
p.drawLine(0, i, width(), i);
}
for (uint r = 0; r < numRows; r++) {
for (uint c = 0; c < numCols; c++) {
QString handle = "r" + QString::number(r) + "c" + QString::number(c);
if (keys.contains(handle)) {
if (keys[handle].pixFile.isEmpty())
p.drawText( c * keyWidth + 1, r * keyHeight + 1,
keyWidth, keyHeight,
Qt::AlignHCenter | Qt::AlignVCenter,
keys[handle].label
);
else {
ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
p.drawPixmap(centerX, centerY, *keys[handle].pix);
@@ -163,193 +168,193 @@ void FunctionKeyboard::paintKey(uint row, uint col) {
p.drawPixmap(centerX, centerY, *keys[handle].pix);
}
if (col == numCols - 1) {
// sometimes it doesnt draw the last line
p.drawLine((col+1) * keyWidth -1, row * keyHeight,
(col+1) * keyWidth -1, (row + 1) * keyHeight
);
}
}
void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
pressedRow = e->y() / keyHeight;
pressedCol = (int) (e->x() / keyWidth);
paintKey(pressedRow, pressedCol);
// emit that sucker!
FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
emit keyPressed(k, pressedRow, pressedCol, 1);
}
void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
if (pressedRow != -1 && pressedRow != -1) {
int row = pressedRow; pressedRow = -1;
int col = pressedCol; pressedCol = -1;
paintKey(row, col);
FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
emit keyPressed(k, row, col, 0);
}
}
void FunctionKeyboard::resizeEvent(QResizeEvent*) {
/* set he default font height/width */
QFontMetrics fm=fontMetrics();
keyHeight = fm.lineSpacing() + 2;
keyWidth = (double)width()/numCols;
}
QSize FunctionKeyboard::sizeHint() const {
return QSize(width(), keyHeight * numRows + 1);
}
void FunctionKeyboard::loadDefaults() {
numRows = DEFAULT_ROWS;
numCols = DEFAULT_COLS;
keyWidth = (double)width()/numCols; // have to reset this thing too
keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space));
keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0));
keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0));
keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff));
keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
keys.insert( "r1c11", FKey ("F12", 0, 4155, 0));
}
/* FunctionKeyboardConfig {{{1 */
FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
: ProfileDialogKeyWidget(name, parent, na),
selectedRow(0), selectedCol(0)
{
- qWarning("FunctionKeyboardConfig");
+ owarn << "FunctionKeyboardConfig" << oendl;
kb = new FunctionKeyboard(this);
connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool)));
QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this);
QLabel *l = new QLabel("Rows", dimentions);
m_rowBox = new QSpinBox(1, 15, 1, dimentions);
connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
l = new QLabel("Columns", dimentions);
m_colBox = new QSpinBox(1, 15, 1, dimentions);
connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
l = new QLabel("Label", editKey);
m_labels = new QComboBox(true, editKey);
m_labels->setInsertionPolicy(QComboBox::AtCurrent);
m_labels->insertItem("");
QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
for (uint i = 0; i < files.count(); i++) {
m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]);
}
connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&)));
l = new QLabel("Q Keycode", editKey);
m_qvalues = new QComboBox(true, editKey);
m_qvalues->setInsertionPolicy(QComboBox::AtTop);
m_qvalues->setDuplicatesEnabled(false);
m_qvalues->insertItem("");
connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&)));
l = new QLabel("Unicode Value", editKey);
m_uniValues = new QComboBox(true, editKey);
m_uniValues->setInsertionPolicy(QComboBox::AtTop);
m_uniValues->setDuplicatesEnabled(false);
m_uniValues->insertItem("");
connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&)));
QVBoxLayout *root = new QVBoxLayout(this, 2);
root->addWidget(kb);
root->addWidget(dimentions);
root->addWidget(editKey);
}
FunctionKeyboardConfig::~FunctionKeyboardConfig() {
}
void FunctionKeyboardConfig::load (const Profile& prof) {
kb->keys.clear();
kb->loadDefaults();
m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
/* load all the keys to the keyboard */
for (int i = 0; i <= m_rowBox->value() -1; i++)
for (int j = 0; j <= m_colBox->value() -1; j++) {
QString h = "r" + QString::number(i) + "c" + QString::number(j);
QString values = prof.readEntry("keb_" + h);
if (!values.isEmpty()) {
QStringList l = QStringList::split(QChar('|'), values, TRUE);
kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
// load pixmap if used
if (!l[1].isEmpty()) {
kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
}
}
}
}
void FunctionKeyboardConfig::save (Profile& prof) {
prof.writeEntry("keb_rows", m_rowBox->value());
prof.writeEntry("keb_cols", m_colBox->value());
QMap<QString, FKey>::Iterator it;
for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
FKey k = it.data();
QString entry = k.label + "|"
+ k.pixFile + "|"
+ QString::number(k.qcode) + "|"
+ QString::number(k.unicode);
prof.writeEntry("keb_" + it.key(), entry);
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp
index a29fa8e..c102427 100644
--- a/noncore/apps/opie-console/io_bt.cpp
+++ b/noncore/apps/opie-console/io_bt.cpp
@@ -1,93 +1,96 @@
#include "io_bt.h"
+/* OPIE */
+#include <opie2/odebug.h>
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(Opie::Core::OProcess*) ),
this, SLOT( slotExited(Opie::Core::OProcess*) ) );
if ( m_attach->start() ) {
ret = IOSerial::open();
} else {
- qWarning("could not attach to device");
+ owarn << "could not attach to device" << oendl;
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..." );
+ odebug << "Please overload me..." << oendl;
}
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
index 07c2b62..38542f5 100644
--- a/noncore/apps/opie-console/io_irda.cpp
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -1,78 +1,80 @@
-
#include "io_irda.h"
+/* OPIE */
+#include <opie2/odebug.h>
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(Opie::Core::OProcess*) ),
this, SLOT( slotExited(Opie::Core::OProcess*) ) );
if ( m_attach->start() ) {
ret= IOSerial::open();
} else {
// emit error!!!
- qWarning("could not attach to device");
+ owarn << "could not attach to device" << oendl;
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..." );
+ odebug << "Please overload me..." << oendl;
}
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index b74d076..c499dfe 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -1,108 +1,108 @@
#include "io_modem.h"
-
#include "dialer.h"
+/* OPIE */
+#include <opie2/odebug.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..." );
+ odebug << "Please overload me..." << oendl;
}
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index dfb2f83..1bd4338 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -1,110 +1,110 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <qpe/qpeapplication.h>
#include "mainwindow.h"
//#define FSCKED_DISTRIBUTION 1
#ifdef FSCKED_DISTRIBUTION
/*
* The Zaurus rom
*/
class FixIt {
public:
FixIt();
~FixIt();
void fixIt();
/* no real interested in implementing it */
void breakIt() {
};
char* m_file;
};
FixIt::FixIt() {
/* the new inittab */
m_file = "#\n# /etc/inittab"
"#"
""
"# 0 - halt (Do NOT set initdefault to this)"
"# 1 - Single user mode"
"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
"# 3 - Full multiuser mode"
"# 4 - JavaVM(Intent) developer mode"
"# 5 - JavaVM(Intent)"
"# 6 - reboot (Do NOT set initdefault to this)"
"#"
"id:5:initdefault:"
""
"# Specify things to do when starting"
"si::sysinit:/etc/rc.d/rc.sysinit"
""
"l0:0:wait:/root/etc/rc.d/rc 0"
"l1:1:wait:/etc/rc.d/rc 1"
"l2:2:wait:/etc/rc.d/rc 2"
"l3:3:wait:/etc/rc.d/rc 3"
"l4:4:wait:/etc/rc.d/rc 4"
"l5:5:wait:/etc/rc.d/rc 5"
"l6:6:wait:/root/etc/rc.d/rc 6"
""
"# Specify things to do before rebooting"
"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
""
"# Specify program to run on ttyS0"
"s0:24:respawn:/sbin/getty 9600 ttyS0"
"#pd:5:respawn:/etc/sync/serialctl"
""
"# Specify program to run on tty1"
"1:2:respawn:/sbin/getty 9600 tty1"
"ln:345:respawn:survive -l 6 /sbin/launch"
"#qt:5:respawn:/sbin/qt"
""
"# collie sp."
"sy::respawn:/sbin/shsync\n";
}
FixIt::~FixIt() {
}
/*
* the retail Zaurus is broken in many ways
* one is that pppd is listening on our port...
* we've to stop it from that and then do kill(SIGHUP,1);
*/
void FixIt::fixIt() {
::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
QFile file( "/etc/inittab" );
if ( file.open(IO_WriteOnly | IO_Raw ) ) {
file.writeBlock(m_file,strlen(m_file) );
}
file.close();
::kill( SIGHUP, 1 );
}
#endif
int main(int argc, char **argv) {
// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole";
QPEApplication app( argc, argv );
#ifdef FSCKED_DISTRIBUTION
- qWarning("fscked");
+ owarn << "fscked" << oendl;
FixIt it;
it.fixIt();
#endif
MainWindow mw;
mw.setCaption(QObject::tr("Opie Console") );
app.showMainWidget( &mw );
int ap = app.exec();
#ifdef FSCKED_DISTRIBUTION
/* should add a signal handler too */
it.breakIt();
#endif
return ap;
}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 06a8f7d..b403b4d 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,123 +1,126 @@
-#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"
-
+/* OPIE */
+#include <opie2/odebug.h>
+#include <opie2/ofiledialog.h>
+#include <qpe/filemanager.h>
+using namespace Opie::Core;
using namespace Opie::Ui;
+
+/* QT */
+#include <qaction.h>
+#include <qmenubar.h>
+#include <qtoolbar.h>
+#include <qmessagebox.h>
+#include <qwhatsthis.h>
+#include <qfileinfo.h>
+
+/* STD */
+#include <assert.h>
+
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,
@@ -353,326 +356,326 @@ void MainWindow::slotSaveScript() {
}
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() );
+ owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
/* 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!!");
+ owarn << "after remove!!" << oendl;
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!");
+ owarn << "changed!" << oendl;
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() ) );
+ odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
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();
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index 3466e3a..9fdaf73 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,234 +1,237 @@
+#include "modemconfigwidget.h"
+#include "dialdialog.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
+using namespace Opie::Core;
+/* QT */
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include <qpushbutton.h>
#include <qhbox.h>
-#include "modemconfigwidget.h"
-#include "dialdialog.h"
-
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
uint b = bo->count();
for (int i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
return;
}
}
bo->insertItem( str );
bo->setCurrentItem( b );
}
}
ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
m_lay = new QVBoxLayout( this );
m_device = new QLabel(tr( "Modem is attached to:" ), this );
m_deviceCmb = new QComboBox(this );
m_deviceCmb->setEditable( TRUE );
QLabel* telLabel = new QLabel( this );
telLabel->setText( tr( "Enter telefon number here:" ) );
QHBox *buttonBox = new QHBox( this );
m_telNumber = new QLineEdit( buttonBox );
QPushButton *atButton = new QPushButton( buttonBox );
atButton->setText( tr( "AT commands" ) );
connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) );
QPushButton *dialButton = new QPushButton( buttonBox );
dialButton->setText( tr( "Enter number" ) );
connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) );
m_base = new IOLayerBase( this, "base" );
m_lay->addWidget( m_device );
m_lay->addWidget( m_deviceCmb );
m_lay->addWidget( telLabel );
m_lay->addWidget( buttonBox );
m_lay->addWidget( m_base );
m_lay->addStretch( 0 );
m_deviceCmb->insertItem( "/dev/ttyS0" );
m_deviceCmb->insertItem( "/dev/ttyS1" );
m_deviceCmb->insertItem( "/dev/ttyS2" );
atConf = new ATConfigDialog( this, "ATConfig", true );
}
ModemConfigWidget::~ModemConfigWidget() {
}
void ModemConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry( "Flow" );
int rad_parity = prof.readNumEntry( "Parity" );
int speed = prof.readNumEntry( "Speed" );
int dbits = prof.readNumEntry("DataBits");
int sbits = prof.readNumEntry("StopBits");
QString number = prof.readEntry( "Number" );
if ( !number.isEmpty() ) {
m_telNumber->setText( number );
}
if ( rad_flow == 1 ) {
m_base->setFlow( IOLayerBase::Hardware );
} else if (rad_flow == 2) {
m_base->setFlow( IOLayerBase::Software );
} else if (rad_flow == 0) {
m_base->setFlow( IOLayerBase::None );
}
if ( rad_parity == 1 ) {
m_base->setParity( IOLayerBase::Even );
} else if ( rad_parity == 2 ){
m_base->setParity( IOLayerBase::Odd );
} else {
m_base->setParity( IOLayerBase::NonePar );
}
switch( speed ) {
case 115200:
m_base->setSpeed( IOLayerBase::Baud_115200 );
break;
case 57600:
m_base->setSpeed( IOLayerBase::Baud_57600 );
break;
case 38400:
m_base->setSpeed( IOLayerBase::Baud_38400 );
break;
case 19200:
m_base->setSpeed( IOLayerBase::Baud_19200 );
break;
case 9600:
default:
m_base->setSpeed( IOLayerBase::Baud_9600 );
break;
}
if ( dbits == 5) {
m_base->setData( IOLayerBase::Data_Five );
} else if (rad_flow == 6) {
m_base->setData( IOLayerBase::Data_Six );
} else if (rad_flow == 7) {
m_base->setData( IOLayerBase::Data_Seven );
} else {
m_base->setData( IOLayerBase::Data_Eight );
}
if ( sbits == 2) {
m_base->setStop( IOLayerBase::Stop_Two );
} else if ( sbits == 15 ) {
m_base->setStop( IOLayerBase::Stop_OnePointFive );
} else {
m_base->setStop( IOLayerBase::Stop_One );
}
atConf->readConfig( prof );
if ( prof.readEntry( "Device" ).isEmpty() ) {
- qWarning("device empty!");
+ owarn << "device empty!" << oendl;
return;
}
setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
}
/*
* save speed,
* flow,
* parity
*/
void ModemConfigWidget::save( Profile& prof ) {
int flow, parity, speed, data, stop;
flow = parity = speed = data = stop = 0;
prof.writeEntry( "Device", m_deviceCmb->currentText() );
switch( m_base->flow() ) {
case IOLayerBase::None:
flow = 0;
break;
case IOLayerBase::Software:
flow = 2;
break;
case IOLayerBase::Hardware:
flow = 1;
break;
}
switch( m_base->parity() ) {
case IOLayerBase::Odd:
parity = 2;
break;
case IOLayerBase::Even:
parity = 1;
break;
case IOLayerBase::NonePar:
parity = 0;
break;
}
switch( m_base->speed() ) {
case IOLayerBase::Baud_115200:
speed = 115200;
break;
case IOLayerBase::Baud_57600:
speed = 57600;
break;
case IOLayerBase::Baud_38400:
speed = 38400;
break;
case IOLayerBase::Baud_19200:
speed = 19200;
break;
case IOLayerBase::Baud_9600:
speed = 9600;
break;
}
switch( m_base->data() ) {
case IOLayerBase::Data_Five:
data = 5;
break;
case IOLayerBase::Data_Six:
data = 6;
break;
case IOLayerBase::Data_Seven:
data = 7;
break;
case IOLayerBase::Data_Eight:
data = 8;
break;
}
switch( m_base->stop() ) {
case IOLayerBase::Stop_One:
stop = 1;
break;
case IOLayerBase::Stop_OnePointFive:
stop = 15;
break;
case IOLayerBase::Stop_Two:
stop = 2;
break;
}
prof.writeEntry( "Flow", flow );
prof.writeEntry( "Parity", parity );
prof.writeEntry( "Speed", speed );
prof.writeEntry("DataBits", data);
prof.writeEntry("StopBits", stop);
prof.writeEntry( "Number", m_telNumber->text() );
atConf->writeConfig(prof);
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 7a15828..f7e33e9 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,76 +1,74 @@
TEMPLATE = app
-TMAKE_CXXFLAGS += -DHAVE_OPENPTY
CONFIG += qt warn_on
-#CONFIG = qt
DESTDIR = $(OPIEDIR)/bin
HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
file_layer.h filetransfer.h \
metafactory.h \
session.h \
mainwindow.h \
profile.h \
profileconfig.h \
profilemanager.h \
tabwidget.h \
configdialog.h \
keytrans.h \
transferdialog.h \
profiledialogwidget.h \
profileeditordialog.h \
default.h \
iolayerbase.h \
serialconfigwidget.h irdaconfigwidget.h \
btconfigwidget.h modemconfigwidget.h \
atconfigdialog.h dialdialog.h \
procctl.h \
function_keyboard.h \
receive_layer.h filereceive.h \
script.h \
dialer.h \
terminalwidget.h \
emulation_handler.h TECommon.h \
TEHistory.h TEScreen.h TEWidget.h \
TEmuVt102.h TEmulation.h MyPty.h \
consoleconfigwidget.h
SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
file_layer.cpp filetransfer.cpp \
main.cpp \
metafactory.cpp \
session.cpp \
mainwindow.cpp \
profile.cpp \
profileconfig.cpp \
profilemanager.cpp \
tabwidget.cpp \
configdialog.cpp \
keytrans.cpp \
transferdialog.cpp \
profiledialogwidget.cpp \
profileeditordialog.cpp \
iolayerbase.cpp \
serialconfigwidget.cpp irdaconfigwidget.cpp \
btconfigwidget.cpp modemconfigwidget.cpp \
atconfigdialog.cpp dialdialog.cpp \
default.cpp procctl.cpp \
function_keyboard.cpp \
receive_layer.cpp filereceive.cpp \
script.cpp \
dialer.cpp \
terminalwidget.cpp \
emulation_handler.cpp TEHistory.cpp \
TEScreen.cpp TEWidget.cpp \
TEmuVt102.cpp TEmulation.cpp MyPty.cpp \
consoleconfigwidget.cpp
INTERFACES = configurebase.ui editbase.ui
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopiecore2 -lopieui2 -lutil
TARGET = opie-console
-
+DEFINES += HAVE_OPENPTY
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp
index fbc5306..f505998 100644
--- a/noncore/apps/opie-console/sz_transfer.cpp
+++ b/noncore/apps/opie-console/sz_transfer.cpp
@@ -1,86 +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(Opie::Core::OProcess*)),
this, SLOT(sent()));
connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
this, SLOT(SzReceivedStdout(Opie::Core::OProcess*,char*,int)));
connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
this, SLOT(SzReceivedStderr(Opie::Core::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);
+ owarn << "recieved from sz on stdout " << buflen << " bytes" << oendl;
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());
+ owarn << "recieved from io_serial " << data.size() << " bytes" << oendl;
// recieved data from the io layer goes to sz
proc->writeStdin(data.data(), data.size());
}
void SzTransfer::sent() {
- qWarning("sent file");
+ owarn << "sent file" << oendl;
//setcbreak(0); /* default */
delete proc;
disconnect(layer(), SIGNAL(received(const QByteArray&)),
this, SLOT(receivedStdin(const QByteArray&)));
}
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp
index 6429e3c..41a91ed 100644
--- a/noncore/apps/opie-console/tabwidget.cpp
+++ b/noncore/apps/opie-console/tabwidget.cpp
@@ -1,45 +1,48 @@
-
#include "tabwidget.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
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() );
+ owarn << "session ses " + ses->name() << oendl;
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/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp
index 6870487..087476b 100644
--- a/noncore/apps/opie-console/terminalwidget.cpp
+++ b/noncore/apps/opie-console/terminalwidget.cpp
@@ -1,168 +1,173 @@
+#include "terminalwidget.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qlabel.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qradiobutton.h>
#include <qhgroupbox.h>
#include <qhbuttongroup.h>
#include <qlayout.h>
-#include "terminalwidget.h"
-
namespace {
enum TermIds {
id_term_vt100 = 0,
id_term_vt102,
id_term_linux,
id_term_xterm
};
enum ColourIds {
id_term_black,
id_term_white,
id_term_green,
id_term_orange
};
enum FontIds {
id_size_small,
id_size_medium,
id_size_large
};
};
TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
const char* na )
: ProfileDialogTerminalWidget( name, parent, na ) {
m_terminal = new QLabel(tr("Terminal Type"), this );
m_terminalBox = new QComboBox(this);
m_colorLabel = new QLabel(tr("Color scheme"), this);
m_colorCmb = new QComboBox(this );
m_groupSize = new QHButtonGroup(tr("Font size"), this );
m_sizeSmall = new QRadioButton(tr("small"), m_groupSize );
m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize );
m_sizeLarge = new QRadioButton(tr("large"), m_groupSize );
m_groupConv = new QHGroupBox( tr("Line-break conversions"), this );
m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv );
m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv );
m_groupOptions = new QHGroupBox( tr("Options"), this );
m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions );
m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions );
m_lroot = new QVBoxLayout( this );
m_typeBox = new QVBoxLayout( m_lroot );
m_colorBox = new QVBoxLayout( m_lroot );
// Layout
m_typeBox->add( m_terminal );
m_typeBox->add( m_terminalBox );
m_lroot->add( m_groupSize );
m_colorBox->add( m_colorLabel );
m_colorBox->add( m_colorCmb );
m_lroot->add( m_groupConv );
m_lroot->add( m_groupOptions );
m_lroot->addStretch( 0 );
// Fill in some options
- qWarning("Options for terminal box");
+ owarn << "Options for terminal box" << oendl;
m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ );
m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */);
m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux );
m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm );
//m_terminalBox->insertItem( tr("ANSI"), id_term_ansi );
m_colorCmb->insertItem( tr("black on white"), id_term_black );
m_colorCmb->insertItem( tr("white on black"), id_term_white );
m_colorCmb->insertItem( tr("green on black"), id_term_green );
m_colorCmb->insertItem( tr("orange on black"), id_term_orange );
// signals + slots
/*
connect(m_terminalBox, SIGNAL(activated(int) ),
this, SLOT(slotTermTerm(int) ) );
connect(m_colorBox, SIGNAL(activated(int) ),
tis, SLOT(slotTermColor(int) ) );
connect(m_groupSize, SIGNAL(activated(int) ),
this, SLOT(slotTermFont(int) ) );
connect(m_optionEcho, SIGNAL(toggled(bool) ),
this, SLOT(slotTermEcho(bool) ) );
connect(m_optionWrap, SIGNAL(toggled(bool) ),
this, SLOT(slotTermWrap(bool) ) );
connect(m_convInbound, SIGNAL(toggled(bool) ),
this, SLOT(slotTermInbound(bool) ) );
connect(m_convOutbound, SIGNAL(toggled(bool) ),
this, SLOT(slotTermOutbound(bool) ) );
*/
}
TerminalWidget::~TerminalWidget() {
}
void TerminalWidget::load( const Profile& prof ) {
int term = prof.readNumEntry("Terminal");
int color = prof.readNumEntry("Color");
int fontsize = prof.readNumEntry("Font");
int opt_echo = prof.readNumEntry("Echo");
int opt_wrap = prof.readNumEntry("Wrap");
int opt_inbound = prof.readNumEntry("Inbound");
int opt_outbound = prof.readNumEntry("Outbound");
switch( term ) {
case Profile::VT100:
m_terminalBox->setCurrentItem(id_term_vt100 );
break;
case Profile::VT102:
m_terminalBox->setCurrentItem(id_term_vt102 );
break;
case Profile::Linux:
m_terminalBox->setCurrentItem(id_term_linux );
break;
case Profile::XTerm:
m_terminalBox->setCurrentItem(id_term_xterm );
break;
default:
m_terminalBox->setCurrentItem(id_term_vt102 );
break;
};
switch( color ) {
case Profile::Black:
m_colorCmb->setCurrentItem(id_term_black );
break;
case Profile::White:
m_colorCmb->setCurrentItem(id_term_white );
break;
case Profile::Green:
m_colorCmb->setCurrentItem(id_term_green );
break;
case Profile::Orange:
m_colorCmb->setCurrentItem(id_term_orange );
break;
default:
break;
};
switch( fontsize ) {
case Profile::Micro:
m_sizeSmall->setChecked(true );
break;
case Profile::Small:
m_sizeMedium->setChecked(true );
break;
case Profile::Medium:
m_sizeLarge->setChecked( true );
break;
default:
m_sizeMedium->setChecked(true );
break;
};
if (opt_echo) m_optionEcho->setChecked( true );
if (opt_wrap) m_optionWrap->setChecked( true );
if (opt_inbound) m_convInbound->setChecked( true );
if (opt_outbound) m_convOutbound->setChecked( true );
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp
index df27055..45fd11d 100644
--- a/noncore/apps/opie-console/test/senderui.cpp
+++ b/noncore/apps/opie-console/test/senderui.cpp
@@ -1,79 +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);
+ owarn << "prof " + prof.readEntry("Device") + " " + str << oendl;
ser = new IOSerial(prof);
connect(ser, SIGNAL(received(const QByteArray&) ),
this, SLOT(got(const QByteArray&) ) );
if ( ser->open() )
- qWarning("opened!!!");
+ owarn << "opened!!!" << oendl;
else
- qWarning("could not open");
+ owarn << "could not open" << oendl;
}
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() );
+ owarn << "sending: " << str.data() << "" << oendl;
str = str.replace( QRegExp("\n"), "\r");
ser->send( str );
}
void SenderUI::got(const QByteArray& ar) {
- qWarning("got:");
+ owarn << "got:" << oendl;
for ( uint i = 0; i < ar.count(); i++ ) {
printf("%c", ar[i] );
}
printf("\n");
}
void SenderUI::fileTransComplete() {
- qWarning("file transfer complete");
+ owarn << "file transfer complete" << oendl;
}
void SenderUI::send() {
}
void SenderUI::slotRev(){
-qWarning("Going to receive!");
+owarn << "Going to receive!" << oendl;
FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
rev->receive();
}
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp
index e17dfd4..c51983f 100644
--- a/noncore/apps/opie-console/widget.cpp
+++ b/noncore/apps/opie-console/widget.cpp
@@ -902,236 +902,236 @@ void Widget::setMouseMarks(bool on)
/* ------------------------------------------------------------------------- */
/* */
/* Clipboard */
/* */
/* ------------------------------------------------------------------------- */
#undef KeyPress
void Widget::emitSelection()
// Paste Clipboard by simulating keypress events
{
#ifndef QT_NO_CLIPBOARD
QString text = QApplication::clipboard()->text();
if ( ! text.isNull() )
{
text.replace(QRegExp("\n"), "\r");
QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
emit keyPressedSignal(&e); // expose as a big fat keypress event
emit clearSelectionSignal();
}
#endif
}
void Widget::emitText(QString text)
{
QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
emit keyPressedSignal(&e); // expose as a big fat keypress event
}
void Widget::pasteClipboard( )
{
emitSelection();
}
void Widget::setSelection(const QString& t)
{
#ifndef QT_NO_CLIPBOARD
// Disconnect signal while WE set the clipboard
QObject *cb = QApplication::clipboard();
QObject::disconnect( cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
QApplication::clipboard()->setText(t);
QObject::connect( cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
#endif
}
void Widget::onClearSelection()
{
emit clearSelectionSignal();
}
/* ------------------------------------------------------------------------- */
/* */
/* Keyboard */
/* */
/* ------------------------------------------------------------------------- */
//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
// due to a bug in `QT' or the ignorance of the author to prevent
// repaint events being emitted to the screen whenever one leaves
// or reenters the screen to/from another application.
//
// Troll says one needs to change focusInEvent() and focusOutEvent(),
// which would also let you have an in-focus cursor and an out-focus
// cursor like xterm does.
// for the auto-hide cursor feature, I added empty focusInEvent() and
// focusOutEvent() so that update() isn't called.
// For auto-hide, we need to get keypress-events, but we only get them when
// we have focus.
void Widget::doScroll(int lines)
{
scrollbar->setValue(scrollbar->value()+lines);
}
bool Widget::eventFilter( QObject *obj, QEvent *e )
{
if ( (e->type() == QEvent::Accel ||
e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
static_cast<QKeyEvent *>( e )->ignore();
return true;
}
if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
return FALSE; // not us
if ( e->type() == QEvent::Wheel) {
QApplication::sendEvent(scrollbar, e);
}
#ifdef FAKE_CTRL_AND_ALT
static bool control = FALSE;
static bool alt = FALSE;
-// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
+// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
bool dele=FALSE;
if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
QKeyEvent* ke = (QKeyEvent*)e;
bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
switch (ke->key()) {
case Key_F9: // let this be "Control"
control = keydown;
e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
dele=TRUE;
break;
case Key_F13: // let this be "Alt"
alt = keydown;
e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
dele=TRUE;
break;
default:
if ( control ) {
int a = toupper(ke->ascii())-64;
if ( a >= 0 && a < ' ' ) {
e = new QKeyEvent(e->type(), ke->key(),
a, ke->state()|ControlButton, QChar(a,0));
dele=TRUE;
}
}
if ( alt ) {
e = new QKeyEvent(e->type(), ke->key(),
ke->ascii(), ke->state()|AltButton, ke->text());
dele=TRUE;
}
}
}
#endif
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent* ke = (QKeyEvent*)e;
actSel=0; // Key stroke implies a screen update, so Widget won't
// know where the current selection is.
-// qDebug("key pressed is 0x%x",ke->key());
+// odebug << "key pressed is 0x" << ke->key() << "" << oendl;
if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
-// qDebug("key pressed 2 is 0x%x",ke->key());
+// odebug << "key pressed 2 is 0x" << ke->key() << "" << oendl;
emitText("\\"); // expose
} else
emit keyPressedSignal(ke); // expose
ke->accept();
#ifdef FAKE_CTRL_AND_ALT
if ( dele ) delete e;
#endif
return true; // stop the event
}
if ( e->type() == QEvent::Enter ) {
QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
}
if ( e->type() == QEvent::Leave ) {
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
}
return QFrame::eventFilter( obj, e );
}
/* ------------------------------------------------------------------------- */
/* */
/* Frame */
/* */
/* ------------------------------------------------------------------------- */
void Widget::frameChanged()
{
propagateSize();
update();
}
/* ------------------------------------------------------------------------- */
/* */
/* Sound */
/* */
/* ------------------------------------------------------------------------- */
void Widget::Bell()
{
QApplication::beep();
}
/* ------------------------------------------------------------------------- */
/* */
/* Auxiluary */
/* */
/* ------------------------------------------------------------------------- */
void Widget::clearImage()
// initialize the image
// for internal use only
{
for (int y = 0; y < lines; y++)
for (int x = 0; x < columns; x++)
{
image[loc(x,y)].c = 0xff; //' ';
image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
}
}
// Create Image ///////////////////////////////////////////////////////
void Widget::calcGeometry()
{
//FIXME: set rimX == rimY == 0 when running in full screen mode.
scrollbar->resize(QApplication::style().scrollBarExtent().width(),
contentsRect().height());
switch(scrollLoc)
{
case SCRNONE :
columns = ( contentsRect().width() - 2 * rimX ) / font_w;
blX = (contentsRect().width() - (columns*font_w) ) / 2;
brX = blX;
scrollbar->hide();
break;
case SCRLEFT :
columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
blX = brX + scrollbar->width();
scrollbar->move(contentsRect().topLeft());
scrollbar->show();
break;
case SCRRIGHT:
columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
brX = blX;
scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
scrollbar->show();
break;
}
//FIXME: support 'rounding' styles
lines = ( contentsRect().height() - 2 * rimY ) / font_h;
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp
index 96dda1c..ab25919 100644
--- a/noncore/apps/opie-console/widget_layer.cpp
+++ b/noncore/apps/opie-console/widget_layer.cpp
@@ -1,214 +1,214 @@
/* ------------------------------------------------------------------------- */
/* */
/* widget_layer.cpp Widget Layer */
/* */
/* opie developers <opie@handhelds.org> */
/* */
/* ------------------------------------------------------------------------- */
#include "widget_layer.h"
#include <string.h>
//#include <
WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name )
{
// get the clipboard
m_clipboard = QApplication::clipboard();
// when data on clipboard changes, clear selection
QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ),
(QObject*)this, SLOT( onClearSelection() ) );
// initialize vars:
m_lines = 1;
m_columns = 1;
m_resizing = false;
// just for demonstrating
//m_image = QArray<Character>( m_lines * m_columns );
m_image = QArray<Character>( 1 );
// we need to install an event filter,
// to emit keypresses.
qApp->installEventFilter( this );
}
WidgetLayer::~WidgetLayer()
{
// clean up
delete m_image;
}
QSize WidgetLayer::sizeHint()
{
return size();
}
/* --------------------------------- audio ---------------------------------- */
void WidgetLayer::bell()
{
QApplication::beep();
}
bool WidgetLayer::eventFilter( QObject *obj, QEvent *e )
{
if ( (e->type() == QEvent::Accel ||
e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
static_cast<QKeyEvent *>( e )->ignore();
return true;
}
if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
return false; // not us
#ifdef FAKE_CTRL_AND_ALT
static bool control = false;
static bool alt = false;
-// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
+// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
bool dele = false;
if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
QKeyEvent* ke = (QKeyEvent*)e;
bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
switch (ke->key()) {
case Key_F9: // let this be "Control"
control = keydown;
e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
dele=TRUE;
break;
case Key_F13: // let this be "Alt"
alt = keydown;
e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
dele=TRUE;
break;
default:
if ( control ) {
int a = toupper(ke->ascii())-64;
if ( a >= 0 && a < ' ' ) {
e = new QKeyEvent(e->type(), ke->key(),
a, ke->state()|ControlButton,
QChar(a,0));
dele=TRUE;
}
}
if ( alt ) {
e = new QKeyEvent(e->type(), ke->key(),
ke->ascii(), ke->state()|AltButton, ke->text());
dele=TRUE;
}
}
}
#endif
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent* ke = (QKeyEvent*)e;
//actSel=0; // Key stroke implies a screen update, so Widget won't
// know where the current selection is.
-// qDebug("key pressed is 0x%x",ke->key());
+// odebug << "key pressed is 0x" << ke->key() << "" << oendl;
if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
insertText("\\"); // expose
} else
emit keyPressed( ke ); // expose
ke->accept();
#ifdef FAKE_CTRL_AND_ALT
if ( dele ) delete e;
#endif
return true; // stop the event
}
return QFrame::eventFilter( obj, e );
}
/* --------------------------------- screen --------------------------------- */
void WidgetLayer::propagateSize()
{
QArray<Character> oldimage = m_image.copy();
int oldlines = m_lines;
int oldcolumns = m_columns;
makeImage();
// copy old image, to reduce flicker
if ( ! oldimage.isEmpty() )
{
int lins = QMIN( oldlines, m_lines );
int cols = QMIN( oldcolumns, m_columns );
for ( int lin = 0; lin < lins; ++lin )
{
memcpy( (void*) &m_image[m_columns*lin],
(void*) &oldimage[oldcolumns*lin],
cols*sizeof( Character ) );
}
}
else
clearImage();
delete oldimage;
m_resizing = true;
emit imageSizeChanged( m_lines, m_columns );
m_resizing = false;
}
void WidgetLayer::makeImage()
{
calcGeometry();
m_image = QArray<Character>( m_columns * m_lines );
clearImage();
}
void WidgetLayer::clearImage()
{
//should this belong here??
for ( int y = 0; y < m_lines; y++ )
for ( int x = 0; x < m_columns; x++ )
{
m_image[loc(x,y)].c = 0xff;
m_image[loc(x,y)].f = 0xff;
m_image[loc(x,y)].b = 0xff;
m_image[loc(x,y)].r = 0xff;
}
}
/* --------------------------------- selection ------------------------------ */
void WidgetLayer::pasteClipboard()
{
insertSelection();
}
void WidgetLayer::insertSelection()
{
QString text = QApplication::clipboard()->text();
if ( ! text.isNull() )
{
text.replace( QRegExp( "\n" ), "\r" );
insertText( text );
// selection should be unselected
emit selectionCleared();
}
}
void WidgetLayer::insertText( QString text )
{
// text is inserted as key event
QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text);
emit keyPressed( &e );
}
void WidgetLayer::onClearSelection()
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp
index 90e1a70..aa03060 100644
--- a/noncore/apps/opie-write/mainwindow.cpp
+++ b/noncore/apps/opie-write/mainwindow.cpp
@@ -1,124 +1,128 @@
/**********************************************************************
** 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"
+
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/fileselector.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
#include <qpe/fontdatabase.h>
+using namespace Opie::Core;
-//#include "qspellchecker.h"
+/* QT */
#include "qtextedit.h"
#include <qaction.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qtabwidget.h>
#include <qapplication.h>
#include <qfontdatabase.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qfileinfo.h>
#include <qfile.h>
#include <qfiledialog.h>
#include <qprinter.h>
#include <qpaintdevicemetrics.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qcolordialog.h>
#include <qpainter.h>
#include <qstyle.h>
class ButtonMenu : public QToolButton
{
Q_OBJECT
public:
ButtonMenu( QWidget *parent, const char *name=0 )
: QToolButton( parent, name ), current(0)
{
setPopup( new QPopupMenu( this ) );
setPopupDelay( 1 );
connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) );
}
int insertItem(const QIconSet &icon, const QString &text, int id ) {
if ( !popup()->count() ) {
setIconSet( icon );
current = id;
}
return popup()->insertItem( icon, text, id );
}
void setCurrentItem( int id ) {
if ( id != current ) {
current = id;
setIconSet( *popup()->iconSet( id ) );
}
}
virtual QSize sizeHint() const {
return QToolButton::sizeHint() + QSize( 4, 0 );
}
signals:
void activated( int id );
protected slots:
void selected( int id ) {
current = id;
setIconSet( *popup()->iconSet( id ) );
emit activated( id );
}
protected:
virtual void drawButtonLabel( QPainter *p ) {
p->translate( -4, 0 );
QToolButton::drawButtonLabel( p );
p->translate( 4, 0 );
}
private:
int current;
};
//===========================================================================
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl )
: QMainWindow( parent, name, fl ),
doc( 0 )
{
setRightJustification(TRUE);
editorStack = new QWidgetStack( this );
fileSelector = new FileSelector( "text/html",
editorStack, "fileselector" );
fileSelector->setCloseVisible( FALSE );
editorStack->addWidget( fileSelector, 0 );
editor = new Qt3::QTextEdit( editorStack );
editor->setTextFormat( Qt::RichText );
editorStack->addWidget( editor, 1 );
setupActions();
QObject::connect( fileSelector, SIGNAL(closeMe()),
@@ -351,224 +355,224 @@ void MainWindow::textFamily( const QString &f )
currentEditor()->setFamily( f );
currentEditor()->viewport()->setFocus();
}
void MainWindow::textSize( const QString &p )
{
if ( !currentEditor() )
return;
currentEditor()->setPointSize( p.toInt() );
currentEditor()->viewport()->setFocus();
}
void MainWindow::textStyle( int i )
{
if ( !currentEditor() )
return;
if ( i == 0 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock,
Qt3::QStyleSheetItem::ListDisc );
else if ( i == 1 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListDisc );
else if ( i == 2 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListCircle );
else if ( i == 3 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListSquare );
else if ( i == 4 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListDecimal );
else if ( i == 5 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListLowerAlpha );
else if ( i == 6 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListUpperAlpha );
currentEditor()->viewport()->setFocus();
}
void MainWindow::textAlign( int a )
{
if ( !currentEditor() )
return;
editor->setAlignment( a );
}
void MainWindow::fontChanged( const QFont &f )
{
comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) );
updateFontSizeCombo( f );
comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
actionTextBold->setOn( f.bold() );
actionTextItalic->setOn( f.italic() );
actionTextUnderline->setOn( f.underline() );
}
void MainWindow::colorChanged( const QColor & )
{
}
void MainWindow::alignmentChanged( int a )
{
if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) {
alignMenu->setCurrentItem(AlignLeft);
} else if ( ( a & AlignCenter ) ) {
alignMenu->setCurrentItem(AlignCenter);
} else if ( ( a & AlignRight ) ) {
alignMenu->setCurrentItem(AlignRight);
} else if ( ( a & Qt3::AlignJustify ) ) {
alignMenu->setCurrentItem(Qt3::AlignJustify);
}
}
void MainWindow::editorChanged( QWidget * )
{
if ( !currentEditor() )
return;
fontChanged( currentEditor()->font() );
colorChanged( currentEditor()->color() );
alignmentChanged( currentEditor()->alignment() );
}
void MainWindow::fileOpen()
{
save();
editorStack->raiseWidget( fileSelector );
fileSelector->reread();
hideEditTools();
fileSelector->setNewVisible( TRUE );
clear();
updateCaption();
}
void MainWindow::fileRevert()
{
- qDebug( "QMainWindow::fileRevert needs to be done" );
+ odebug << "QMainWindow::fileRevert needs to be done" << oendl;
}
void MainWindow::fileNew()
{
editor->setTextFormat( Qt::RichText );
save();
newFile(DocLnk());
}
void MainWindow::insertTable()
{
- qDebug( "MainWindow::insertTable() needs to be done" );
+ odebug << "MainWindow::insertTable() needs to be done" << oendl;
}
void MainWindow::newFile( const DocLnk &dl )
{
DocLnk nf = dl;
nf.setType( "text/html" );
clear();
editorStack->raiseWidget( editor );
editor->viewport()->setFocus();
doc = new DocLnk( nf );
updateCaption();
}
void MainWindow::openFile( const DocLnk &dl )
{
FileManager fm;
QString txt;
if ( !fm.loadFile( dl, txt ) )
- qDebug( "couldn't open file" );
+ odebug << "couldn't open file" << oendl;
clear();
editorStack->raiseWidget( editor );
editor->viewport()->setFocus();
doc = new DocLnk( dl );
editor->setText( txt );
editor->setModified( FALSE );
updateCaption();
}
void MainWindow::showEditTools( void )
{
tbMenu->show();
tbEdit->show();
tbFont->show();
tbStyle->show();
}
void MainWindow::hideEditTools( void )
{
// let's reset the buttons...
actionTextBold->setOn( FALSE );
actionTextItalic->setOn( FALSE );
actionTextUnderline->setOn( FALSE );
//comboFont->setCurrentText( QApplication::font().family() );
comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) );
tbMenu->hide();
tbEdit->hide();
tbFont->hide();
tbStyle->hide();
}
void MainWindow::save()
{
if ( !doc )
return;
if ( !editor->isModified() )
return;
QString rt = editor->text();
// quick hack to get around formatting...
editor->setTextFormat( Qt::PlainText );
QString pt = editor->text();
editor->setTextFormat( Qt::RichText );
if ( doc->name().isEmpty() ) {
unsigned ispace = pt.find( ' ' );
unsigned ienter = pt.find( '\n' );
int i = (ispace < ienter) ? ispace : ienter;
QString docname;
if ( i == -1 ) {
if ( pt.isEmpty() )
docname = "Empty Text";
else
docname = pt;
} else {
docname = pt.left( i );
}
doc->setName(docname);
}
FileManager fm;
fm.saveFile( *doc, rt );
}
void MainWindow::clear()
{
delete doc;
doc = 0;
editor->clear();
}
void MainWindow::updateCaption()
{
if ( !doc )
setCaption( tr("Rich Text Editor") );
else {
QString s = doc->name();
if ( s.isEmpty() )
s = tr( "Unnamed" );
setCaption( s + " - " + tr("Rich Text Editor") );
}
}
void MainWindow::closeEvent( QCloseEvent *e )
{
if ( editorStack->visibleWidget() == editor ) {
// call fileOpen instead, don't close it
fileOpen();
e->ignore();
} else {
e->accept();
}
}
#include "mainwindow.moc"
diff --git a/noncore/apps/opie-write/opie-write.pro b/noncore/apps/opie-write/opie-write.pro
index 044ce7e..8e514d4 100644
--- a/noncore/apps/opie-write/opie-write.pro
+++ b/noncore/apps/opie-write/opie-write.pro
@@ -1,27 +1,26 @@
-CONFIG += qt warn on quick-app
-
+CONFIG += qt warn on quick-app
HEADERS = qcleanuphandler.h \
qcomplextext_p.h \
qrichtext_p.h \
qstylesheet.h \
qtextedit.h \
mainwindow.h
SOURCES = qcomplextext.cpp \
qstylesheet.cpp \
qrichtext_p.cpp \
qrichtext.cpp \
qtextedit.cpp \
main.cpp \
mainwindow.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopiecore2
TARGET = opie-write
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-write/qcomplextext.cpp b/noncore/apps/opie-write/qcomplextext.cpp
index 473f184..00a91c5 100644
--- a/noncore/apps/opie-write/qcomplextext.cpp
+++ b/noncore/apps/opie-write/qcomplextext.cpp
@@ -13,134 +13,134 @@
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** 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.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial 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.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** 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 "qrichtext_p.h"
#include <stdlib.h>
using namespace Qt3;
// -----------------------------------------------------
/* a small helper class used internally to resolve Bidi embedding levels.
Each line of text caches the embedding level at the start of the line for faster
relayouting
*/
QBidiContext::QBidiContext( uchar l, QChar::Direction e, QBidiContext *p, bool o )
: level(l) , override(o), dir(e)
{
if ( p )
p->ref();
parent = p;
count = 0;
}
QBidiContext::~QBidiContext()
{
if( parent && parent->deref() )
delete parent;
}
/*
Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on
arabic).
Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent).
transparent joining is not encoded in QChar::joining(), but applies to all combining marks and format marks.
Right join-causing: dual + center
Left join-causing: dual + right + center
Rules are as follows (for a string already in visual order, as we have it here):
R1 Transparent characters do not affect joining behaviour.
R2 A right joining character, that has a right join-causing char on the right will get form XRight
(R3 A left joining character, that has a left join-causing char on the left will get form XLeft)
Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode
R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on
the right will get form XMedial
R5 A dual joining character, that has a right join causing char on the right, and no left join causing char on the left
will get form XRight
R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right
will get form XLeft
R7 Otherwise the character will get form XIsolated
Additionally we have to do the minimal ligature support for lam-alef ligatures:
L1 Transparent characters do not affect ligature behaviour.
L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft)
L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated)
The two functions defined in this class do shaping in visual and logical order. For logical order just replace right with
previous and left with next in the above rules ;-)
*/
/*
Two small helper functions for arabic shaping. They get the next shape causing character on either
side of the char in question. Implements rule R1.
leftChar() returns true if the char to the left is a left join-causing char
rightChar() returns true if the char to the right is a right join-causing char
*/
static inline const QChar *prevChar( const QString &str, int pos )
{
- //qDebug("leftChar: pos=%d", pos);
+ //odebug << "leftChar: pos=" << pos << "" << oendl;
pos--;
const QChar *ch = str.unicode() + pos;
while( pos > -1 ) {
if( !ch->isMark() )
return ch;
pos--;
ch--;
}
return &QChar::replacement;
}
static inline const QChar *nextChar( const QString &str, int pos)
{
pos++;
int len = str.length();
const QChar *ch = str.unicode() + pos;
while( pos < len ) {
- //qDebug("rightChar: %d isLetter=%d, joining=%d", pos, ch.isLetter(), ch.joining());
+ //odebug << "rightChar: " << pos << " isLetter=" << ch.isLetter() << ", joining=" << ch.joining() << "" << oendl;
if( !ch->isMark() )
return ch;
// assume it's a transparent char, this might not be 100% correct
pos++;
ch++;
}
return &QChar::replacement;
}
static inline bool prevVisualCharJoins( const QString &str, int pos)
{
return ( prevChar( str, pos )->joining() != QChar::OtherJoining );
}
static inline bool nextVisualCharJoins( const QString &str, int pos)
{
QChar::Joining join = nextChar( str, pos )->joining();
return ( join == QChar::Dual || join == QChar::Center );
}
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp
index b77a0fc..c27eb1e 100644
--- a/noncore/apps/opie-write/qrichtext.cpp
+++ b/noncore/apps/opie-write/qrichtext.cpp
@@ -1,311 +1,317 @@
/****************************************************************************
** $Id$
**
** Implementation of the internal Qt classes dealing with rich text
**
** Created : 990101
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the kernel module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** 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.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial 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.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** 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 "qrichtext_p.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include "qdragobject.h"
#include "qpaintdevicemetrics.h"
#include "qdrawutil.h"
#include "qcleanuphandler.h"
+/* STD */
#include <stdlib.h>
using namespace Qt3;
static QTextCursor* richTextExportStart = 0;
static QTextCursor* richTextExportEnd = 0;
static QTextFormatCollection *qFormatCollection = 0;
const int border_tolerance = 2;
#ifdef Q_WS_WIN
#include "qt_windows.h"
#endif
#define QChar_linesep QChar(0x2028U)
static inline bool is_printer( QPainter *p )
{
if ( !p || !p->device() )
return FALSE;
return p->device()->devType() == QInternal::Printer;
}
static inline int scale( int value, QPainter *painter )
{
if ( is_printer( painter ) ) {
QPaintDeviceMetrics metrics( painter->device() );
#if defined(Q_WS_X11)
value = value * metrics.logicalDpiY() / QPaintDevice::x11AppDpiY();
#elif defined (Q_WS_WIN)
HDC hdc = GetDC( 0 );
int gdc = GetDeviceCaps( hdc, LOGPIXELSY );
if ( gdc )
value = value * metrics.logicalDpiY() / gdc;
ReleaseDC( 0, hdc );
#elif defined (Q_WS_MAC)
value = value * metrics.logicalDpiY() / 75; // ##### FIXME
#elif defined (Q_WS_QWS)
value = value * metrics.logicalDpiY() / 75;
#endif
}
return value;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void QTextCommandHistory::addCommand( QTextCommand *cmd )
{
if ( current < (int)history.count() - 1 ) {
QPtrList<QTextCommand> commands;
commands.setAutoDelete( FALSE );
for( int i = 0; i <= current; ++i ) {
commands.insert( i, history.at( 0 ) );
history.take( 0 );
}
commands.append( cmd );
history.clear();
history = commands;
history.setAutoDelete( TRUE );
} else {
history.append( cmd );
}
if ( (int)history.count() > steps )
history.removeFirst();
else
++current;
}
QTextCursor *QTextCommandHistory::undo( QTextCursor *c )
{
if ( current > -1 ) {
QTextCursor *c2 = history.at( current )->unexecute( c );
--current;
return c2;
}
return 0;
}
QTextCursor *QTextCommandHistory::redo( QTextCursor *c )
{
if ( current > -1 ) {
if ( current < (int)history.count() - 1 ) {
++current;
return history.at( current )->execute( c );
}
} else {
if ( history.count() > 0 ) {
++current;
return history.at( current )->execute( c );
}
}
return 0;
}
bool QTextCommandHistory::isUndoAvailable()
{
return current > -1;
}
bool QTextCommandHistory::isRedoAvailable()
{
return current > -1 && current < (int)history.count() - 1 || current == -1 && history.count() > 0;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
QTextDeleteCommand::QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
const QByteArray& oldStyleInfo )
: QTextCommand( d ), id( i ), index( idx ), parag( 0 ), text( str ), styleInformation( oldStyleInfo )
{
for ( int j = 0; j < (int)text.size(); ++j ) {
if ( text[ j ].format() )
text[ j ].format()->addRef();
}
}
QTextDeleteCommand::QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str )
: QTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str )
{
for ( int i = 0; i < (int)text.size(); ++i ) {
if ( text[ i ].format() )
text[ i ].format()->addRef();
}
}
QTextDeleteCommand::~QTextDeleteCommand()
{
for ( int i = 0; i < (int)text.size(); ++i ) {
if ( text[ i ].format() )
text[ i ].format()->removeRef();
}
text.resize( 0 );
}
QTextCursor *QTextDeleteCommand::execute( QTextCursor *c )
{
QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
if ( !s ) {
- qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() );
+ owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
return 0;
}
cursor.setParagraph( s );
cursor.setIndex( index );
int len = text.size();
if ( c )
*c = cursor;
if ( doc ) {
doc->setSelectionStart( QTextDocument::Temp, cursor );
for ( int i = 0; i < len; ++i )
cursor.gotoNextLetter();
doc->setSelectionEnd( QTextDocument::Temp, cursor );
doc->removeSelectedText( QTextDocument::Temp, &cursor );
if ( c )
*c = cursor;
} else {
s->remove( index, len );
}
return c;
}
QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c )
{
QTextParagraph *s = doc ? doc->paragAt( id ) : parag;
if ( !s ) {
- qWarning( "can't locate parag at %d, last parag: %d", id, doc->lastParagraph()->paragId() );
+ owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl;
return 0;
}
cursor.setParagraph( s );
cursor.setIndex( index );
QString str = QTextString::toString( text );
cursor.insert( str, TRUE, &text );
cursor.setParagraph( s );
cursor.setIndex( index );
if ( c ) {
c->setParagraph( s );
c->setIndex( index );
for ( int i = 0; i < (int)text.size(); ++i )
c->gotoNextLetter();
}
if ( !styleInformation.isEmpty() ) {
QDataStream styleStream( styleInformation, IO_ReadOnly );
int num;
styleStream >> num;
QTextParagraph *p = s;
while ( num-- && p ) {
p->readStyleInformation( styleStream );
p = p->next();
}
}
s = cursor.paragraph();
while ( s ) {
s->format();
s->setChanged( TRUE );
if ( s == c->paragraph() )
break;
s = s->next();
}
return &cursor;
}
QTextFormatCommand::QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx,
const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl )
: QTextCommand( d ), startId( sid ), startIndex( sidx ), endId( eid ), endIndex( eidx ), format( f ), oldFormats( old ), flags( fl )
{
format = d->formatCollection()->format( f );
for ( int j = 0; j < (int)oldFormats.size(); ++j ) {
if ( oldFormats[ j ].format() )
oldFormats[ j ].format()->addRef();
}
}
QTextFormatCommand::~QTextFormatCommand()
{
format->removeRef();
for ( int j = 0; j < (int)oldFormats.size(); ++j ) {
if ( oldFormats[ j ].format() )
oldFormats[ j ].format()->removeRef();
}
}
QTextCursor *QTextFormatCommand::execute( QTextCursor *c )
{
QTextParagraph *sp = doc->paragAt( startId );
QTextParagraph *ep = doc->paragAt( endId );
if ( !sp || !ep )
return c;
QTextCursor start( doc );
start.setParagraph( sp );
start.setIndex( startIndex );
QTextCursor end( doc );
end.setParagraph( ep );
end.setIndex( endIndex );
doc->setSelectionStart( QTextDocument::Temp, start );
doc->setSelectionEnd( QTextDocument::Temp, end );
doc->setFormat( QTextDocument::Temp, format, flags );
doc->removeSelection( QTextDocument::Temp );
if ( endIndex == ep->length() )
end.gotoLeft();
*c = end;
return c;
}
QTextCursor *QTextFormatCommand::unexecute( QTextCursor *c )
{
QTextParagraph *sp = doc->paragAt( startId );
QTextParagraph *ep = doc->paragAt( endId );
if ( !sp || !ep )
return 0;
int idx = startIndex;
int fIndex = 0;
for ( ;; ) {
if ( oldFormats.at( fIndex ).c == '\n' ) {
if ( idx > 0 ) {
if ( idx < sp->length() && fIndex > 0 )
sp->setFormat( idx, 1, oldFormats.at( fIndex - 1 ).format() );
@@ -1451,196 +1457,196 @@ void QTextDocument::setRichTextInternal( const QString &text, QTextCursor* curso
NEWPAR;
}
// set rtext spacing to FALSE for the initial paragraph.
curpar->rtext = FALSE;
QString wellKnownTags = "br hr wsp table qt body meta title";
while ( pos < length ) {
if ( hasPrefix(doc, length, pos, '<' ) ){
if ( !hasPrefix( doc, length, pos+1, QChar('/') ) ) {
// open tag
QMap<QString, QString> attr;
bool emptyTag = FALSE;
QString tagname = parseOpenTag(doc, length, pos, attr, emptyTag);
if ( tagname.isEmpty() )
continue; // nothing we could do with this, probably parse error
const QStyleSheetItem* nstyle = sheet_->item(tagname);
if ( nstyle ) {
// we might have to close some 'forgotten' tags
while ( !nstyle->allowedInContext( curtag.style ) ) {
QString msg;
msg.sprintf( "QText Warning: Document not valid ( '%s' not allowed in '%s' #%d)",
tagname.ascii(), curtag.style->name().ascii(), pos);
sheet_->error( msg );
if ( tags.isEmpty() )
break;
curtag = tags.pop();
}
/* special handling for p and li for HTML
compatibility. We do not want to embed blocks in
p, and we do not want new blocks inside non-empty
lis. Plus we want to merge empty lis sometimes. */
if( nstyle->displayMode() == QStyleSheetItem::DisplayListItem ) {
canMergeLi = TRUE;
} else if ( nstyle->displayMode() == QStyleSheetItem::DisplayBlock ) {
while ( curtag.style->name() == "p" ) {
if ( tags.isEmpty() )
break;
curtag = tags.pop();
}
if ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ) {
// we are in a li and a new block comes along
if ( nstyle->name() == "ul" || nstyle->name() == "ol" )
hasNewPar = FALSE; // we want an empty li (like most browsers)
if ( !hasNewPar ) {
/* do not add new blocks inside
non-empty lis */
while ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ) {
if ( tags.isEmpty() )
break;
curtag = tags.pop();
}
} else if ( canMergeLi ) {
/* we have an empty li and a block
comes along, merge them */
nstyle = curtag.style;
}
canMergeLi = FALSE;
}
}
}
QTextCustomItem* custom = 0;
// some well-known tags, some have a nstyle, some not
if ( wellKnownTags.find( tagname ) != -1 ) {
if ( tagname == "br" ) {
emptyTag = space = TRUE;
int index = QMAX( curpar->length(),1) - 1;
QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor );
curpar->append( QChar_linesep );
curpar->setFormat( index, 1, &format );
} else if ( tagname == "hr" ) {
emptyTag = space = TRUE;
custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this );
NEWPAR;
} else if ( tagname == "table" ) {
emptyTag = space = TRUE;
QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor );
curpar->setAlignment( curtag.alignment );
custom = parseTable( attr, format, doc, length, pos, curpar );
} else if ( tagname == "qt" || tagname == "body" ) {
if ( attr.contains( "bgcolor" ) ) {
QBrush *b = new QBrush( QColor( attr["bgcolor"] ) );
setPaper( b );
}
if ( attr.contains( "background" ) ) {
QImage img;
QString bg = attr["background"];
const QMimeSource* m = factory_->data( bg, contxt );
if ( !m ) {
- qWarning("QRichText: no mimesource for %s", bg.latin1() );
+ owarn << "QRichText: no mimesource for " << bg.latin1() << "" << oendl;
} else {
if ( !QImageDrag::decode( m, img ) ) {
- qWarning("QTextImage: cannot decode %s", bg.latin1() );
+ owarn << "QTextImage: cannot decode " << bg.latin1() << "" << oendl;
}
}
if ( !img.isNull() ) {
QPixmap pm;
pm.convertFromImage( img );
QBrush *b = new QBrush( QColor(), pm );
setPaper( b );
}
}
if ( attr.contains( "text" ) ) {
QColor c( attr["text"] );
if ( formatCollection()->defaultFormat()->color() != c ) {
QDict<QTextFormat> formats = formatCollection()->dict();
QDictIterator<QTextFormat> it( formats );
while ( it.current() ) {
if ( it.current() == formatCollection()->defaultFormat() ) {
++it;
continue;
}
it.current()->setColor( c );
++it;
}
formatCollection()->defaultFormat()->setColor( c );
curtag.format.setColor( c );
}
}
if ( attr.contains( "link" ) )
linkColor = QColor( attr["link"] );
if ( attr.contains( "title" ) )
attribs.replace( "title", attr["title"] );
if ( textEditMode ) {
if ( attr.contains("style" ) ) {
QString a = attr["style"];
for ( int s = 0; s < a.contains(';')+1; s++ ) {
QString style = QTextDocument::section( a, ";", s, s );
if ( style.startsWith("font-size:" ) && QTextDocument::endsWith(style, "pt") ) {
scaleFontsFactor = double( formatCollection()->defaultFormat()->fn.pointSize() ) /
style.mid( 10, style.length() - 12 ).toInt();
}
}
}
nstyle = 0; // ignore body in textEditMode
}
// end qt- and body-tag handling
} else if ( tagname == "meta" ) {
if ( attr["name"] == "qrichtext" && attr["content"] == "1" )
textEditMode = TRUE;
} else if ( tagname == "title" ) {
QString title;
while ( pos < length ) {
if ( hasPrefix( doc, length, pos, QChar('<') ) && hasPrefix( doc, length, pos+1, QChar('/') ) &&
parseCloseTag( doc, length, pos ) == "title" )
break;
title += doc[ pos ];
++pos;
}
attribs.replace( "title", title );
}
} // end of well-known tag handling
if ( !custom ) // try generic custom item
custom = sheet_->tag( tagname, attr, contxt, *factory_ , emptyTag, this );
if ( !nstyle && !custom ) // we have no clue what this tag could be, ignore it
continue;
if ( custom ) {
int index = QMAX( curpar->length(),1) - 1;
QTextFormat format = curtag.format.makeTextFormat( nstyle, attr, scaleFontsFactor );
curpar->append( QChar('*') );
curpar->setFormat( index, 1, &format );
curpar->at( index )->setCustomItem( custom );
if ( !curtag.anchorHref.isEmpty() )
curpar->at(index)->setAnchor( QString::null, curtag.anchorHref );
if ( !anchorName.isEmpty() ) {
curpar->at(index)->setAnchor( anchorName, curpar->at(index)->anchorHref() );
anchorName = QString::null;
}
registerCustomItem( custom, curpar );
hasNewPar = FALSE;
} else if ( !emptyTag ) {
/* if we do nesting, push curtag on the stack,
otherwise reinint curag. */
if ( curtag.style->name() != tagname || nstyle->selfNesting() ) {
tags.push( curtag );
} else {
if ( !tags.isEmpty() )
curtag = tags.top();
else
curtag = initag;
}
curtag.name = tagname;
curtag.style = nstyle;
curtag.name = tagname;
@@ -2059,193 +2065,193 @@ QString QTextDocument::plainText() const
} else {
s += p->at( i )->c;
}
}
}
s.remove( s.length() - 1, 1 );
if ( p->next() )
s += "\n";
buffer += s;
p = p->next();
}
return buffer;
}
static QString align_to_string( int a )
{
if ( a & Qt::AlignRight )
return " align=\"right\"";
if ( a & Qt::AlignHCenter )
return " align=\"center\"";
if ( a & Qt3::AlignJustify )
return " align=\"justify\"";
return QString::null;
}
static QString direction_to_string( int d )
{
if ( d != QChar::DirON )
return ( d == QChar::DirL? " dir=\"ltr\"" : " dir=\"rtl\"" );
return QString::null;
}
static QString list_value_to_string( int v )
{
if ( v != -1 )
return " listvalue=\"" + QString::number( v ) + "\"";
return QString::null;
}
static QString list_style_to_string( int v )
{
switch( v ) {
case QStyleSheetItem::ListDecimal: return "\"1\"";
case QStyleSheetItem::ListLowerAlpha: return "\"a\"";
case QStyleSheetItem::ListUpperAlpha: return "\"A\"";
case QStyleSheetItem::ListDisc: return "\"disc\"";
case QStyleSheetItem::ListSquare: return "\"square\"";
case QStyleSheetItem::ListCircle: return "\"circle\"";
default:
return QString::null;
}
}
static inline bool list_is_ordered( int v )
{
return v == QStyleSheetItem::ListDecimal ||
v == QStyleSheetItem::ListLowerAlpha ||
v == QStyleSheetItem::ListUpperAlpha;
}
static QString margin_to_string( QStyleSheetItem* style, int t, int b, int l, int r, int fl )
{
QString s;
if ( l > 0 )
s += QString(!!s?";":"") + "margin-left:" + QString::number(l+QMAX(0,style->margin(QStyleSheetItem::MarginLeft))) + "px";
if ( r > 0 )
s += QString(!!s?";":"") + "margin-right:" + QString::number(r+QMAX(0,style->margin(QStyleSheetItem::MarginRight))) + "px";
if ( t > 0 )
s += QString(!!s?";":"") + "margin-top:" + QString::number(t+QMAX(0,style->margin(QStyleSheetItem::MarginTop))) + "px";
if ( b > 0 )
s += QString(!!s?";":"") + "margin-bottom:" + QString::number(b+QMAX(0,style->margin(QStyleSheetItem::MarginBottom))) + "px";
if ( fl > 0 )
s += QString(!!s?";":"") + "text-indent:" + QString::number(fl+QMAX(0,style->margin(QStyleSheetItem::MarginFirstLine))) + "px";
if ( !!s )
return " style=\"" + s + "\"";
return QString::null;
}
QString QTextDocument::richText() const
{
QString s = "";
if ( !par ) {
s += "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:" ;
s += QString::number( formatCollection()->defaultFormat()->font().pointSize() );
s += "pt;font-family:";
s += formatCollection()->defaultFormat()->font().family();
s +="\">";
}
QTextParagraph* p = fParag;
QStyleSheetItem* item_p = styleSheet()->item("p");
QStyleSheetItem* item_ul = styleSheet()->item("ul");
QStyleSheetItem* item_ol = styleSheet()->item("ol");
QStyleSheetItem* item_li = styleSheet()->item("li");
if ( !item_p || !item_ul || !item_ol || !item_li ) {
- qWarning( "QTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, ul, ol, or li)" );
+ owarn << "QTextEdit: cannot export HTML due to insufficient stylesheet (lack of p, ul, ol, or li)" << oendl;
return QString::null;
}
int pastListDepth = 0;
int listDepth = 0;
int futureListDepth = 0;
QMemArray<int> listStyles(10);
while ( p ) {
listDepth = p->listDepth();
if ( listDepth < pastListDepth ) {
for ( int i = listDepth+1; i <= pastListDepth; i++ )
s += list_is_ordered( listStyles[i] ) ? "</ol>" : "</ul>";
s += '\n';
} else if ( listDepth > pastListDepth ) {
s += '\n';
listStyles.resize( QMAX( (int)listStyles.size(), listDepth+1 ) );
QString list_type;
listStyles[listDepth] = p->listStyle();
if ( !list_is_ordered( p->listStyle() ) || item_ol->listStyle() != p->listStyle() )
list_type = " type=" + list_style_to_string( p->listStyle() );
for ( int i = pastListDepth; i < listDepth; i++ ) {
s += list_is_ordered( p->listStyle() ) ? "<ol" : "<ul" ;
s += list_type + ">";
}
} else {
s += '\n';
}
QString ps = p->richText();
// for the bottom margin we need to know whether we are at the end of a list
futureListDepth = 0;
if ( listDepth > 0 && p->next() )
futureListDepth = p->next()->listDepth();
if ( richTextExportStart && richTextExportStart->paragraph() ==p &&
richTextExportStart->index() == 0 )
s += "<selstart/>";
if ( p->isListItem() ) {
s += "<li";
if ( p->listStyle() != listStyles[listDepth] )
s += " type=" + list_style_to_string( p->listStyle() );
s +=align_to_string( p->alignment() );
s += margin_to_string( item_li, p->utm, p->ubm, p->ulm, p->urm, p->uflm );
s += list_value_to_string( p->listValue() );
s += direction_to_string( p->direction() );
s +=">";
s += ps;
s += "</li>";
} else {
// normal paragraph item
s += "<p";
s += align_to_string( p->alignment() );
s += margin_to_string( item_p, p->utm, p->ubm, p->ulm, p->urm, p->uflm );
s +=direction_to_string( p->direction() );
s += ">";
s += ps;
s += "</p>";
}
pastListDepth = listDepth;
p = p->next();
}
while ( listDepth > 0 ) {
s += list_is_ordered( listStyles[listDepth] ) ? "</ol>" : "</ul>";
listDepth--;
}
if ( !par )
s += "\n</body></html>\n";
return s;
}
QString QTextDocument::text() const
{
if ( txtFormat == Qt::AutoText && preferRichText || txtFormat == Qt::RichText )
return richText();
return plainText();
}
QString QTextDocument::text( int parag ) const
{
QTextParagraph *p = paragAt( parag );
if ( !p )
return QString::null;
if ( txtFormat == Qt::AutoText && preferRichText || txtFormat == Qt::RichText )
return p->richText();
else
return p->string()->toString();
}
void QTextDocument::invalidate()
{
QTextParagraph *s = fParag;
@@ -4003,246 +4009,246 @@ void QTextParagraph::format( int start, bool doMove )
// with has to be the full document width on mac as the selections
// always extend completely to the right. This is a bit unefficient,
// as this results in a bigger double buffer than needed but ok for
// now.
if ( lineStarts.count() == 1 ) {
if ( !string()->isBidi() ) {
c = &str->at( str->length() - 1 );
r.setWidth( c->x + str->width( str->length() - 1 ) );
} else {
r.setWidth( lineStarts[0]->w );
}
}
if ( !hasdoc ) { // qt_format_text bounding rect handling
it = lineStarts.begin();
int usedw = 0;
for ( ; it != lineStarts.end(); ++it )
usedw = QMAX( usedw, (*it)->w );
if ( r.width() <= 0 ) {
// if the user specifies an invalid rect, this means that the
// bounding box should grow to the width that the text actually
// needs
r.setWidth( usedw );
} else {
r.setWidth( QMIN( usedw, r.width() ) );
}
}
if ( y != r.height() )
r.setHeight( y );
if ( !visible ) {
r.setHeight( 0 );
} else {
int minw = formatter()->minimumWidth();
int wused = formatter()->widthUsed();
wused = QMAX( minw, wused );
if ( hasdoc ) {
document()->setMinimumWidth( minw, wused, this );
} else {
pseudoDocument()->minw = QMAX( pseudoDocument()->minw, minw );
pseudoDocument()->wused = QMAX( pseudoDocument()->wused, wused );
}
}
// do page breaks if required
if ( hasdoc && document()->isPageBreakEnabled() ) {
int shift = document()->formatter()->formatVertically( document(), this );
if ( shift && !formattedAgain ) {
formattedAgain = TRUE;
goto formatAgain;
}
}
if ( n && doMove && n->invalid == -1 && r.y() + r.height() != n->r.y() ) {
int dy = ( r.y() + r.height() ) - n->r.y();
QTextParagraph *s = n;
bool makeInvalid = p && p->lastInFrame;
while ( s && dy ) {
if ( !s->isFullWidth() )
makeInvalid = TRUE;
if ( makeInvalid )
s->invalidate( 0 );
s->move( dy );
if ( s->lastInFrame )
makeInvalid = TRUE;
s = s->n;
}
}
firstFormat = FALSE;
changed = TRUE;
invalid = -1;
//##### string()->setTextChanged( FALSE );
}
int QTextParagraph::lineHeightOfChar( int i, int *bl, int *y ) const
{
if ( !isValid() )
( (QTextParagraph*)this )->format();
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end();
--it;
for ( ;; ) {
if ( i >= it.key() ) {
if ( bl )
*bl = ( *it )->baseLine;
if ( y )
*y = ( *it )->y;
return ( *it )->h;
}
if ( it == lineStarts.begin() )
break;
--it;
}
- qWarning( "QTextParagraph::lineHeightOfChar: couldn't find lh for %d", i );
+ owarn << "QTextParagraph::lineHeightOfChar: couldn't find lh for " << i << "" << oendl;
return 15;
}
QTextStringChar *QTextParagraph::lineStartOfChar( int i, int *index, int *line ) const
{
if ( !isValid() )
( (QTextParagraph*)this )->format();
int l = (int)lineStarts.count() - 1;
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.end();
--it;
for ( ;; ) {
if ( i >= it.key() ) {
if ( index )
*index = it.key();
if ( line )
*line = l;
return &str->at( it.key() );
}
if ( it == lineStarts.begin() )
break;
--it;
--l;
}
- qWarning( "QTextParagraph::lineStartOfChar: couldn't find %d", i );
+ owarn << "QTextParagraph::lineStartOfChar: couldn't find " << i << "" << oendl;
return 0;
}
int QTextParagraph::lines() const
{
if ( !isValid() )
( (QTextParagraph*)this )->format();
return (int)lineStarts.count();
}
QTextStringChar *QTextParagraph::lineStartOfLine( int line, int *index ) const
{
if ( !isValid() )
( (QTextParagraph*)this )->format();
if ( line >= 0 && line < (int)lineStarts.count() ) {
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
while ( line-- > 0 )
++it;
int i = it.key();
if ( index )
*index = i;
return &str->at( i );
}
- qWarning( "QTextParagraph::lineStartOfLine: couldn't find %d", line );
+ owarn << "QTextParagraph::lineStartOfLine: couldn't find " << line << "" << oendl;
return 0;
}
int QTextParagraph::leftGap() const
{
if ( !isValid() )
( (QTextParagraph*)this )->format();
int line = 0;
int x = str->at(0).x; /* set x to x of first char */
if ( str->isBidi() ) {
for ( int i = 1; i < str->length()-1; ++i )
x = QMIN(x, str->at(i).x);
return x;
}
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
while (line < (int)lineStarts.count()) {
int i = it.key(); /* char index */
x = QMIN(x, str->at(i).x);
++it;
++line;
}
return x;
}
void QTextParagraph::setFormat( int index, int len, QTextFormat *f, bool useCollection, int flags )
{
if ( !f )
return;
if ( index < 0 )
index = 0;
if ( index > str->length() - 1 )
index = str->length() - 1;
if ( index + len >= str->length() )
len = str->length() - index;
QTextFormatCollection *fc = 0;
if ( useCollection )
fc = formatCollection();
QTextFormat *of;
for ( int i = 0; i < len; ++i ) {
of = str->at( i + index ).format();
if ( !changed && f->key() != of->key() )
changed = TRUE;
if ( invalid == -1 &&
( f->font().family() != of->font().family() ||
f->font().pointSize() != of->font().pointSize() ||
f->font().weight() != of->font().weight() ||
f->font().italic() != of->font().italic() ||
f->vAlign() != of->vAlign() ) ) {
invalidate( 0 );
}
if ( flags == -1 || flags == QTextFormat::Format || !fc ) {
if ( fc )
f = fc->format( f );
str->setFormat( i + index, f, useCollection );
} else {
QTextFormat *fm = fc->format( of, f, flags );
str->setFormat( i + index, fm, useCollection );
}
}
}
void QTextParagraph::indent( int *oldIndent, int *newIndent )
{
if ( !hasdoc || !document()->indent() || isListItem() ) {
if ( oldIndent )
*oldIndent = 0;
if ( newIndent )
*newIndent = 0;
if ( oldIndent && newIndent )
*newIndent = *oldIndent;
return;
}
document()->indent()->indent( document(), this, oldIndent, newIndent );
}
void QTextParagraph::paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor, bool drawSelections,
int clipx, int clipy, int clipw, int cliph )
{
if ( !visible )
return;
QTextStringChar *chr = 0;
int i, y, h, baseLine, xstart, xend;
i = y =h = baseLine = 0;
QRect cursorRect;
drawSelections &= ( mSelections != 0 );
// macintosh full-width selection style
bool fullWidthStyle = FALSE;
int fullSelectionWidth = 0;
if ( drawSelections && fullWidthStyle )
fullSelectionWidth = (hasdoc ? document()->width() : r.width());
QString qstr = str->toString();
// ### workaround so that \n are not drawn, actually this should
@@ -5604,193 +5610,193 @@ QTextFormat *QTextFormatCollection::format( QTextFormat *f )
return lastFormat;
}
if ( f == lastFormat || ( lastFormat && f->key() == lastFormat->key() ) ) {
lastFormat->addRef();
return lastFormat;
}
QTextFormat *fm = cKey.find( f->key() );
if ( fm ) {
lastFormat = fm;
lastFormat->addRef();
return lastFormat;
}
if ( f->key() == defFormat->key() )
return defFormat;
lastFormat = createFormat( *f );
lastFormat->collection = this;
cKey.insert( lastFormat->key(), lastFormat );
return lastFormat;
}
QTextFormat *QTextFormatCollection::format( QTextFormat *of, QTextFormat *nf, int flags )
{
if ( cres && kof == of->key() && knf == nf->key() && cflags == flags ) {
cres->addRef();
return cres;
}
cres = createFormat( *of );
kof = of->key();
knf = nf->key();
cflags = flags;
if ( flags & QTextFormat::Bold )
cres->fn.setBold( nf->fn.bold() );
if ( flags & QTextFormat::Italic )
cres->fn.setItalic( nf->fn.italic() );
if ( flags & QTextFormat::Underline )
cres->fn.setUnderline( nf->fn.underline() );
if ( flags & QTextFormat::StrikeOut )
cres->fn.setStrikeOut( nf->fn.strikeOut() );
if ( flags & QTextFormat::Family )
cres->fn.setFamily( nf->fn.family() );
if ( flags & QTextFormat::Size ) {
if ( of->usePixelSizes )
cres->fn.setPixelSize( nf->fn.pixelSize() );
else
cres->fn.setPointSize( nf->fn.pointSize() );
}
if ( flags & QTextFormat::Color )
cres->col = nf->col;
if ( flags & QTextFormat::Misspelled )
cres->missp = nf->missp;
if ( flags & QTextFormat::VAlign )
cres->ha = nf->ha;
cres->update();
QTextFormat *fm = cKey.find( cres->key() );
if ( !fm ) {
cres->collection = this;
cKey.insert( cres->key(), cres );
} else {
delete cres;
cres = fm;
cres->addRef();
}
return cres;
}
QTextFormat *QTextFormatCollection::format( const QFont &f, const QColor &c )
{
if ( cachedFormat && cfont == f && ccol == c ) {
cachedFormat->addRef();
return cachedFormat;
}
QString key = QTextFormat::getKey( f, c, FALSE, QTextFormat::AlignNormal );
cachedFormat = cKey.find( key );
cfont = f;
ccol = c;
if ( cachedFormat ) {
cachedFormat->addRef();
return cachedFormat;
}
if ( key == defFormat->key() )
return defFormat;
cachedFormat = createFormat( f, c );
cachedFormat->collection = this;
cKey.insert( cachedFormat->key(), cachedFormat );
if ( cachedFormat->key() != key )
- qWarning("ASSERT: keys for format not identical: '%s '%s'", cachedFormat->key().latin1(), key.latin1() );
+ owarn << "ASSERT: keys for format not identical: '" << cachedFormat->key().latin1() << " '" << key.latin1() << "'" << oendl;
return cachedFormat;
}
void QTextFormatCollection::remove( QTextFormat *f )
{
if ( lastFormat == f )
lastFormat = 0;
if ( cres == f )
cres = 0;
if ( cachedFormat == f )
cachedFormat = 0;
cKey.remove( f->key() );
}
#define UPDATE( up, lo, rest ) \
if ( font.lo##rest() != defFormat->fn.lo##rest() && fm->fn.lo##rest() == defFormat->fn.lo##rest() ) \
fm->fn.set##up##rest( font.lo##rest() )
void QTextFormatCollection::updateDefaultFormat( const QFont &font, const QColor &color, QStyleSheet *sheet )
{
QDictIterator<QTextFormat> it( cKey );
QTextFormat *fm;
bool usePixels = font.pointSize() == -1;
bool changeSize = usePixels ? font.pixelSize() != defFormat->fn.pixelSize() :
font.pointSize() != defFormat->fn.pointSize();
int base = usePixels ? font.pixelSize() : font.pointSize();
while ( ( fm = it.current() ) ) {
++it;
UPDATE( F, f, amily );
UPDATE( W, w, eight );
UPDATE( B, b, old );
UPDATE( I, i, talic );
UPDATE( U, u, nderline );
if ( changeSize ) {
fm->stdSize = base;
fm->usePixelSizes = usePixels;
if ( usePixels )
fm->fn.setPixelSize( fm->stdSize );
else
fm->fn.setPointSize( fm->stdSize );
sheet->scaleFont( fm->fn, fm->logicalFontSize );
}
if ( color.isValid() && color != defFormat->col && fm->col == defFormat->col )
fm->col = color;
fm->update();
}
defFormat->fn = font;
defFormat->col = color;
defFormat->update();
defFormat->stdSize = base;
defFormat->usePixelSizes = usePixels;
updateKeys();
}
// the keys in cKey have changed, rebuild the hashtable
void QTextFormatCollection::updateKeys()
{
if ( cKey.isEmpty() )
return;
cKey.setAutoDelete( FALSE );
QTextFormat** formats = new QTextFormat*[ cKey.count() + 1 ];
QTextFormat **f = formats;
QDictIterator<QTextFormat> it( cKey );
while ( ( *f = it.current() ) ) {
++it;
++f;
}
cKey.clear();
for ( f = formats; *f; f++ )
cKey.insert( (*f)->key(), *f );
cKey.setAutoDelete( TRUE );
delete [] formats;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void QTextFormat::setBold( bool b )
{
if ( b == fn.bold() )
return;
fn.setBold( b );
update();
}
void QTextFormat::setMisspelled( bool b )
{
if ( b == (bool)missp )
return;
missp = b;
update();
}
@@ -5990,197 +5996,197 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa
if ( attr.contains("size") ) {
QString a = attr["size"];
int n = a.toInt();
if ( a[0] == '+' || a[0] == '-' )
n += format.logicalFontSize;
format.logicalFontSize = n;
if ( format.usePixelSizes )
format.fn.setPixelSize( format.stdSize );
else
format.fn.setPointSize( format.stdSize );
style->styleSheet()->scaleFont( format.fn, format.logicalFontSize );
}
}
if ( attr.contains("style" ) ) {
QString a = attr["style"];
for ( int s = 0; s < a.contains(';')+1; s++ ) {
QString style = QTextDocument::section( a, ";", s, s );
if ( style.startsWith("font-size:" ) && QTextDocument::endsWith(style, "pt") ) {
format.logicalFontSize = 0;
format.setPointSize( int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toInt() ) );
} if ( style.startsWith("font-style:" ) ) {
QString s = style.mid( 11 ).stripWhiteSpace();
if ( s == "normal" )
format.fn.setItalic( FALSE );
else if ( s == "italic" || s == "oblique" )
format.fn.setItalic( TRUE );
} else if ( style.startsWith("font-weight:" ) ) {
QString s = style.mid( 12 );
bool ok = TRUE;
int n = s.toInt( &ok );
if ( ok )
format.fn.setWeight( n/8 );
} else if ( style.startsWith("font-family:" ) ) {
format.fn.setFamily( QTextDocument::section(style.mid(12),",",0,0).stripWhiteSpace() );
} else if ( style.startsWith("text-decoration:" ) ) {
QString s = style.mid( 16 ).stripWhiteSpace();
format.fn.setUnderline( s == "underline" );
} else if ( style.startsWith("vertical-align:" ) ) {
QString s = style.mid( 15 ).stripWhiteSpace();
if ( s == "sub" )
format.setVAlign( QTextFormat::AlignSubScript );
else if ( s == "super" )
format.setVAlign( QTextFormat::AlignSuperScript );
else
format.setVAlign( QTextFormat::AlignNormal );
} else if ( style.startsWith("color:" ) ) {
format.col.setNamedColor( style.mid(6) );
format.linkColor = FALSE;
}
}
}
format.update();
return format;
}
struct QPixmapInt
{
QPixmapInt() : ref( 0 ) {}
QPixmap pm;
int ref;
};
static QMap<QString, QPixmapInt> *pixmap_map = 0;
QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
QMimeSourceFactory &factory )
: QTextCustomItem( p )
{
width = height = 0;
if ( attr.contains("width") )
width = attr["width"].toInt();
if ( attr.contains("height") )
height = attr["height"].toInt();
reg = 0;
QString imageName = attr["src"];
if (!imageName)
imageName = attr["source"];
if ( !imageName.isEmpty() ) {
imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
if ( !pixmap_map )
pixmap_map = new QMap<QString, QPixmapInt>;
if ( pixmap_map->contains( imgId ) ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pm = pmi.pm;
pmi.ref++;
width = pm.width();
height = pm.height();
} else {
QImage img;
const QMimeSource* m =
factory.data( imageName, context );
if ( !m ) {
- qWarning("QTextImage: no mimesource for %s", imageName.latin1() );
+ owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl;
}
else {
if ( !QImageDrag::decode( m, img ) ) {
- qWarning("QTextImage: cannot decode %s", imageName.latin1() );
+ owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl;
}
}
if ( !img.isNull() ) {
if ( width == 0 ) {
width = img.width();
if ( height != 0 ) {
width = img.width() * height / img.height();
}
}
if ( height == 0 ) {
height = img.height();
if ( width != img.width() ) {
height = img.height() * width / img.width();
}
}
if ( img.width() != width || img.height() != height ){
#ifndef QT_NO_IMAGE_SMOOTHSCALE
img = img.smoothScale(width, height);
#endif
width = img.width();
height = img.height();
}
pm.convertFromImage( img );
}
if ( !pm.isNull() ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pmi.pm = pm;
pmi.ref++;
}
}
if ( pm.mask() ) {
QRegion mask( *pm.mask() );
QRegion all( 0, 0, pm.width(), pm.height() );
reg = new QRegion( all.subtract( mask ) );
}
}
if ( pm.isNull() && (width*height)==0 )
width = height = 50;
place = PlaceInline;
if ( attr["align"] == "left" )
place = PlaceLeft;
else if ( attr["align"] == "right" )
place = PlaceRight;
tmpwidth = width;
tmpheight = height;
attributes = attr;
}
QTextImage::~QTextImage()
{
if ( pixmap_map && pixmap_map->contains( imgId ) ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pmi.ref--;
if ( !pmi.ref ) {
pixmap_map->remove( imgId );
if ( pixmap_map->isEmpty() ) {
delete pixmap_map;
pixmap_map = 0;
}
}
}
delete reg;
}
QString QTextImage::richText() const
{
QString s;
s += "<img ";
QMap<QString, QString>::ConstIterator it = attributes.begin();
for ( ; it != attributes.end(); ++it )
s += it.key() + "=" + *it + " ";
s += ">";
return s;
}
void QTextImage::adjustToPainter( QPainter* p )
{
width = scale( tmpwidth, p );
height = scale( tmpheight, p );
}
#if !defined(Q_WS_X11)
#include <qbitmap.h>
#include "qcleanuphandler.h"
static QPixmap *qrt_selection = 0;
static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap;
static void qrt_createSelectionPixmap( const QColorGroup &cg )
{
qrt_selection = new QPixmap( 2, 2 );
qrt_cleanup_pixmap.set( &qrt_selection );
qrt_selection->fill( Qt::color0 );
diff --git a/noncore/apps/opie-write/qrichtext_p.cpp b/noncore/apps/opie-write/qrichtext_p.cpp
index 6783e0b..2e8b09c 100644
--- a/noncore/apps/opie-write/qrichtext_p.cpp
+++ b/noncore/apps/opie-write/qrichtext_p.cpp
@@ -1,236 +1,239 @@
/****************************************************************************
** $Id$
**
** Implementation of the internal Qt classes dealing with rich text
**
** Created : 990101
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the kernel module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** 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.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial 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.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** 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 <opie2/odebug.h>
+using namespace Opie::Core;
+
#include "qrichtext_p.h"
using namespace Qt3;
QTextCommand::~QTextCommand() {}
QTextCommand::Commands QTextCommand::type() const { return Invalid; }
QTextCustomItem::~QTextCustomItem() {}
void QTextCustomItem::adjustToPainter( QPainter* p){ if ( p ) width = 0; }
QTextCustomItem::Placement QTextCustomItem::placement() const { return PlaceInline; }
bool QTextCustomItem::ownLine() const { return FALSE; }
void QTextCustomItem::resize( int nwidth ){ width = nwidth; }
void QTextCustomItem::invalidate() {}
bool QTextCustomItem::isNested() const { return FALSE; }
int QTextCustomItem::minimumWidth() const { return 0; }
QString QTextCustomItem::richText() const { return QString::null; }
bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool )
{
return TRUE;
}
bool QTextCustomItem::enterAt( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int &, const QPoint & )
{
return TRUE;
}
bool QTextCustomItem::next( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
{
return TRUE;
}
bool QTextCustomItem::prev( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
{
return TRUE;
}
bool QTextCustomItem::down( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
{
return TRUE;
}
bool QTextCustomItem::up( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & )
{
return TRUE;
}
void QTextFlow::setPageSize( int ps ) { pagesize = ps; }
bool QTextFlow::isEmpty() { return leftItems.isEmpty() && rightItems.isEmpty(); }
void QTextTableCell::invalidate() { cached_width = -1; cached_sizehint = -1; }
void QTextTable::invalidate() { cachewidth = -1; }
QTextParagraphData::~QTextParagraphData() {}
void QTextParagraphData::join( QTextParagraphData * ) {}
QTextFormatter::~QTextFormatter() {}
void QTextFormatter::setWrapEnabled( bool b ) { wrapEnabled = b; }
void QTextFormatter::setWrapAtColumn( int c ) { wrapColumn = c; }
int QTextCursor::x() const
{
QTextStringChar *c = para->at( idx );
int curx = c->x;
if ( !c->rightToLeft &&
c->c.isSpace() &&
idx > 0 &&
!c->lineStart &&
( para->alignment() & Qt3::AlignJustify ) == Qt3::AlignJustify )
curx = para->at( idx - 1 )->x + para->string()->width( idx - 1 );
if ( c->rightToLeft )
curx += para->string()->width( idx );
return curx;
}
int QTextCursor::y() const
{
int dummy, line;
para->lineStartOfChar( idx, &dummy, &line );
return para->lineY( line );
}
int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); }
int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); }
QTextDocument *QTextCursor::document() const
{
return para ? para->document() : 0;
}
void QTextCursor::gotoPosition( QTextParagraph* p, int index )
{
if ( para && p != para ) {
while ( para->document() != p->document() && !indices.isEmpty() )
pop();
Q_ASSERT( indices.isEmpty() || para->document() == p->document() );
}
para = p;
if ( index < 0 || index >= para->length() ) {
#if defined(QT_CHECK_RANGE)
- qWarning( "QTextCursor::gotoParagraph Index: %d out of range", index );
+ owarn << "QTextCursor::gotoParagraph Index: " << index << " out of range" << oendl;
#endif
index = index < 0 ? 0 : para->length() - 1;
}
tmpIndex = -1;
idx = index;
}
bool QTextDocument::hasSelection( int id, bool visible ) const
{
return ( selections.find( id ) != selections.end() &&
( !visible ||
( (QTextDocument*)this )->selectionStartCursor( id ) !=
( (QTextDocument*)this )->selectionEndCursor( id ) ) );
}
void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor )
{
QTextDocumentSelection sel;
sel.startCursor = cursor;
sel.endCursor = cursor;
sel.swapped = FALSE;
selections[ id ] = sel;
}
QTextParagraph *QTextDocument::paragAt( int i ) const
{
QTextParagraph* p = curParag;
if ( !p || p->paragId() > i )
p = fParag;
while ( p && p->paragId() != i )
p = p->next();
((QTextDocument*)this)->curParag = p;
return p;
}
QTextFormat::~QTextFormat()
{
}
QTextFormat::QTextFormat()
: fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() )
{
ref = 0;
usePixelSizes = FALSE;
if ( stdSize == -1 ) {
stdSize = qApp->font().pixelSize();
usePixelSizes = TRUE;
}
missp = FALSE;
ha = AlignNormal;
collection = 0;
}
QTextFormat::QTextFormat( const QStyleSheetItem *style )
: fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() )
{
ref = 0;
usePixelSizes = FALSE;
if ( stdSize == -1 ) {
stdSize = qApp->font().pixelSize();
usePixelSizes = TRUE;
}
missp = FALSE;
ha = AlignNormal;
collection = 0;
fn = QFont( style->fontFamily(),
style->fontSize(),
style->fontWeight(),
style->fontItalic() );
fn.setUnderline( style->fontUnderline() );
fn.setStrikeOut( style->fontStrikeOut() );
col = style->color();
fm = QFontMetrics( fn );
leftBearing = fm.minLeftBearing();
rightBearing = fm.minRightBearing();
hei = fm.lineSpacing();
asc = fm.ascent() + (fm.leading()+1)/2;
dsc = fm.descent();
missp = FALSE;
ha = AlignNormal;
memset( widths, 0, 256 );
generateKey();
addRef();
}
QTextFormat::QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection *parent )
: fn( f ), col( c ), fm( QFontMetrics( f ) ), linkColor( TRUE ),
logicalFontSize( 3 ), stdSize( f.pointSize() )
{
ref = 0;
@@ -384,220 +387,220 @@ QString QTextFormat::getKey( const QFont &fn, const QColor &col, bool misspelled
k += '/';
k += QString::number( (uint)col.rgb() );
k += '/';
k += QString::number( (int)misspelled );
k += '/';
k += QString::number( (int)a );
return k;
}
QString QTextString::toString( const QMemArray<QTextStringChar> &data )
{
QString s;
int l = data.size();
s.setUnicode( 0, l );
QTextStringChar *c = data.data();
QChar *uc = (QChar *)s.unicode();
while ( l-- ) {
*uc = c->c;
// ### workaround so that non-breaking whitespaces are drawn
// properly, actually this should be fixed in QFont somewhere
if ( *uc == (char)0xa0 )
*uc = 0x20;
uc++;
c++;
}
return s;
}
QString QTextString::toString() const
{
return toString( data );
}
void QTextParagraph::setSelection( int id, int start, int end )
{
QMap<int, QTextParagraphSelection>::ConstIterator it = selections().find( id );
if ( it != mSelections->end() ) {
if ( start == ( *it ).start && end == ( *it ).end )
return;
}
QTextParagraphSelection sel;
sel.start = start;
sel.end = end;
(*mSelections)[ id ] = sel;
setChanged( TRUE, TRUE );
}
void QTextParagraph::removeSelection( int id )
{
if ( !hasSelection( id ) )
return;
if ( mSelections )
mSelections->remove( id );
setChanged( TRUE, TRUE );
}
int QTextParagraph::selectionStart( int id ) const
{
if ( !mSelections )
return -1;
QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
if ( it == mSelections->end() )
return -1;
return ( *it ).start;
}
int QTextParagraph::selectionEnd( int id ) const
{
if ( !mSelections )
return -1;
QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
if ( it == mSelections->end() )
return -1;
return ( *it ).end;
}
bool QTextParagraph::hasSelection( int id ) const
{
return mSelections ? mSelections->contains( id ) : FALSE;
}
bool QTextParagraph::fullSelected( int id ) const
{
if ( !mSelections )
return FALSE;
QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id );
if ( it == mSelections->end() )
return FALSE;
return ( *it ).start == 0 && ( *it ).end == str->length() - 1;
}
int QTextParagraph::lineY( int l ) const
{
if ( l > (int)lineStarts.count() - 1 ) {
- qWarning( "QTextParagraph::lineY: line %d out of range!", l );
+ owarn << "QTextParagraph::lineY: line " << l << " out of range!" << oendl;
return 0;
}
if ( !isValid() )
( (QTextParagraph*)this )->format();
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
while ( l-- > 0 )
++it;
return ( *it )->y;
}
int QTextParagraph::lineBaseLine( int l ) const
{
if ( l > (int)lineStarts.count() - 1 ) {
- qWarning( "QTextParagraph::lineBaseLine: line %d out of range!", l );
+ owarn << "QTextParagraph::lineBaseLine: line " << l << " out of range!" << oendl;
return 10;
}
if ( !isValid() )
( (QTextParagraph*)this )->format();
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
while ( l-- > 0 )
++it;
return ( *it )->baseLine;
}
int QTextParagraph::lineHeight( int l ) const
{
if ( l > (int)lineStarts.count() - 1 ) {
- qWarning( "QTextParagraph::lineHeight: line %d out of range!", l );
+ owarn << "QTextParagraph::lineHeight: line " << l << " out of range!" << oendl;
return 15;
}
if ( !isValid() )
( (QTextParagraph*)this )->format();
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
while ( l-- > 0 )
++it;
return ( *it )->h;
}
void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const
{
if ( l > (int)lineStarts.count() - 1 ) {
- qWarning( "QTextParagraph::lineInfo: line %d out of range!", l );
- qDebug( "%d %d", (int)lineStarts.count() - 1, l );
+ owarn << "QTextParagraph::lineInfo: line " << l << " out of range!" << oendl;
+ odebug << "" << (int)lineStarts.count() - 1 << " " << l << "" << oendl;
y = 0;
h = 15;
bl = 10;
return;
}
if ( !isValid() )
( (QTextParagraph*)this )->format();
QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin();
while ( l-- > 0 )
++it;
y = ( *it )->y;
h = ( *it )->h;
bl = ( *it )->baseLine;
}
void QTextParagraph::setAlignment( int a )
{
if ( a == (int)align )
return;
align = a;
invalidate( 0 );
}
QTextFormatter *QTextParagraph::formatter() const
{
if ( hasdoc )
return document()->formatter();
if ( pseudoDocument()->pFormatter )
return pseudoDocument()->pFormatter;
return ( ( (QTextParagraph*)this )->pseudoDocument()->pFormatter = new QTextFormatterBreakWords );
}
void QTextParagraph::setTabArray( int *a )
{
delete [] tArray;
tArray = a;
}
void QTextParagraph::setTabStops( int tw )
{
if ( hasdoc )
document()->setTabStops( tw );
else
tabStopWidth = tw;
}
QMap<int, QTextParagraphSelection> &QTextParagraph::selections() const
{
if ( !mSelections )
((QTextParagraph *)this)->mSelections = new QMap<int, QTextParagraphSelection>;
return *mSelections;
}
QPtrList<QTextCustomItem> &QTextParagraph::floatingItems() const
{
if ( !mFloatingItems )
((QTextParagraph *)this)->mFloatingItems = new QPtrList<QTextCustomItem>;
return *mFloatingItems;
}
QTextStringChar::~QTextStringChar()
{
if ( format() )
format()->removeRef();
if ( type ) // not Regular
delete d.custom;
}
QTextParagraphPseudoDocument::QTextParagraphPseudoDocument():pFormatter(0),commandHistory(0), minw(0),wused(0){}
QTextParagraphPseudoDocument::~QTextParagraphPseudoDocument(){ delete pFormatter; delete commandHistory; }
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp
index 0fe5b09..046d997 100755
--- a/noncore/apps/qashmoney/accountdisplay.cpp
+++ b/noncore/apps/qashmoney/accountdisplay.cpp
@@ -1,105 +1,110 @@
-#include <qmessagebox.h>
-#include <qheader.h>
-
#include "accountdisplay.h"
#include "newaccount.h"
#include "transaction.h"
#include "transferdialog.h"
#include "transfer.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
+#include <qmessagebox.h>
+#include <qheader.h>
+
extern Account *account;
extern Transaction *transaction;
extern Transfer *transfer;
extern Preferences *preferences;
AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent )
{
cleared = 0;
firstline = new QHBox ( this );
firstline->setSpacing ( 2 );
newaccount = new QPushButton ( firstline );
newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
connect ( newaccount, SIGNAL ( released() ), this, SLOT ( addAccount() ) );
editaccount = new QPushButton ( firstline );
editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
connect ( editaccount, SIGNAL ( released() ), this, SLOT ( editAccount() ) );
deleteaccount = new QPushButton ( firstline );
deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
connect ( deleteaccount, SIGNAL ( released() ), this, SLOT ( deleteAccount() ) );
transferbutton = new QPushButton ( firstline );
transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") );
transferbutton->setToggleButton ( TRUE );
connect ( transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( accountTransfer(bool) ) );
listview = new QListView ( this );
listview->setAllColumnsShowFocus ( TRUE );
listview->setShowSortIndicator ( TRUE );
listview->setRootIsDecorated ( TRUE );
listview->setMultiSelection ( FALSE );
connect ( listview, SIGNAL ( expanded(QListViewItem*) ), this, SLOT ( setAccountExpanded(QListViewItem*) ) );
connect ( listview, SIGNAL ( collapsed(QListViewItem*) ), this, SLOT ( setAccountCollapsed(QListViewItem*) ) );
listview->header()->setTracking ( FALSE );
connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
layout = new QVBoxLayout ( this, 2, 5 );
layout->addWidget ( firstline );
layout->addWidget ( listview );
}
void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs )
{
tab2 = newtab2;
maintabs = newtabs;
}
void AccountDisplay::addAccount ()
{
// initialize local variables
int parentid = 0;
type = 0;
QString parentlist [ listview->childCount() + 1 ] [ 3 ] ;
// create new account window for entering data
NewAccount *newaccount = new NewAccount ( this );
int width = this->width();
newaccount->accountbox->setMaximumWidth ( ( int ) ( width * 0.5 ) );
newaccount->datebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
newaccount->childbox->setMaximumWidth ( ( int ) ( width * 0.5 ) );
newaccount->balancebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
newaccount->creditlimitbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
// if there are no accounts, disable the child check box
if ( account->getNumberOfAccounts () == 0 )
newaccount->childcheckbox->setEnabled ( FALSE );
// if there are accounts, fill up the pulldown menu for
// selecting a parent account. We should only add those parents without transactions
else
{
int c = 0;
QListViewItemIterator it ( listview );
for ( ; it.current(); ++it )
{
int id = it.current()->text ( getIDColumn() ).toInt();
// iterate through accountdisplay listview and add parents with no transactions
// add this item to the list box only if it is a parent and has no transactions
if ( transfer->getNumberOfTransfers ( id ) == 0 && transaction->getNumberOfTransactions ( id ) == 0 && it.current()->parent() == 0 )
{
newaccount->childbox->insertItem ( it.current()->text ( 0 ) );
parentlist [ c ] [ 0 ] = it.current()->text ( 0 );
parentlist [ c ] [ 1 ] = it.current()->text ( getIDColumn() );
parentlist [ c ] [ 2 ] = QString::number ( c );
c++;
}
}
}
if ( preferences->getPreference ( 4 ) == 0 )
newaccount->currencybox->setEnabled ( FALSE );
@@ -174,193 +179,193 @@ void AccountDisplay::deleteAccount ()
transfer->deleteAllTransfers ( accountid );
// delete the account
account->deleteAccount ( accountid );
// update account balances
if ( parentid != -1 )
account->changeParentAccountBalance ( parentid );
//redisplay accounts
account->displayAccounts ( listview );
//remove all the columns from the accountdisplay if there are not any accounts
if ( account->getNumberOfAccounts() == 0 )
{
int columns = listview->columns();
int counter;
for ( counter = 0; counter <= columns; counter++ )
listview->removeColumn ( 0 );
}
setToggleButton();
}
}
maintabs->setTabEnabled ( tab2, FALSE );
}
void AccountDisplay::setToggleButton ()
{
// iterate through account display and determine how many "transferable" accounts we have
// if there are less than two, disable the transfer button
QListViewItemIterator it ( listview );
int counter = 0;
for ( ; it.current(); ++it )
{
// add one to counter if we find a transferable account
if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 )
counter++;
}
if ( counter > 1 )
transferbutton->show();
else
transferbutton->hide();
}
void AccountDisplay::accountTransfer ( bool state )
{
if ( state == TRUE )
{
firstaccountid = -1;
secondaccountid = -1;
listview->clearSelection ();
listview->setMultiSelection ( TRUE );
disableParentsWithChildren ();
connect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
}
else
{
firstaccountid = -1;
secondaccountid = -1;
listview->clearSelection ();
listview->setMultiSelection ( FALSE );
enableAccounts ();
disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
}
}
void AccountDisplay::getTransferAccounts ( QListViewItem * item )
{
if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children
{
if ( firstaccountid == -1 )
firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account
else
if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first
secondaccountid = item->text ( getIDColumn() ).toInt();
}
// open transfer window if both accounts are set
if ( firstaccountid != -1 && secondaccountid != -1 )
{
// construct the transferdialog window
TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid );
// enter today's date in the date box as default
QDate today = QDate::currentDate ();
int defaultday = today.day();
int defaultmonth = today.month();
int defaultyear = today.year();
td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
if ( td->exec() == QDialog::Accepted )
{
// set the cleared integer if the checkbox is checked
if ( td->clearedcheckbox->isChecked() == TRUE )
cleared = 1;
- qDebug("Year from transferdialog = %i",td->getYear());
+ odebug << "Year from transferdialog = " << td->getYear() << "" << oendl;
// add the transfer with a new date if its been edited or use the default date
if ( td->getDateEdited () == TRUE )
transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared );
else
transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared );
// update account balances of both accounts and parents if necessary
account->updateAccountBalance ( firstaccountid );
if ( account->getParentAccountID ( firstaccountid ) != -1 )
account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) );
account->updateAccountBalance ( secondaccountid );
if ( account->getParentAccountID ( secondaccountid ) != -1 )
account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) );
// redisplay accounts
account->displayAccounts ( listview );
}
else
{
firstaccountid = -1;
secondaccountid = -1;
listview->clearSelection ();
listview->setMultiSelection ( FALSE );
disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
}
// reset the accounts display window
transferbutton->toggle(); // toggling this button with clear the window as well
// reenable all the accounts so the transaction tab will be properly set
enableAccounts ();
}
}
void AccountDisplay::disableParentsWithChildren ()
{
// iterate through accountdisplay listview and disable all the parents that have children
QListViewItemIterator it ( listview );
for ( ; it.current(); ++it )
{
if ( it.current()->parent() == 0 && it.current()->childCount() != 0 )
it.current()->setSelectable ( FALSE );
}
}
void AccountDisplay::enableAccounts ()
{
// iterate through accountdisplay listview and enable all accounts
QListViewItemIterator it ( listview );
for ( ; it.current(); ++it )
it.current()->setSelectable ( TRUE );
}
void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize )
{
switch ( column )
{
case 0:
if ( listview->columns() == 3 )
preferences->changeColumnPreference ( 1, newsize );
else
preferences->changeColumnPreference ( 10, newsize );
break;
case 1:
if ( listview->columns() == 3 )
preferences->changeColumnPreference ( 2, newsize );
else
preferences->changeColumnPreference ( 11, newsize );
break;
case 2:
preferences->changeColumnPreference ( 12, newsize );
break;
}
}
void AccountDisplay::saveSortingPreference ( int column )
{
preferences->changeSortingPreference ( 1, column );
}
int AccountDisplay::getIDColumn ()
{
int counter;
int columns = listview->columns();
for ( counter = 0; counter <= columns; counter++ )
if ( listview->header()->label ( counter ).length() == 0 )
return counter;
}
void AccountDisplay::editAccount ()
{
if ( listview->selectedItem() == 0 )
QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit.");
else
{
diff --git a/noncore/apps/qashmoney/config.in b/noncore/apps/qashmoney/config.in
index 91739fe..aeed298 100644
--- a/noncore/apps/qashmoney/config.in
+++ b/noncore/apps/qashmoney/config.in
@@ -1,4 +1,4 @@
config QASHMONEY
boolean "opie-qashmoney (money manager)"
default "n"
- depends ( LIBQPE || LIBQPE-X11 )
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/apps/qashmoney/qashmoney.pro b/noncore/apps/qashmoney/qashmoney.pro
index 6ad3db3..8a4302f 100755
--- a/noncore/apps/qashmoney/qashmoney.pro
+++ b/noncore/apps/qashmoney/qashmoney.pro
@@ -1,49 +1,49 @@
TEMPLATE = app
CONFIG = qt warn_on
HEADERS = qashmoney.h \
accountdisplay.h \
account.h \
transaction.h \
transactiondisplay.h \
newtransaction.h \
transfer.h \
transferdialog.h \
preferences.h \
preferencedialogs.h \
memory.h \
memorydialog.h \
newaccount.h \
calculator.h \
datepicker.h \
budget.h \
budgetdisplay.h \
currency.h
SOURCES = qashmoney.cpp \
accountdisplay.cpp \
account.cpp \
transaction.cpp \
transactiondisplay.cpp \
newtransaction.cpp \
transfer.cpp \
transferdialog.cpp \
preferences.cpp \
preferencedialogs.cpp \
memory.cpp \
memorydialog.cpp \
newaccount.cpp \
calculator.cpp \
datepicker.cpp \
main.cpp \
budget.cpp \
budgetdisplay.cpp \
currency.cpp
INCLUDEPATH = $(OPIEDIR)/include
DEPENDPATH = $(OPIEDIR)/include
DESTDIR = $(OPIEDIR)/bin
unix:LIBS += -lm
-LIBS += -lqpe -lqte -lsqlite
+LIBS += -lqpe -lopiecore2 -lsqlite
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp
index dbf9370..6e544ba 100644
--- a/noncore/apps/tableviewer/db/common.cpp
+++ b/noncore/apps/tableviewer/db/common.cpp
@@ -1,124 +1,132 @@
/**********************************************************************
** 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 <stdlib.h>
+#include "common.h"
+#include "datacache.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/timestring.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qstring.h>
#include <qheader.h>
#include <qvector.h>
#include <qdatetime.h>
-#include <qpe/timestring.h>
-#include "common.h"
-#include "datacache.h"
+
+/* STD */
#include <assert.h>
+#include <stdlib.h>
static const int del_flag = 0x1;
static const int new_flag = 0x2;
/* Helper function */
int parseNextNumber(QString *q) {
QChar c;
uint i;
int result = 0;
bool found_digits = FALSE;
for(i = 0; i < q->length(); i++) {
c = q->at(i);
if (c.isDigit()) {
if (found_digits)
result *= 10;
found_digits = TRUE;
result += c.digitValue();
} else {
if (found_digits)
break;
/* just skip this char */
}
}
/* now truncate q */
if (found_digits)
q->remove(0, i);
return result;
}
/*!
\class QStringVector
\brief A Vector of QStrings that can be sorted and searched
Implmented in order to allow reverse lookup on the string name
*/
/*!
This function implements the compare function in order to allow the
searching and sorting of the QStringVector to occur
\returns an int which is either
<UL>
<LI> < 0 if the first string is smaller than the second,</LI>
<LI> > 0 if the first string is bigger then the second,</LI>
<LI> == 0 if the first string is equal to the second.</LI>
</UL>
*/
int QStringVector::compareItems(Item a, Item b)
{
QString *qa = (QString *)a;
QString *qb = (QString *)b;
return QString::compare(*qa, *qb);
}
/*!
\class TVVariant
A way of abstracting void * and keeping information on
the keytypes and behaviours in one place
*/
TVVariantPrivate::TVVariantPrivate()
{
typ = TVVariant::Invalid;
}
TVVariantPrivate::TVVariantPrivate( TVVariantPrivate *d)
{
switch(d->typ)
{
case TVVariant::Invalid:
break;
case TVVariant::String:
value.ptr = new QString(*((QString *)d->value.ptr));
break;
case TVVariant::Date:
value.ptr = new QDate(*((QDate *)d->value.ptr));
break;
case TVVariant::Time:
value.ptr = new QTime(*((QTime *)d->value.ptr));
break;
case TVVariant::Int:
value.i = d->value.i;
break;
default:
ASSERT( 0 );
}
typ = d->typ;
}
TVVariantPrivate::~TVVariantPrivate()
{
@@ -219,193 +227,193 @@ void TVVariant::detach()
{
if (d->count == 1)
return;
d->deref();
d = new TVVariantPrivate(d);
}
const QString TVVariant::typeName() const
{
return typeToName(d->typ);
}
void TVVariant::clear()
{
if (d->count > 1)
{
d->deref();
d = new TVVariantPrivate;
return;
}
d->clear();
}
const QString TVVariant::typeToName(KeyType typ)
{
switch(typ) {
case String:
return QString("String");
case Date:
return QString("Date");
case Time:
return QString("Time");
case Int:
return QString("Int");
case Invalid:
default:
return QString("Invalid");
}
return QString("Invalid");
}
TVVariant::KeyType TVVariant::nameToType(const QString &name)
{
if(!qstrcmp("String", name))
return String;
if(!qstrcmp("Date", name))
return Date;
if(!qstrcmp("Time", name))
return Time;
if(!qstrcmp("Int", name))
return Int;
return Invalid;
}
void TVVariant::load(QDataStream &s )
{
KeyType t;
s >> t;
d->typ = t;
switch(t) {
case Invalid:
d->typ = t;
break;
case String:
{
QString *x = new QString;
s >> *x;
d->value.ptr = x;
}
break;
case Time:
{
QTime *x = new QTime;
s >> *x;
d->value.ptr = x;
}
break;
case Date:
{
QDate *x = new QDate;
s >> *x;
d->value.ptr = x;
}
break;
case Int:
{
int x;
s >> x;
d->value.i = x;
}
break;
default:
- qFatal("Unrecognized data type");
+ ofatal << "Unrecognized data type" << oendl;
}
}
void TVVariant::save( QDataStream &s ) const
{
s << type();
switch( d->typ ) {
case String:
s << *((QString *)d->value.ptr);
break;
case Date:
s << *((QDate *)d->value.ptr);
break;
case Time:
s << *((QTime *)d->value.ptr);
break;
case Int:
s << d->value.i;
break;
case Invalid:
break;
}
}
QDataStream& operator>>(QDataStream& s, TVVariant& p)
{
p.load( s );
return s;
}
QDataStream& operator<<(QDataStream &s, const TVVariant& p)
{
p.save( s );
return s;
}
QDataStream& operator>> (QDataStream &s, TVVariant::KeyType& p)
{
Q_UINT8 u = 0;
s >> u;
p = (TVVariant::KeyType) u;
return s;
}
QDataStream& operator<< (QDataStream& s, const TVVariant::KeyType& p)
{
s << (Q_UINT8)p;
return s;
}
const QString TVVariant::toString() const
{
switch(d->typ) {
case String:
return *((QString*)d->value.ptr);
case Date:
return ((QDate*)d->value.ptr)->toString();
case Time:
return ((QTime*)d->value.ptr)->toString();
case Int:
return QString::number(d->value.i);
case Invalid:
default:
return QString::null;
}
return QString::null;
}
// TODO DO, this properly, */
int TVVariant::toInt() const
{
if(d->typ == Int)
return d->value.i;
if(d->typ == String) {
QString tmpq(*(QString *)d->value.ptr);
return parseNextNumber(&tmpq);
}
return 0;
}
const QDate TVVariant::toDate() const
{
if(d->typ == Date)
return *((QDate *)d->value.ptr);
if(d->typ == String) {
QString q = toString();
/* date format is day mon d yyyy */
/* ignore the first three letters, read the next
three for month.. etc */
@@ -985,193 +993,193 @@ bool KeyList::validIndex(int i) const
return FALSE;
return TRUE;
}
QDataStream &operator<<( QDataStream &s, const KeyList &k)
{
s << k.getNumFields();
KeyListIterator it(k);
while(it.current()) {
s << (Q_UINT16)it.currentKey();
s << it.current()->name();
s << it.current()->example();
s << (Q_UINT16)it.current()->flags();
++it;
}
return s;
}
QDataStream &operator>>( QDataStream &s, KeyList &k)
{
int i;
int size;
int index = 0;
int flags = 0;
TVVariant type = TVVariant();
QString name;
s >> size;
for (i=0; i < size; i++) {
s >> (Q_UINT16 &)index;
s >> name;
s >> type;
s >> (Q_UINT16 &)flags;
k.replace(index, new Key(name, type, flags));
}
return s;
}
/*!
\class DataElem
\brief A class representing a single row or element of a table in a DBStore
This class holds the data of a row in a table.
*/
/*!
Constructs a DataElem. This function needs a container because the
size, types of keys and primary key are all defined by the containing
database
*/
DataElem::DataElem(DBStore *c) : values(20)
{
int size;
contained = c;
size = c->getNumFields();
values.setAutoDelete(TRUE);
}
/*!
Destroys a DataElem and frees memory used by the DataElem
*/
DataElem::~DataElem() {
}
QDataStream &operator<<( QDataStream &s, const DataElem &d)
{
int size = d.getNumFields();
s << size; /* redundent data but makes streaming easier */
KeyList k = d.getKeys();
KeyListIterator it(k);
while(it.current()) {
s << (Q_UINT16)it.currentKey();
s << d.getField(it.currentKey());
++it;
}
return s;
}
QDataStream &operator>>( QDataStream &s, DataElem &d)
{
int i;
int size;
TVVariant t;
int index = 0;
s >> size; /* redundent data but makes streaming easier */
if (size != d.getNumFields()) {
- qWarning("DataSize mis-match");
+ owarn << "DataSize mis-match" << oendl;
return s; /* sanity check failed.. don't load */
}
for(i = 0; i < size; i++) {
s >> (Q_UINT16)index;
s >> t;
d.setField(index, t);
}
return s;
}
/*! Returns the number of possible (not valid) fields in the data element */
int DataElem::getNumFields() const
{
return contained->getNumFields();
}
KeyList DataElem::getKeys() const
{
return *(contained->getKeys());
}
/*!
This function determines whether field index i of the element has been
set yet.
\return A boolean value that is TRUE if the specfied field of this
element has been set and FALSE if the field has not yet been set
*/
bool DataElem::hasValidValue(int i) const
{
if(!values.find(i))
return FALSE;
if(!contained->getKeys()->validIndex(i))
return FALSE;
return values.find(i)->isValid();
}
/*!
This function determines whether field name qs of the element has been
set yet.
\return A boolean value that is TRUE if the specfied field of this
element has been set and FALSE if the field has not yet been set
*/
bool DataElem::hasValidValue(QString qs) const
{
int i = contained->getKeyIndex(qs);
return hasValidValue(i);
}
/*! returns the type of the field specified by index i */
TVVariant::KeyType DataElem::getFieldType(int i) const
{
return contained->getKeyType(i);
}
/*! returns the type of the field specified by name qs */
TVVariant::KeyType DataElem::getFieldType(QString qs) const
{
int i = contained->getKeyIndex(qs);
return contained->getKeyType(i);
}
/*!
returns a pointer to the data stored in field index i for this
data element, (value may not be valid)
*/
TVVariant DataElem::getField(int i) const
{
if(hasValidValue(i))
return TVVariant(*values.find(i));
return TVVariant();
}
/*!
returns a pointer to the data stored in field name qs for this
data element, (value may not be valid)
*/
TVVariant DataElem::getField(QString qs) const
{
int i = contained->getKeyIndex(qs);
return getField(i);
}
/*!
Sets the value of the elements field index i to the value represented in
the QString q.
\param i index of the field to set
\param q a string that can be parsed to get the value to be set
*/
void DataElem::setField(int i, QString q)
{
/* from the type of the field, parse q and store */
TVVariant::KeyType kt = contained->getKeyType(i);
@@ -1284,187 +1292,187 @@ QString DataElem::toQString() const
/*! formats individual fields to strings so can be displayed */
QString DataElem::toQString(int i) const
{
if(hasValidValue(i)) {
return getField(i).toString();
}
return "";
}
/*! formats individual fields to strings so can be sorted by QListView */
QString DataElem::toSortableQString(int i) const
{
QString scratch = "";
if(hasValidValue(i)) {
switch (contained->getKeyType(i)) {
case TVVariant::String: {
scratch += getField(i).toString();
break;
}
case TVVariant::Int: {
scratch.sprintf("%08d", getField(i).toInt());
break;
}
case TVVariant::Date: {
static QDate epochD(1800, 1, 1);
scratch.sprintf("%08d",
epochD.daysTo(getField(i).toDate()));
break;
}
case TVVariant::Time: {
static QTime epochT(0, 0, 0);
scratch.sprintf("%08d",
epochT.msecsTo(getField(i).toTime()));
break;
}
default:
scratch += "Unknown type";
break;
}
}
return scratch;
}
/* compare functions */
bool DataElem::lessThan(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
return (getField(i) < v);
}
bool DataElem::moreThan(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
return (getField(i) > v);
}
bool DataElem::equalTo(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
return (getField(i) == v);
}
bool DataElem::contains(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
if (qs1.contains(qs2) > 0) return TRUE;
break;
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
break;
default:
- qWarning("Tried to compare unknown data type");
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
bool DataElem::startsWith(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
return qs1.startsWith(qs2);
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
return FALSE;
default:
- qWarning("Tried to compare unknown data type");
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
bool DataElem::endsWith(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
return qs1.startsWith(qs2);
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
return FALSE;
default:
- qWarning("Tried to compare unknown data type");
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
/*!
Determins which of the first to parameters are closer to the third, target
parameter.
\return
<UL>
<LI>TRUE if the first element is a closer match to the target than the
second element</LI>
<LI>FALSE if the first element is not a closer match to the target than
the second element</LI>
</UL>
*/
bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column)
{
int type;
if(!d1) return FALSE;
if (!d1->hasValidValue(column)) return FALSE;
if(!target.isValid()) return FALSE;
type = d1->getField(column).type();
if(d2) {
if (type != d2->getField(column).type()) {
/* can't do compare */
- qWarning("Tried to compare two incompatable types");
+ owarn << "Tried to compare two incompatable types" << oendl;
return FALSE;
}
return target.closer(d1->getField(column), d2->getField(column));
}
return target.close(d1->getField(column));
}
diff --git a/noncore/apps/tableviewer/db/datacache.cpp b/noncore/apps/tableviewer/db/datacache.cpp
index 7c14eef..6380e1b 100644
--- a/noncore/apps/tableviewer/db/datacache.cpp
+++ b/noncore/apps/tableviewer/db/datacache.cpp
@@ -1,249 +1,257 @@
/**********************************************************************
** 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.
**
**********************************************************************/
/*
* This file is used to load the xml files that represent the database.
* The main requirment for said file is each data entry must contain a key,
* otherwise any other data headings are allowed.
*/
#include "datacache.h"
#include "xmlsource.h"
#include "csvsource.h"
-#include <stdlib.h>
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qheader.h>
+/* STD */
+#include <stdlib.h>
+
#define INIT_TABLE_SIZE 128
/*!
\class DBStore datastore.h
\brief The DBStore class is the class responsible for storing, sorting and
searching the data loaded by the application
*/
/*!
Constructs a DBStore item
*/
DBStore::DBStore()
{
name = "";
number_elems = 0;
full = false;
kRep = new KeyList();
master_table.resize(INIT_TABLE_SIZE);
table_size = INIT_TABLE_SIZE;
current_elem = 0;
archive = 0;
}
//TODO
/*!
Reinitializes the table to empty (include a resize of the master table,
which should free some memory)
*/
void DBStore::freeTable()
{
name = "";
if(archive) {
delete archive;
archive = 0;
}
kRep->clear(); /* clear the current key list */
number_elems = 0;
table_size = INIT_TABLE_SIZE;
master_table.resize(table_size);
full = false;
current_elem = 0;
}
/*!
Removes all items from the DBStore and destroys the DBStore
*/
DBStore::~DBStore()
{
freeTable();
}
/*!
This function opens the given xml file, loads it and sets up the
appropriate data structures.
\param file_name A string representing the name of the file to be opened
\return true if successful, false otherwise.
*/
bool DBStore::openSource(QIODevice *inDev, const QString &source) {
/* first check if db is already open, if contains data.. then clear */
if(number_elems > 0) {
freeTable();
}
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
} else if (source == "text/csv") {
archive = new DBCsv(this);
} else
return false;
return (archive->openSource(inDev));
}
bool DBStore::saveSource(QIODevice *outDev, const QString &source)
{
/* saving a new file */
if(!archive) {
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
} else if (source == "text/x-xml-tableviewer") {
archive = new DBCsv(this);
} else
return false;
}
/* changing file type */
if(archive->type() != source) {
delete archive;
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
} else if (source == "text/x-xml-tableviewer") {
archive = new DBCsv(this);
} else
return false;
}
return (archive->saveSource(outDev));
}
/*!
This function is used to add new elements to the database. If the database
has already reached the maximum allowable size this function does not alter
the database.
\param delm An already allocated and initialized data element to be added
*/
void DBStore::addItem(DataElem *delem)
{
addItemInternal(delem);
}
void DBStore::addItemInternal(DataElem *delem)
{
/* if already full, don't over fill, do a qWarning though */
if (full) {
- qWarning("Attempted to add items to already full table");
+ owarn << "Attempted to add items to already full table" << oendl;
return;
}
master_table.insert(number_elems, delem);
current_elem = number_elems;
number_elems++;
if(number_elems >= table_size) {
/* filled current table, double if we can */
table_size = table_size << 1;
/* check that the new table size is still valid, i.e. that we didn't
just shift the 1 bit of the end of the int. */
if (!table_size) {
full = true;
/* no point in doing antying else. */
return;
}
master_table.resize(table_size);
}
}
void DBStore::removeItem(DataElem *r)
{
int position = master_table.findRef(r);
if(position != -1) {
/* there is at least one item, this is it */
/* replace this with the last element, decrease the element count */
master_table.insert(position, master_table.at(--number_elems));
master_table.remove(number_elems);
delete r;
}
}
/*!
Sets the name of the database
\param n A string representing the new name of the database.
*/
void DBStore::setName(const QString &n)
{
name = n;
}
/*!
Gets the name of the database
\return A string representing the name of the database.
*/
QString DBStore::getName()
{
return name;
}
/*!
Retrieves a pointer to the key representation of the database for
other classes to use as reference.
\return a pointer to the databases key representaion
*/
KeyList *DBStore::getKeys()
{
return kRep;
}
/*!
sets the database's key representation the passed pointer
\param a pointer to a key representaton
*/
void DBStore::setKeys(KeyList *k)
{
kRep = k;
}
/*!
Sets the current element to the first element of the database
*/
void DBStore::first()
{
current_elem = 0;
}
/*!
Sets the current element to the last element of the database
*/
void DBStore::last()
{
current_elem = number_elems - 1;
}
/*!
Sets the current element to the next element of the database if
there exists an element after the current one.
*/
bool DBStore::next()
diff --git a/noncore/apps/tableviewer/db/xmlsource.cpp b/noncore/apps/tableviewer/db/xmlsource.cpp
index 94fec36..4ca6aee 100644
--- a/noncore/apps/tableviewer/db/xmlsource.cpp
+++ b/noncore/apps/tableviewer/db/xmlsource.cpp
@@ -1,297 +1,303 @@
/**********************************************************************
** 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 "xmlsource.h"
-#include <qdict.h>
-#include <stdlib.h>
-#include <qtextstream.h>
#include "../xmlencodeattr.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+/* QT */
+#include <qdict.h>
+#include <qtextstream.h>
+
+/* STD */
+#include <stdlib.h>
DBXml::DBXml(DBStore *d)
{
dstore = d;
}
QString DBXml::type()
{
return "xml";
}
bool DBXml::openSource(QIODevice *inDev)
{
bool ok;
DBXmlHandler h(dstore);
QTextStream tsIn(inDev);
QXmlInputSource source(tsIn);
QXmlSimpleReader reader;
reader.setContentHandler(&h);
reader.setErrorHandler(&h);
ok = reader.parse(source);
return ok;
}
bool DBXml::saveSource(QIODevice *outDev)
{
int i;
DataElem *elem;
KeyList *k;
QTextStream outstream(outDev);
outstream << "<database name=\"" << dstore->getName() << "\">" << endl;
outstream << "<header>" << endl;
k = dstore->getKeys();
KeyListIterator it(*k);
while(it.current()) {
if (!it.current()->delFlag()) {
outstream << "<key name=\"KEYID" << it.currentKey() << "\" ";
outstream << "type=\""
<< TVVariant::typeToName(it.current()->type())
<< "\">";
outstream << encodeAttr(it.current()->name()) << "</key>" << endl;
}
++it;
}
outstream << "</header>" << endl;
dstore->first();
do {
elem = dstore->getCurrentData();
if (!elem)
break;
outstream << "<record>" << endl;
it.toFirst();
while (it.current()) {
i = it.currentKey();
if (elem->hasValidValue(i)) {
outstream << "<KEYID" << i << ">";
if (dstore->getKeyType(i) == TVVariant::Date) {
// dates in files are different from displayed dates
QDate date = elem->getField(i).toDate();
outstream << date.day() << "/"
<< date.month() << "/"
<< date.year();
} else {
outstream << encodeAttr(elem->toQString(i));
}
outstream << "</KEYID" << i << ">" << endl;
}
++it;
}
outstream << "</record>" << endl;
} while(dstore->next());
outstream << "</database>" << endl;
return TRUE;
}
DBXml::~DBXml() {}
/*!
\class DBXmlHandler
\brief An Xml parser for flat tables.
An xml parser for parsing the files used by the table viewer application.
The format of the xml files can be found at the front of the file
dataparser.h
*/
/*!
Constructs a new DBXmlHandler, and sets that the table should be
constructed in the DBStore pointed to by ds.
*/
DBXmlHandler::DBXmlHandler(DBStore *ds)
{
data_store = ds;
current_keyrep = 0;
}
/*!
Destroys the DBXmlHandler
*/
DBXmlHandler::~DBXmlHandler()
{
}
QString DBXmlHandler::errorProtocol()
{
- qWarning("Error reading file");
+ owarn << "Error reading file" << oendl;
return errorProt;
}
bool DBXmlHandler::startDocument()
{
errorProt = "";
state = StateInit;
return TRUE;
}
bool DBXmlHandler::startElement(const QString&, const QString&,
const QString& qName, const QXmlAttributes& atts)
{
if (state == StateInit && qName == "database") {
// First thing it expects is a <document name="..."> tag
state = StateDocument;
data_store->setName(atts.value("name"));
return TRUE;
}
if (state == StateDocument && qName == "header") {
state = StateHeader;
if (current_keyrep) delete current_keyrep;
current_keyrep = new KeyList();
return TRUE;
}
if (state == StateHeader && qName == "key") {
/* Ok, adding a new key to our KeyList TODO */
state = StateKey;
last_key_type = TVVariant::String;
key = atts.value("name");
if (key.isEmpty()) {
- qWarning("empty key name");
+ owarn << "empty key name" << oendl;
return FALSE;
}
if(!atts.value("type").isEmpty())
last_key_type = TVVariant::nameToType(atts.value("type"));
return TRUE;
}
if (state == StateDocument && qName == "record") {
state = StateRecord;
current_data = new DataElem(data_store);
// Now expecting a <record> tag
return TRUE;
}
if (state == StateRecord) {
state = StateField;
/* the qName is the name of a key */
if (!keyIndexList[qName]) {
/* invalid key, we failed */
- qWarning("Invalid key in record");
+ owarn << "Invalid key in record" << oendl;
return FALSE;
}
keyIndex = *keyIndexList[qName];
return TRUE;
}
- qWarning("Unable to determine tag type");
+ owarn << "Unable to determine tag type" << oendl;
return FALSE;
}
bool DBXmlHandler::endElement(const QString&, const QString&,
const QString& qName)
{
switch(state) {
case StateField:
// TODO checks 'could' be done of the popped value
state = StateRecord;
break;
case StateKey:
// TODO checks 'could' be done of the popped value
state = StateHeader;
break;
case StateHeader:
data_store->setKeys(current_keyrep);
state = StateDocument;
break;
case StateRecord:
data_store->addItem(current_data);
state = StateDocument;
break;
case StateDocument:
// we are done...
break;
default:
// should only get a 'endElement' from one of the above states.
- qWarning("Invalid end tag");
+ owarn << "Invalid end tag" << oendl;
return FALSE;
break;
}
return TRUE;
}
bool DBXmlHandler::characters(const QString& ch)
{
// this is where the 'between tag' stuff happens.
// e.g. the stuff between tags.
QString ch_simplified = ch.simplifyWhiteSpace();
if (ch_simplified.isEmpty())
return TRUE;
if (state == StateKey) {
int *tmp_val = new int;
/* We just grabbed the display name of a key */
*tmp_val = current_keyrep->addKey(ch_simplified, last_key_type);
keyIndexList.insert(key, tmp_val);
return TRUE;
}
if (state == StateField) {
/* Ok, need to add data here */
current_data->setField(keyIndex, ch_simplified);
return TRUE;
}
- qWarning("Junk characters found... ignored");
+ owarn << "Junk characters found... ignored" << oendl;
return TRUE;
}
QString DBXmlHandler::errorString()
{
return "the document is not in the expected file format";
}
bool DBXmlHandler::warning(const QXmlParseException& exception)
{
errorProt += QString("warning parsing error: %1 in line %2, column %3\n" )
.arg(exception.message())
.arg(exception.lineNumber())
.arg(exception.columnNumber());
- qWarning(errorProt);
+ owarn << errorProt << oendl;
return QXmlDefaultHandler::fatalError(exception);
}
bool DBXmlHandler::error(const QXmlParseException& exception)
{
errorProt += QString("error parsing error: %1 in line %2, column %3\n" )
.arg(exception.message())
.arg(exception.lineNumber())
.arg(exception.columnNumber());
- qWarning(errorProt);
+ owarn << errorProt << oendl;
return QXmlDefaultHandler::fatalError(exception);
}
bool DBXmlHandler::fatalError(const QXmlParseException& exception)
{
errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" )
.arg(exception.message())
.arg(exception.lineNumber())
.arg(exception.columnNumber());
- qWarning(errorProt);
+ owarn << errorProt << oendl;
return QXmlDefaultHandler::fatalError(exception);
}
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp
index 102b94c..9538cb3 100644
--- a/noncore/apps/tableviewer/tableviewer.cpp
+++ b/noncore/apps/tableviewer/tableviewer.cpp
@@ -1,387 +1,389 @@
/**********************************************************************
** 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 */
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/fileselector.h>
#include <qpe/resource.h>
-#include <qtoolbar.h>
+using namespace Opie::Core;
-/* QTE includes */
+/* QT */
#include <qmenubar.h>
+#include <qtoolbar.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");
+ owarn << "Save unsuccessful" << oendl;
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();
doc = nf;
dirty = FALSE;
current_view = BrowseState;
cw->raiseWidget(current_view);
/* now set up for editing the keys */
ts.kRep->addKey("key", TVVariant::String);
editKeysSlot();
}
void TableViewerWindow::setDocument(const QString &f)
{
openDocument(DocLnk(f, TRUE));
}
void TableViewerWindow::openDocument(const DocLnk &f)
{
if (!f.isValid())
return;
FileManager fm;
QIODevice *dev = fm.openFile(f);
doc = f;
if(ds->openSource(dev, doc.type())) {
DataElem *d;
browseView->reset();
listView->reset();
filterView->reset();
current_view = BrowseState;
cw->raiseWidget(current_view);
/* set up new table state and ensure sub widgets have a reference */
ts.current_column = 0;
ts.kRep = ds->getKeys();
browseView->rebuildKeys();
listView->rebuildKeys();
filterView->rebuildKeys();
ds->first();
/* set up the list view */
listView->clearItems();
do {
d = ds->getCurrentData();
if(d)
listView->addItem(d);
} while(ds->next());
/* Set up browse view, Will be based of structure of listView */
listView->first();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
listView->rebuildData();
QString scratch = "Table Viewer";/* later take from constant */
scratch += " - ";
scratch += ds->getName();
setCaption(tr(scratch));
dirty = FALSE;
} else {
- qWarning(tr("could not load Document"));
+ owarn << tr("could not load Document") << oendl;
}
dev->close();
}
/*!
Moves to the first item of the current table
*/
void TableViewerWindow::firstItem()
{
listView->first();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Moves to the lat item of the current table
*/
void TableViewerWindow::lastItem()
{
listView->last();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Moves to the next item of the current table
*/
void TableViewerWindow::nextItem()
{
listView->next();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Moves to the previous item of the current table
*/
void TableViewerWindow::previousItem()
{
listView->previous();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Raises the List View. This is a mode change for the application.
*/
void TableViewerWindow::listViewSlot()
{
if(current_view == FilterState)
applyFilter();
current_view = ListState;
cw->raiseWidget(current_view);
}
void TableViewerWindow::applyFilter()
{
DataElem *d;
listView->clearItems();
ds->first();
do {
d = ds->getCurrentData();
if(d)
if(filterView->passesFilter(d))
listView->addItem(d);
} while(ds->next());
listView->first();
listView->rebuildData();
}
/*!
Raises the Browse View. This is a mode change for the application.
*/
void TableViewerWindow::browseViewSlot()
{
if(current_view == FilterState)
applyFilter();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
current_view = BrowseState;
cw->raiseWidget(current_view);
}
/*!
Raises the List View. This is a mode change for the application.
*/
void TableViewerWindow::filterViewSlot()
{
current_view = FilterState;
cw->raiseWidget(current_view);
}
diff --git a/noncore/apps/tableviewer/tableviewer.pro b/noncore/apps/tableviewer/tableviewer.pro
index 1de23bb..564f50f 100644
--- a/noncore/apps/tableviewer/tableviewer.pro
+++ b/noncore/apps/tableviewer/tableviewer.pro
@@ -1,38 +1,38 @@
-CONFIG = qt warn_on quick-app
+CONFIG = qt warn_on quick-app
SUBDIRS = db ui
HEADERS = tableviewer.h \
xmlencodeattr.h \
ui/commonwidgets.h \
ui/tvbrowseview.h \
ui/tvlistview.h \
ui/tvfilterview.h \
ui/tveditview.h \
ui/browsekeyentry.h \
ui/filterkeyentry.h \
ui/tvkeyedit.h \
db/datacache.h \
db/common.h \
db/xmlsource.h \
db/csvsource.h
SOURCES = main.cpp \
tableviewer.cpp \
xmlencodeattr.cpp \
ui/commonwidgets.cpp \
ui/tvbrowseview.cpp \
ui/tvfilterview.cpp \
ui/browsekeyentry.cpp \
ui/filterkeyentry.cpp \
ui/tvlistview.cpp \
ui/tveditview.cpp \
ui/tvkeyedit.cpp \
db/datacache.cpp \
db/xmlsource.cpp \
db/csvsource.cpp \
db/common.cpp
INTERFACES = ui/tvkeyedit_gen.ui
TARGET = tableviewer
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopiecore2
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopiecore2
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp
index b10ff1d..c3e6432 100644
--- a/noncore/apps/tableviewer/ui/tvlistview.cpp
+++ b/noncore/apps/tableviewer/ui/tvlistview.cpp
@@ -1,262 +1,269 @@
/**********************************************************************
** 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 "tvlistview.h"
#include "../db/common.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qtoolbutton.h>
#include <qlistview.h>
#include <qlayout.h>
void TVListViewPrivate::setColumnWidth(int column, int width)
{
if(width > 70) width = 70;
QListView::setColumnWidth(column, width);
}
void TVListViewPrivate::setSorting(int column, bool increasing)
{
emit sortChanged(column);
QListView::setSorting(column, increasing);
}
TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name,
WFlags fl) : QListView(parent, name, fl) {
;
}
class TVListViewItem : public QListViewItem
{
public:
TVListViewItem(QListView *parent, DataElem *d);
~TVListViewItem();
QString text(int i) const
{
return data_reference->toQString(i);
}
/* Do nothing... all data for this item should be generated */
void setText(int i, const QString &)
{
;
}
QString key(int i, bool a) const
{
return data_reference->toSortableQString(i);
}
void setDataElem(DataElem *d)
{
data_reference = d;
}
DataElem *getDataElem() {
return data_reference;
}
private:
DataElem *data_reference;
};
TVListViewItem::TVListViewItem(QListView *parent, DataElem *d)
: QListViewItem(parent)
{
data_reference = d;
}
TVListViewItem::~TVListViewItem()
{
data_reference = 0;
}
TVListView::TVListView(TableState *t, QWidget* parent,
const char *name, WFlags fl ) : QWidget(parent, name, fl)
{
if (!name)
setName("TVListView");
// the next two lines need to be rationalized.
resize(318,457);
setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
(QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth()));
setCaption(tr("List View"));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setSpacing(0);
layout->setMargin(0);
listViewDisplay = new TVListViewPrivate(this, "listViewDisplay");
layout->addWidget(listViewDisplay);
connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem*)), this,
SLOT(setCurrent(QListViewItem*)));
connect(listViewDisplay, SIGNAL(sortChanged(int)), this,
SLOT(setSorting(int)));
listViewDisplay->setShowSortIndicator(true);
it = new QListViewItemIterator(listViewDisplay);
ts = t;
}
TVListView::~TVListView()
{
}
void TVListView::addItem(DataElem *d)
{
TVListViewItem *i = new TVListViewItem(listViewDisplay, d);
delete it;
it = new QListViewItemIterator(i);
}
/* remove current (it) item */
void TVListView::removeItem()
{
QListViewItemIterator other(*it);
QListViewItemIterator tmp = *it;
(*it)++;
if (!it->current()) {
*it = tmp;
(*it)--;
if (!it->current()) {
delete it;
it = 0;
}
}
delete other.current();
}
void TVListView::clearItems()
{
/* This is ok since the destructor for TVListItem does not know about
the data_reference pointer.. and hence will leave it alone */
listViewDisplay->clear();
delete it;
it = new QListViewItemIterator(listViewDisplay);
}
void TVListView::first()
{
delete it;
it = new QListViewItemIterator(listViewDisplay);
}
void TVListView::last()
{
- qWarning("TVListView::last not yet implemented");
+ owarn << "TVListView::last not yet implemented" << oendl;
}
void TVListView::next()
{
QListViewItemIterator tmp = *it;
(*it)++;
if (!it->current()) {
*it = tmp;
}
}
void TVListView::previous()
{
QListViewItemIterator tmp = *it;
(*it)--;
if (!it->current()) {
*it = tmp;
}
}
DataElem *TVListView::getCurrentData() {
if (it->current()) {
return ((TVListViewItem *)it->current())->getDataElem();
}
return NULL;
}
/*! Now to implement the closest match function */
void TVListView::findItem(int keyId, TVVariant value)
{
QListViewItem *i;
TVListViewItem *best_so_far = NULL;
/* start at the beginning... go through till find the closest elem */
i = listViewDisplay->firstChild();
while (i) {
/* search stuff */
if(best_so_far) {
if (DataElem::closer(
((TVListViewItem *)i)->getDataElem(),
best_so_far->getDataElem(), value, keyId))
best_so_far = (TVListViewItem *)i;
} else {
if (DataElem::closer(
((TVListViewItem *)i)->getDataElem(),
NULL, value, keyId))
best_so_far = (TVListViewItem *)i;
}
i = i->itemBelow();
}
if (best_so_far) {
/* set best_so_far to current element */
delete it;
it = new QListViewItemIterator(best_so_far);
}
}
void TVListView::rebuildKeys()
{
int i;
if(!ts) return;
if(!ts->kRep) return;
i = listViewDisplay->columns();
while(i > 0)
listViewDisplay->removeColumn(--i);
KeyListIterator kit(*ts->kRep);
i = 0;
while(kit.current()) {
if(!kit.current()->delFlag()) {
listViewDisplay->addColumn(kit.current()->name());
keyIds.insert(i, kit.currentKey());
++i;
}
++kit;
}
}
void TVListView::setSorting(int column)
{
/* Without table state can't do anything */
if (ts == 0)
return;
if (keyIds[column] != ts->current_column) {
ts->current_column = keyIds[column];
}
}
void TVListView::rebuildData() {
int i;
QMap<int, int>::Iterator kit;
/* Need to set sort order */
if(!ts)
diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro
index 11ee275..1552dff 100644
--- a/noncore/apps/tinykate/libkate/libkate.pro
+++ b/noncore/apps/tinykate/libkate/libkate.pro
@@ -1,90 +1,87 @@
TEMPLATE = lib
-CONFIG = qt warn_on
-HEADERS = microkde/kapplication.h \
- kateconfig.h \
- microkde/kdebug.h \
- microkde/kdialog.h \
- microkde/kdialogbase.h \
- microkde/kfiledialog.h \
- microkde/kglobal.h \
- microkde/kiconloader.h \
- microkde/klineedit.h \
- microkde/klocale.h \
- microkde/kmessagebox.h \
- microkde/kprinter.h \
- microkde/krestrictedline.h \
- microkde/kseparator.h \
- microkde/kstandarddirs.h \
- microkde/ktempfile.h \
- microkde/kunload.h \
- microkde/kurlrequester.h \
- microkde/kfontdialog.h \
- microkde/krun.h \
- microkde/knumvalidator.h \
- microkde/kstaticdeleter.h \
- microkde/klistview.h \
- microkde/kglobalsettings.h \
- microkde/kcolorbtn.h \
- \
+CONFIG = qt warn_on
+HEADERS = microkde/kapplication.h \
+ kateconfig.h \
+ microkde/kdebug.h \
+ microkde/kdialog.h \
+ microkde/kdialogbase.h \
+ microkde/kfiledialog.h \
+ microkde/kglobal.h \
+ microkde/kiconloader.h \
+ microkde/klineedit.h \
+ microkde/klocale.h \
+ microkde/kmessagebox.h \
+ microkde/kprinter.h \
+ microkde/krestrictedline.h \
+ microkde/kseparator.h \
+ microkde/kstandarddirs.h \
+ microkde/ktempfile.h \
+ microkde/kunload.h \
+ microkde/kurlrequester.h \
+ microkde/kfontdialog.h \
+ microkde/krun.h \
+ microkde/knumvalidator.h \
+ microkde/kstaticdeleter.h \
+ microkde/klistview.h \
+ microkde/kglobalsettings.h \
+ microkde/kcolorbtn.h \
\
- qt3back/qregexp3.h \
- microkde/ksharedptr.h \
- document/katebuffer.h document/katedialogs.h \
- document/katetextline.h \
- document/katecmd.h \
- document/katehighlight.h \
- document/katecmds.h document/katedocument.h \
- document/katesyntaxdocument.h \
- view/kateundohistory.h \
- view/kateview.h \
- view/kateviewdialog.h \
- interfaces/view.h \
- interfaces/document.h \
- ktexteditor/ktexteditor.h
+ qt3back/qregexp3.h \
+ microkde/ksharedptr.h \
+ document/katebuffer.h document/katedialogs.h \
+ document/katetextline.h \
+ document/katecmd.h \
+ document/katehighlight.h \
+ document/katecmds.h document/katedocument.h \
+ document/katesyntaxdocument.h \
+ view/kateundohistory.h \
+ view/kateview.h \
+ view/kateviewdialog.h \
+ interfaces/view.h \
+ interfaces/document.h \
+ ktexteditor/ktexteditor.h
-SOURCES = microkde/kapplication.cpp \
- microkde/kdialogbase.cpp \
- kateconfig.cpp \
- microkde/klocale.cpp \
- microkde/kmessagebox.cpp \
- microkde/kprocess.cpp \
- microkde/kstandarddirs.cpp \
- microkde/ktempfile.cpp \
- microkde/kurlrequester.cpp \
- microkde/kfontdialog.cpp \
- microkde/krun.cpp \
- microkde/knumvalidator.cpp \
- microkde/kglobal.cpp \
- microkde/kglobalsettings.cpp \
- microkde/kcolorbtn.cpp \
- \
- \
- qt3back/qregexp3.cpp \
- ktexteditor/ktexteditor.cpp \
- document/katebuffer.cpp document/katedialogs.cpp \
- document/katehighlight.cpp \
- document/katecmd.cpp \
- document/katesyntaxdocument.cpp document/katecmds.cpp \
- document/katedocument.cpp document/katetextline.cpp \
- view/kateundohistory.cpp \
- view/kateview.cpp \
- view/kateviewdialog.cpp \
- interfaces/interfaces.cpp
-
-INTERFACES =
-INCLUDEPATH += $(OPIEDIR)/include \
+SOURCES = microkde/kapplication.cpp \
+ microkde/kdialogbase.cpp \
+ kateconfig.cpp \
+ microkde/klocale.cpp \
+ microkde/kmessagebox.cpp \
+ microkde/kprocess.cpp \
+ microkde/kstandarddirs.cpp \
+ microkde/ktempfile.cpp \
+ microkde/kurlrequester.cpp \
+ microkde/kfontdialog.cpp \
+ microkde/krun.cpp \
+ microkde/knumvalidator.cpp \
+ microkde/kglobal.cpp \
+ microkde/kglobalsettings.cpp \
+ microkde/kcolorbtn.cpp \
+ \
+ qt3back/qregexp3.cpp \
+ ktexteditor/ktexteditor.cpp \
+ document/katebuffer.cpp document/katedialogs.cpp \
+ document/katehighlight.cpp \
+ document/katecmd.cpp \
+ document/katesyntaxdocument.cpp document/katecmds.cpp \
+ document/katedocument.cpp document/katetextline.cpp \
+ view/kateundohistory.cpp \
+ view/kateview.cpp \
+ view/kateviewdialog.cpp \
+ interfaces/interfaces.cpp
+INTERFACES =
+INCLUDEPATH += $(OPIEDIR)/include \
$(OPIEDIR)/noncore/apps/tinykate/libkate \
$(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
$(OPIEDIR)/noncore/apps/tinykate/libkate/document \
$(OPIEDIR)/noncore/apps/tinykate/libkate/view \
$(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
$(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
$(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
-DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lqtaux2 -lopiecore2 -lopieui2
-TARGET = tinykate
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lqtaux2 -lopiecore2 -lopieui2
+TARGET = tinykate
INCLUDEPATH += $(OPIEDIR)/include
DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro
index 6f4baa8..d34e519 100644
--- a/noncore/apps/tinykate/tinykate.pro
+++ b/noncore/apps/tinykate/tinykate.pro
@@ -1,22 +1,20 @@
-TEMPLATE = app
-CONFIG = qt warn_on quick-app
+TEMPLATE = app
+CONFIG = qt warn_on quick-app
DESTDIR = $(OPIEDIR)/bin
HEADERS = tinykate.h
SOURCES = tinykate.cpp main.cpp
-INTERFACES =
INCLUDEPATH += $(OPIEDIR)/include \
- $(OPIEDIR)/noncore/apps/tinykate/libkate \
- $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
- $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
- $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
- $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
- $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
- $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
-
-DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -ltinykate -lopiecore2 -lopieui2
-TARGET = kate
+ $(OPIEDIR)/noncore/apps/tinykate/libkate \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
+ $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -ltinykate -lopiecore2 -lopieui2
+TARGET = kate
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/zsafe/config.in b/noncore/apps/zsafe/config.in
index 6e321f3..b6d3ffe 100644
--- a/noncore/apps/zsafe/config.in
+++ b/noncore/apps/zsafe/config.in
@@ -1,5 +1,5 @@
config ZSAFE
boolean "zsafe (Zaurus Password Manager)"
default "y"
- depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI
diff --git a/noncore/apps/zsafe/scqtfiledlg.cpp b/noncore/apps/zsafe/scqtfiledlg.cpp
index 52b8d0d..c67bbd5 100644
--- a/noncore/apps/zsafe/scqtfiledlg.cpp
+++ b/noncore/apps/zsafe/scqtfiledlg.cpp
@@ -1,106 +1,103 @@
-/****************************************************************************
-** Form implementation generated from reading ui file 'scqtfiledlg.ui'
-**
-** Created: Sun Jun 8 15:51:12 2003
-** by: The User Interface Compiler (uic)
-**
-** WARNING! All changes made in this file will be lost!
-****************************************************************************/
#include "scqtfiledlg.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qcombobox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qtoolbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
static const char* const image0_data[] = {
"24 16 3 1",
". c None",
"# c #000040",
"a c #808080",
"........................",
"........................",
".................####...",
".................####...",
".......##........#aa#...",
"......###........#aa#...",
".....####........#aa#...",
"....##############aa#...",
"...###aaaaaaaaaaaaaa#...",
"..####aaaaaaaaaaaaaa#...",
"...###aaaaaaaaaaaaaa#...",
"....#################...",
".....####...............",
"......###...............",
".......##...............",
"........................"};
static const char* const image1_data[] = {
"24 16 4 1",
". c None",
"a c #008080",
"b c #808080",
"# c #ff0000",
"........................",
"........................",
"...####..........####...",
"...#####........#####...",
"....######.....#####a...",
".....######...#####ba...",
".....aa###########bba...",
"....aaaaa#######aabba...",
"...aaabbb######bbbbba...",
"..aaaabb########bbbba...",
"...aaa############bba...",
"....a######aaa#####aa...",
"....######.....######...",
"...#####a........####...",
"...####aa.........###...",
"........................"};
static const char* const image2_data[] = {
"17 15 4 1",
"# c #000000",
". c #dcdcdc",
"a c #ffff00",
"b c #ffffff",
".................",
"............#....",
".................",
"............#....",
".........#.....#.",
"....####..#.#.#..",
"...#abab#..#.#...",
"..##########..#.#",
"..#babababab##...",
"..#ababababa#.#..",
"..#babababab#..#.",
"..#ababababa#....",
"..#babababab#....",
"..#ababababa#....",
"..###########...."};
/*
* Constructs a ScQtFileDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
ScQtFileDlg::ScQtFileDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
QPixmap image0( ( const char** ) image0_data );
QPixmap image1( ( const char** ) image1_data );
QPixmap image2( ( const char** ) image2_data );
if ( !name )
setName( "ScQtFileDlg" );
resize( 196, 279 );
if (!name)
setCaption( tr( "FileDlg" ) );
else
setCaption(name);
@@ -123,134 +120,134 @@ ScQtFileDlg::ScQtFileDlg( QWidget* parent, const char* name, bool modal, WFlags
TypeComboBox = new QComboBox( FALSE, this, "TypeComboBox" );
TypeComboBox->setEditable( TRUE );
TypeComboBox->setInsertionPolicy( QComboBox::AtBottom );
TypeComboBox->setAutoCompletion( FALSE );
TypeComboBox->setDuplicatesEnabled( FALSE );
QToolTip::add( TypeComboBox, tr( "file type filter" ) );
QWhatsThis::add( TypeComboBox, tr( "ComboBox FileTypeFilter\n"
"\n"
"edit or select the filter" ) );
Layout3->addWidget( TypeComboBox );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
Layout3->addItem( spacer );
OkButton = new QToolButton( this, "OkButton" );
OkButton->setText( tr( "" ) );
OkButton->setPixmap( image0 );
OkButton->setUsesBigPixmap( FALSE );
QToolTip::add( OkButton, tr( "confirms the selection and closes the form" ) );
QWhatsThis::add( OkButton, tr( "OKButton" ) );
Layout3->addWidget( OkButton );
CancelButton = new QToolButton( this, "CancelButton" );
CancelButton->setText( tr( "" ) );
CancelButton->setPixmap( image1 );
CancelButton->setUsesBigPixmap( FALSE );
QToolTip::add( CancelButton, tr( "cancels the selection and closes the form" ) );
QWhatsThis::add( CancelButton, tr( "CancelButton" ) );
Layout3->addWidget( CancelButton );
Layout4->addLayout( Layout3 );
Layout3_2 = new QHBoxLayout;
Layout3_2->setSpacing( 6 );
Layout3_2->setMargin( 0 );
FNameLineEdit = new QLineEdit( this, "FNameLineEdit" );
QToolTip::add( FNameLineEdit, tr( "shows the selected filename" ) );
QWhatsThis::add( FNameLineEdit, tr( "Filename LineEdit\n"
"\n"
"shows the selected file\n"
"and allows the direct filename\n"
"edit" ) );
Layout3_2->addWidget( FNameLineEdit );
MkDirButton = new QToolButton( this, "MkDirButton" );
MkDirButton->setText( tr( "" ) );
MkDirButton->setPixmap( image2 );
MkDirButton->setUsesBigPixmap( FALSE );
QToolTip::add( MkDirButton, tr( "confirms the selection and closes the form" ) );
QWhatsThis::add( MkDirButton, tr( "OKButton" ) );
Layout3_2->addWidget( MkDirButton );
Layout4->addLayout( Layout3_2 );
DirComboBox = new QComboBox( FALSE, this, "DirComboBox" );
DirComboBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, DirComboBox->sizePolicy().hasHeightForWidth() ) );
DirComboBox->setEditable( TRUE );
DirComboBox->setDuplicatesEnabled( FALSE );
QWhatsThis::add( DirComboBox, tr( "ComboBox Directory \n"
"edit or select the directories name" ) );
Layout4->addWidget( DirComboBox );
Layout5->addLayout( Layout4 );
ListView = new QListView( this, "ListView" );
ListView->addColumn( tr( "Name" ) );
ListView->addColumn( tr( "size" ) );
ListView->addColumn( tr( "type" ) );
ListView->setRootIsDecorated( TRUE );
QToolTip::add( ListView, tr( "directory listview" ) );
QWhatsThis::add( ListView, tr( "Directory ListView\n"
"\n"
"shows the list of dirs and files" ) );
Layout5->addWidget( ListView );
ScQtFileDlgLayout->addLayout( Layout5 );
// signals and slots connections
connect( OkButton, SIGNAL( clicked() ), this, SLOT( slotOK() ) );
connect( DirComboBox, SIGNAL( activated(int) ), this, SLOT( slotDirComboBoxChanged(int) ) );
connect( TypeComboBox, SIGNAL( activated(int) ), this, SLOT( slotTypeComboBoxChanged(int) ) );
connect( CancelButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );
connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) );
connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) );
connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( slotDoubleClicked(QListViewItem*) ) );
connect( FNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotFileTextChanged(const QString&) ) );
connect( FNameLineEdit, SIGNAL( returnPressed() ), this, SLOT( slotOK() ) );
connect( MkDirButton, SIGNAL( clicked() ), this, SLOT( slotMkDir() ) );
}
/*
* Destroys the object and frees any allocated resources
*/
ScQtFileDlg::~ScQtFileDlg()
{
// no need to delete child widgets, Qt does it all for us
}
void ScQtFileDlg::slotCancel()
{
- qWarning( "ScQtFileDlg::slotCancel(): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotCancel(): Not implemented yet!" << oendl;
}
void ScQtFileDlg::slotDirComboBoxChanged( int )
{
- qWarning( "ScQtFileDlg::slotDirComboBoxChanged( int ): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotDirComboBoxChanged( int ): Not implemented yet!" << oendl;
}
void ScQtFileDlg::slotDoubleClicked(QListViewItem *)
{
- qWarning( "ScQtFileDlg::slotDoubleClicked(QListViewItem *): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotDoubleClicked(QListViewItem *): Not implemented yet!" << oendl;
}
void ScQtFileDlg::slotFileTextChanged( const QString & )
{
- qWarning( "ScQtFileDlg::slotFileTextChanged( const QString & ): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotFileTextChanged( const QString & ): Not implemented yet!" << oendl;
}
void ScQtFileDlg::slotMkDir()
{
- qWarning( "ScQtFileDlg::slotMkDir(): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotMkDir(): Not implemented yet!" << oendl;
}
void ScQtFileDlg::slotOK()
{
- qWarning( "ScQtFileDlg::slotOK(): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotOK(): Not implemented yet!" << oendl;
}
void ScQtFileDlg::slotSelectionChanged(QListViewItem *)
{
- qWarning( "ScQtFileDlg::slotSelectionChanged(QListViewItem *): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotSelectionChanged(QListViewItem *): Not implemented yet!" << oendl;
}
void ScQtFileDlg::slotTypeComboBoxChanged( int )
{
- qWarning( "ScQtFileDlg::slotTypeComboBoxChanged( int ): Not implemented yet!" );
+ owarn << "ScQtFileDlg::slotTypeComboBoxChanged( int ): Not implemented yet!" << oendl;
}
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 3df55eb..bf8f7f4 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -1,138 +1,137 @@
/****************************************************************************
**
** 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>
-
+#include <opie2/odebug.h>
+using namespace Opie::Core;
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[] = {
@@ -1976,436 +1975,434 @@ bool ZSafe::openDocument(const char* _filename, const char* )
Category *c1 = new Category();
c1->setCategoryName(category);
QString icon;
QString fullIconPath;
QPixmap *pix;
// #ifndef WIN32
icon = conf->readEntry(APP_KEY+category);
// #endif
bool isIconAv = false;
if (!icon.isEmpty() && !icon.isNull())
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
if (pix)
{
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIconName (icon);
c1->setIcon (*pix);
isIconAv = true;
}
}
if (!isIconAv)
{
c1->setIcon (*getPredefinedIcon(category));
}
c1->setListItem (catI);
c1->initListItem();
categories.insert (c1->getCategoryName(), c1);
numberOfEntries++;
}
for (int count = 0; count < FIELD_SIZE; count++) {
free(entry[count]);
}
retval = loadEntry(entry);
if (retval == 2) {
// m_parent->slotStatusHelpMsg("Last entry loaded");
}
} // end while
if (numberOfEntries == 0)
{
switch( QMessageBox::warning( this, tr("ZSafe"),
tr("Empty document or\nwrong password.\nContinue?"),
tr("&No"), tr("&Yes."),
0
) ) {
case 0: // No
retval = loadFinalize();
exitZs (1);
break;
case 1: // Yes
break;
}
}
retval = loadFinalize();
return true;
}
int ZSafe::loadInit(const char* _filename, const char *password)
{
unsigned int j = 0;
unsigned int keylength=0;
int count=0, count2=0, count3=0;
unsigned char charbuf[8];
unsigned short ciphertext[4];
char key[128];
Krc2* krc2 = new Krc2();
fd = fopen (_filename, "rb");
QFileInfo f (_filename);
load_buffer_length = f.size();
load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2;
if (fd == NULL)
return PWERR_OPEN;
buffer = (char *)malloc(load_buffer_length);
for (j = 0; password[j] != '\0'; j++) {
key[j] = password[j];
}
keylength = j;
krc2->rc2_expandkey (key, keylength, 128);
#ifndef WIN32
size = read(fileno (fd), (unsigned char *) (charbuf + count), 8);
#else
- printf ("LoadInit() read1");
size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
#endif
if (size < 8)
return PWERR_DATA;
for (count = 0; count < 4; count++) {
count2 = count << 1;
iv[count] = charbuf[count2] << 8;
iv[count] += charbuf[count2 + 1];
}
size = 0;
bufferIndex = 0;
#ifndef WIN32
while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) {
while (count < 8) {
count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8);
#else
- printf ("LoadInit() read2");
while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) {
while (count < 8) {
count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd);
#endif
if (count2 == 0) {
return PWERR_DATA;
}
count += count2;
} /* while (count < 8) */
size += 8;
for (count2 = 0; count2 < 8; count2 += 2) {
count3 = count2 >> 1;
ciphertext[count3] = charbuf[count2] << 8;
ciphertext[count3] += charbuf[count2 + 1];
plaintext[count3] = ciphertext[count3] ^ iv[count3];
iv[count3] = plaintext[count3];
} /* for (count2) */
krc2->rc2_decrypt (plaintext);
memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8);
bufferIndex += 8;
buffer[bufferIndex + 1] = '\0';
} /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */
size -= buffer[size - 1];
lastcount = 0;
/* This will point to the starting index */
bufferIndex = 0;
return PWERR_GOOD;
}
int ZSafe::loadEntry(char *entry[FIELD_SIZE])
{
/* Strip off PKCS 5 padding
* Should check to make sure it's good here
*/
int count, count1=0;
for (count = lastcount; count < size; count++) {
if ((unsigned char) (buffer[count]) == 255) {
if (buffer[bufferIndex] == '\0') {
bufferIndex++;
}
entry[count1] = (char *) malloc (count - bufferIndex + 1);
memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex);
entry[count1][count - bufferIndex] = '\0';
count++;
bufferIndex = count;
count1++;
if (count1 == FIELD_SIZE) {
lastcount = count;
return 1;
}
} /* if ((unsigned char) (buffer[count]) == 255) */
} /* for (count = 0; count < size; count++) */
return 2;
}
int ZSafe::loadFinalize(void)
{
fclose (fd);
if (buffer) free(buffer);
return PWERR_GOOD;
}
bool ZSafe::saveDocument(const char* _filename,
bool withPwd,
const char* )
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return false;
}
// if (m_password.isEmpty())
// withPwd = true; // the document must be saved with a valid password
if (withPwd)
{
bool pwdOk = FALSE;
while (!pwdOk)
{
getDocPassword(tr("Enter Password"));
if (m_password.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("Password is empty.\nPlease enter again."));
continue;
}
QString firstPasswd = m_password;
getDocPassword(tr("Reenter Password"));
if (m_password.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("Password is empty.\nPlease enter again."));
continue;
}
if (firstPasswd != m_password)
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("Passwords must be identical.\nPlease enter again."));
continue;
}
pwdOk = TRUE;
modified = false;
}
}
else if (modified)
{
QString fns(_filename);
fns = fns.right (fns.length() - fns.findRev ('/') - 1);
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to save ") + fns + tr("\nbefore continuing?"),
tr("&Save"),
tr("&Don't Save"),
0 // Enter == button 0
) )
{ // Escape == button 2
case 0: // Save clicked, Alt-S or Enter pressed.
modified = false;
break;
case 1: // Don't Save clicked or Alt-D pressed
modified = false;
return true;
}
}
modified = false;
if (m_password.isEmpty())
return false;
int retval = saveInit(_filename, m_password);
// int retval = saveInit(_filename, "test");
if (retval != PWERR_GOOD) {
return false;
}
char* entry[FIELD_SIZE];
// save the validation entry
{
int i=0;
entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
strcpy(entry[i++], "ZSAFECATEGORY");
entry[i] = (char*)malloc(strlen("name")+1);
strcpy(entry[i++], "name");
entry[i] = (char*)malloc(strlen("username")+1);
strcpy(entry[i++], "username");
entry[i] = (char*)malloc(strlen("password")+1);
strcpy(entry[i++], "password");
entry[i] = (char*)malloc(strlen("comment")+1);
strcpy(entry[i++], "comment");
entry[i] = (char*)malloc(strlen("field5")+1);
strcpy(entry[i++], "field5");
entry[i] = (char*)malloc(strlen("field6")+1);
strcpy(entry[i++], "field6");
retval = saveEntry(entry);
for (int z=0; z<i; z++) free(entry[z]);
if (retval == PWERR_DATA) {
- qWarning("1: Error writing file, contents not saved");
+ owarn << "1: Error writing file, contents not saved" << oendl;
saveFinalize();
return false;
}
// #ifndef WIN32
conf->writeEntry(APP_KEY+"valzsafe", 1);
// #endif
saveConf();
}
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL;
si = si->nextSibling())
{
int j=0;
entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1);
strcpy(entry[j++], i->text(0).utf8());
entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1);
strcpy(entry[j++], si->text(0).utf8());
entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1);
strcpy(entry[j++], si->text(1).utf8());
entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1);
strcpy(entry[j++], si->text(2).utf8());
entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1);
strcpy(entry[j++], si->text(3).utf8());
entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1);
strcpy(entry[j++], si->text(4).utf8());
entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1);
strcpy(entry[j++], si->text(5).utf8());
retval = saveEntry(entry);
for (int z=0; z<j; z++)
{
free(entry[z]);
}
if (retval == PWERR_DATA) {
- qWarning("1: Error writing file, contents not saved");
+ owarn << "1: Error writing file, contents not saved" << oendl;
saveFinalize();
return false;
}
}
}
if (saveFinalize() == PWERR_DATA) {
- qWarning("2: Error writing file, contents not saved");
+ owarn << "2: Error writing file, contents not saved" << oendl;
return false;
} else {
#ifndef DESKTOP
Global::statusMessage (tr("Password file saved."));
#endif
modified = false;
return true;
}
}
PasswordForm *newPwdDialog;
bool newPwdDialogResult = false;
void ZSafe::setPasswordDialogDone()
{
newPwdDialogResult = true;
newPwdDialog->close();
}
void ZSafe::getDocPassword(QString title)
{
qWarning ("getDocPassword");
// open the 'Password' dialog
PasswordForm *dialog = new PasswordForm(this, title, TRUE);
newPwdDialog = dialog;
newPwdDialogResult = false;
connect( dialog->PasswordField, SIGNAL( returnPressed() ),
this, SLOT( setPasswordDialogDone() ) );
// CS: !!!
// int pos = filename.findRev ('/');
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
#ifdef WIN32
dialog->setCaption("Qt " + ti);
#else
dialog->setCaption(ti);
#endif
// dialog->setCaption(title);
dialog->PasswordField->setFocus();
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString password;
if (result == Accepted || newPwdDialogResult)
{
m_password = dialog->PasswordField->text();
}
else
{
exitZs (1);
}
}
int ZSafe::saveInit(const char *_filename, const char *password)
{
char key[128];
unsigned int j = 0;
unsigned int keylength;
// int val;
int count2;
Krc2* krc2 = new Krc2();
/* first we should check the permissions of the filename */
/*
if (QFile::exists(_filename)) {
val = checkFile(_filename);
if (val != PWERR_GOOD)
return val;
} else
{
val = creat (_filename, (S_IRUSR | S_IWUSR));
if (val == -1)
return PWERR_OPEN;
else
close(val);
}
*/
QFileInfo f (_filename);
save_buffer_length = f.size();
save_buffer_length = ((save_buffer_length / 1024)+1) * 1024;
fd = fopen (_filename, "wb");
if (fd == NULL)
return PWERR_OPEN;
buffer = (char*)malloc(save_buffer_length);
/* make the key ready */
for (j = 0; password[j] != '\0'; j++) {
key[j] = password[j];
}
keylength = j;
krc2->rc2_expandkey (key, keylength, 128);
@@ -3097,193 +3094,193 @@ void ZSafe::editCategory()
dialog->IconField->setCurrentItem(0);
}
dialog->IconField->insertItem("predefined");
while ( (fi=it.current()) ) { // for each file...
QString fileName = fi->fileName();
if(fileName.right(4) == ".png")
{
fileName = fileName.mid(0,fileName.length()-4);
#ifdef DESKTOP
QPixmap imageOfFile;
imageOfFile.load(iconPath + fi->fileName());
#else
QPixmap imageOfFile(Resource::loadPixmap(fileName));
#endif
QImage foo = imageOfFile.convertToImage();
foo = foo.smoothScale(16,16);
imageOfFile.convertFromImage(foo);
dialog->IconField->insertItem(imageOfFile,fileName);
if(fileName+".png"==icon)
dialog->IconField->setCurrentItem(i+1);
++i;
}
++it;
}
waitDialog.hide();
}
else
{
#ifdef DESKTOP
// QDir d(QDir::homeDirPath() + "/pics/");
QDir d(iconPath);
#else
QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
d.setFilter( QDir::Files);
const QFileInfoList *list = d.entryInfoList();
int i=0;
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
}
else
{
while ( (fi=it.current()) )
{ // for each file...
QString fileName = fi->fileName();
if(fileName.right(4) == ".png")
{
fileName = fileName.mid(0,fileName.length()-4);
if(fileName+".png"==icon)
{
dialog->IconField->setCurrentItem(i+1);
break;
}
++i;
}
++it;
}
}
}
// dialog->show();
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString fullIconPath;
QPixmap *pix;
if (result == Accepted)
{
modified = true;
if (category != dialog->CategoryField->currentText())
{
categories.remove (category);
// #ifndef WIN32
conf->removeEntry(category);
// #endif
saveConf();
}
category = dialog->CategoryField->currentText();
icon = dialog->IconField->currentText()+".png";
if (cat)
{
- qWarning("Category found");
+ owarn << "Category found" << oendl;
// if (!icon.isEmpty() && !icon.isNull())
if (icon != "predefined.png")
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
if (pix)
{
// save the full pixmap name into the config file
// #ifndef WIN32
conf->writeEntry(APP_KEY+category, icon);
// #endif
saveConf();
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
cat->setIconName (icon);
cat->setIcon (*pix);
}
}
else
{
// #ifndef WIN32
conf->removeEntry (category);
// #endif
saveConf();
cat->setIcon (*getPredefinedIcon(category));
}
// change the category name of the selected category
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
qWarning (category);
catItem->setText( 0, tr( category ) );
cat->setCategoryName (tr(category));
cat->initListItem();
categories.insert (category, cat);
}
}
saveCategoryDialogFields(dialog);
}
else
{
// delete dialog;
dialog->hide();
return;
}
}
}
void ZSafe::cutItem()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
IsCut = true;
copiedItem = selectedItem;
}
}
void ZSafe::copyItem()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
IsCopy = true;
copiedItem = selectedItem;
}
}
// paste item into category
void ZSafe::pasteItem()
{
if (!selectedItem)
return;
if (isCategory(selectedItem))
{
modified = true;
if (IsCut)
{
if (copiedItem)
{
// add the new item
QListViewItem *i = new ShadedListItem (0, selectedItem);
// i->setOpen (TRUE);
i->setText (0, copiedItem->text(0));
i->setText (1, copiedItem->text(1));
i->setText (2, copiedItem->text(2));
i->setText (3, copiedItem->text(3));
i->setText (4, copiedItem->text(4));
i->setText (5, copiedItem->text(5));
diff --git a/noncore/apps/zsafe/zsafe.pro b/noncore/apps/zsafe/zsafe.pro
index 72c8fe9..3cae706 100644
--- a/noncore/apps/zsafe/zsafe.pro
+++ b/noncore/apps/zsafe/zsafe.pro
@@ -1,17 +1,17 @@
-TEMPLATE = app
-CONFIG = qt warn_on
+TEMPLATE = app
+CONFIG = qt warn_on
DESTDIR = $(OPIEDIR)/bin
HEADERS = zsafe.h krc2.h category.h categorylist.h zlistview.h \
scqtfiledlg.h
SOURCES = main.cpp zsafe.cpp krc2.cpp category.cpp \
categorylist.cpp zlistview.cpp shadedlistitem.cpp\
scqtfileedit.cpp scqtfileedit.moc.cpp \
scqtfiledlg.cpp
-INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
-LIBS += -Wl,-rpath,$(OPIEDIR)/lib -L$(OPIEDIR)/lib -lqpe -lopiecore2 -lopieui2
-TARGET = zsafe
+INTERFACES = newdialog.ui searchdialog.ui passworddialog.ui categorydialog.ui infoform.ui wait.ui
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopiecore2 -lopieui2
+TARGET = zsafe
include ( $(OPIEDIR)/include.pro )