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.cpp4
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp28
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp10
-rw-r--r--noncore/apps/advancedfm/output.cpp18
-rw-r--r--noncore/apps/checkbook/checkbook.cpp18
-rw-r--r--noncore/apps/checkbook/listedit.cpp6
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp2
-rw-r--r--noncore/apps/checkbook/password.cpp2
-rw-r--r--noncore/apps/checkbook/transaction.cpp14
-rw-r--r--noncore/apps/confedit/mainwindow.cpp4
-rw-r--r--noncore/apps/odict/odict.cpp2
-rw-r--r--noncore/apps/opie-bartender/bartender.cpp6
-rw-r--r--noncore/apps/opie-bartender/searchresults.cpp2
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp4
-rw-r--r--noncore/apps/opie-console/dialdialog.cpp2
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp8
-rw-r--r--noncore/apps/opie-console/emulation_layer.cpp24
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp10
-rw-r--r--noncore/apps/opie-console/io_bt.cpp4
-rw-r--r--noncore/apps/opie-console/io_irda.cpp4
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp8
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp6
-rw-r--r--noncore/apps/opie-console/session.cpp4
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp18
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp2
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp12
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp24
-rw-r--r--noncore/apps/opie-reader/fileBrowser.cpp8
-rw-r--r--noncore/apps/opie-sheet/mainwindow.cpp12
-rw-r--r--noncore/apps/opie-sheet/sheet.cpp4
-rw-r--r--noncore/apps/opie-write/mainwindow.cpp24
-rw-r--r--noncore/apps/opie-write/qtextedit.cpp4
-rwxr-xr-xnoncore/apps/qashmoney/accountdisplay.cpp22
-rwxr-xr-xnoncore/apps/qashmoney/budgetdisplay.cpp20
-rwxr-xr-xnoncore/apps/qashmoney/calculator.cpp24
-rwxr-xr-xnoncore/apps/qashmoney/datepicker.cpp6
-rwxr-xr-xnoncore/apps/qashmoney/memorydialog.cpp6
-rwxr-xr-xnoncore/apps/qashmoney/newaccount.cpp8
-rwxr-xr-xnoncore/apps/qashmoney/newtransaction.cpp8
-rwxr-xr-xnoncore/apps/qashmoney/preferencedialogs.cpp20
-rwxr-xr-xnoncore/apps/qashmoney/qashmoney.cpp20
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp18
-rwxr-xr-xnoncore/apps/qashmoney/transferdialog.cpp2
-rw-r--r--noncore/apps/tableviewer/tableviewer.cpp8
-rw-r--r--noncore/apps/tableviewer/ui/commonwidgets.cpp2
-rw-r--r--noncore/apps/tableviewer/ui/tvbrowseview.cpp4
-rw-r--r--noncore/apps/tableviewer/ui/tvfilterview.cpp2
-rw-r--r--noncore/apps/tableviewer/ui/tvlistview.cpp4
-rw-r--r--noncore/apps/tinykate/libkate/document/katedialogs.cpp6
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp2
-rw-r--r--noncore/apps/tinykate/libkate/view/kateviewdialog.cpp6
-rw-r--r--noncore/apps/tinykate/tinykate.cpp2
-rw-r--r--noncore/apps/zsafe/scqtfiledlg.cpp12
-rw-r--r--noncore/apps/zsafe/zsafe.cpp20
54 files changed, 260 insertions, 260 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index c44d387..2ba3dca 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,149 +1,149 @@
/***************************************************************************
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>
#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&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
}
AdvancedFm::~AdvancedFm() {
}
void AdvancedFm::cleanUp() {
QString sfile=QDir::homeDirPath();
if(sfile.right(1) != "/")
sfile+="/._temp";
else
sfile+="._temp";
QFile file( sfile);
if(file.exists())
file.remove();
}
void AdvancedFm::tabChanged(QWidget *) {
// qWarning("tab changed");
QString path = CurrentDir()->canonicalPath();
currentPathCombo->lineEdit()->setText( path );
if(whichTab == 1) {
viewMenu->setItemChecked(viewMenu->idAt(0), true);
viewMenu->setItemChecked(viewMenu->idAt(1), false);
} else {
viewMenu->setItemChecked(viewMenu->idAt(0), false);
viewMenu->setItemChecked(viewMenu->idAt(1), true);
}
QString fs= getFileSystemType( (const QString &) path);
setCaption(tr("AdvancedFm :: ")+fs+" :: "
+checkDiskSpace( (const QString &) path )+ tr(" kB free") );
chdir( path.latin1());
}
void AdvancedFm::populateView() {
// qWarning("PopulateView");
QPixmap pm;
QListView *thisView = CurrentView();
QDir *thisDir = CurrentDir();
QString path = thisDir->canonicalPath();
//qWarning("path is "+path);
thisView->clear();
thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
thisDir->setMatchAllDirs(TRUE);
thisDir->setNameFilter(filterStr);
QString fileL, fileS, fileDate;
QString fs= getFileSystemType((const QString &) path);
setCaption(tr("AdvancedFm :: ")+fs+" :: "
+checkDiskSpace((const QString &) path)+ tr(" kB free") );
bool isDir=FALSE;
const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ) {
QString symLink=fi->readLink();
QFileInfo sym( symLink);
fileS.sprintf( "%10i", sym.size() );
fileL = fi->fileName() +" -> " + sym.filePath().data();
fileDate = sym.lastModified().toString();
} else {
fileS.sprintf( "%10i", fi->size() );
fileL = fi->fileName();
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
// if(fileL == "..")
fileL += "/";
isDir=TRUE;
}
}
QFileInfo fileInfo( path + "/" + fileL);
if(fileL !="./" && fi->exists()) {
item = new QListViewItem( thisView, fileL, fileS , fileDate);
if(isDir || fileL.find("/",0,TRUE) != -1) {
if( !QDir( fi->filePath() ).isReadable()) //is directory
pm = Resource::loadPixmap( "lockedfolder" );
else
pm= Resource::loadPixmap( "folder" );
}
else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
pm = Resource::loadPixmap( "exec");
}
else if( (fileInfo.permission( QFileInfo::ExeUser)
| fileInfo.permission( QFileInfo::ExeGroup)
| fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
pm = Resource::loadPixmap( "exec");
}
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index 763ae34..f791c77 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -160,127 +160,127 @@ void AdvancedFm::init() {
// TabWidget->insertTab( tab, tr("1"));
tab_2 = new QWidget( TabWidget, "tab_2" );
tabLayout_2 = new QGridLayout( tab_2 );
tabLayout_2->setSpacing( 2);
tabLayout_2->setMargin( 2);
Remote_View = new QListView( tab_2, "Remote_View" );
Remote_View->addColumn( tr("File"),130);
Remote_View->addColumn( tr("Size"),-1);
Remote_View->setColumnAlignment(1,QListView::AlignRight);
Remote_View->addColumn( tr("Date"),-1);
Remote_View->setColumnAlignment(2,QListView::AlignRight);
Remote_View->setAllColumnsShowFocus(TRUE);
Remote_View->setMultiSelection( TRUE );
Remote_View->setSelectionMode(QListView::Extended);
Remote_View->setFocusPolicy(StrongFocus);
Remote_View->installEventFilter( this );
QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
tabLayout_2->addWidget( Remote_View, 0, 0 );
TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
TabWidget->setSizeChange( 370 );
// TabWidget->insertTab( tab_2, tr( "2"));
/* tab_3 = new QWidget( TabWidget, "tab_3" );
tabLayout_3 = new QGridLayout( tab_3 );
tabLayout_3->setSpacing( 2);
tabLayout_3->setMargin( 2);
// OFileDialog fileDialog;
// fileDialog;
// fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
// fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
// OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
QListView *fileTree;
fileTree = new QListView( tab_3, "tree" );
tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
TabWidget->insertTab( tab_3, tr( "Remote" ) );
*/
///////////////
if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
zaurusDevice=TRUE;
else
zaurusDevice=FALSE;
if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
qDebug("not have sd");
sdButton->hide();
}
if( !StorageInfo::hasCf() ) {
qDebug("not have cf");
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="*";
b=FALSE;
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, 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( 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( 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( 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 *)),
+ 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( 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 9ad1146..9e740d0 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -588,218 +588,218 @@ void AdvancedFm::runCommand() {
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 * )));
+ connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
file->send( curFilePath, curFile );
}
}
}
}
void AdvancedFm::fileBeamFinished( Ir *) {
QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
}
void AdvancedFm::selectAll() {
QListView *thisView = CurrentView();
thisView->selectAll(true);
thisView->setSelected( thisView->firstChild(),false);
}
void AdvancedFm::startProcess(const QString & cmd) {
QStringList command;
OProcess *process;
process = new OProcess();
- connect(process, SIGNAL(processExited(OProcess *)),
- this, SLOT( processEnded(OProcess *)));
+ connect(process, SIGNAL(processExited(OProcess*)),
+ this, SLOT( processEnded(OProcess*)));
- connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
- this, SLOT( oprocessStderr(OProcess *, char *, int)));
+ connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)),
+ this, SLOT( oprocessStderr(OProcess*,char*,int)));
command << "/bin/sh";
command << "-c";
command << cmd.latin1();
*process << command;
if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
qDebug("could not start process");
}
void AdvancedFm::processEnded(OProcess *) {
rePopulate();
}
void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
// qWarning("received stderrt %d bytes", buflen);
QString lineStr = buffer;
QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
}
bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
if ( o->inherits( "QLineEdit" ) ) {
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent*)e;
if ( ke->key() == Key_Return ||
ke->key() == Key_Enter ) {
okRename();
return true;
}
else if ( ke->key() == Key_Escape ) {
cancelRename();
return true;
}
}
else if ( e->type() == QEvent::FocusOut ) {
cancelRename();
return true;
}
}
if ( o->inherits( "QListView" ) ) {
if ( e->type() == QEvent::FocusIn ) {
if( o == Local_View) { //keep track of which view
whichTab=1;
}
else {
whichTab=2;
}
}
OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
}
return QWidget::eventFilter( o, e );
}
void AdvancedFm::cancelRename() {
// qDebug("cancel rename");
QListView * view;
view = CurrentView();
bool resetFocus = view->viewport()->focusProxy() == renameBox;
delete renameBox;
renameBox = 0;
if ( resetFocus ) {
view->viewport()->setFocusProxy( view);
view->setFocus();
}
}
void AdvancedFm::doRename(QListView * view) {
if( !CurrentView()->currentItem()) return;
QRect r = view->itemRect( view->currentItem( ));
r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
r.setX( view->contentsX() );
if ( r.width() > view->visibleWidth() )
r.setWidth( view->visibleWidth() );
renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
renameBox->setFrame(true);
renameBox->setText( view->currentItem()->text(0) );
renameBox->selectAll();
renameBox->installEventFilter( this );
view->addChild( renameBox, r.x(), r.y() );
renameBox->resize( r.size() );
view->viewport()->setFocusProxy( renameBox );
renameBox->setFocus();
renameBox->show();
}
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 7dc2416..0bba1d8 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -48,229 +48,229 @@ static char * filesave_xpm[] = {
"} c #777777",
"| c #616161",
"1 c #3A3A3A",
"2 c #BEBEBE",
"3 c #2C2C2C",
"4 c #7C7C7C",
"5 c #F6F6F6",
"6 c #FCFCFC",
"7 c #6B6B6B",
"8 c #959595",
"9 c #4F4F4F",
"0 c #808080",
"a c #767676",
"b c #818181",
"c c #B8B8B8",
"d c #FBFBFB",
"e c #F9F9F9",
"f c #CCCCCC",
"g c #030303",
"h c #737373",
"i c #7A7A7A",
"j c #7E7E7E",
"k c #6A6A6A",
"l c #FAFAFA",
"m c #505050",
"n c #9D9D9D",
"o c #333333",
"p c #7B7B7B",
"q c #787878",
"r c #696969",
"s c #494949",
"t c #555555",
"u c #949494",
"v c #E6E6E6",
"w c #424242",
"x c #515151",
"y c #535353",
"z c #3E3E3E",
"A c #D4D4D4",
"B c #0C0C0C",
"C c #353535",
"D c #474747",
"E c #ECECEC",
"F c #919191",
"G c #7D7D7D",
"H c #000000",
"I c #404040",
"J c #858585",
"K c #323232",
"L c #D0D0D0",
"M c #1C1C1C",
" ...+ ",
" @#$%&..+ ",
" .*=-;;>,..+ ",
" ')!~;;;;;;{]..",
" ^/(-;;;;;;;_:<",
" [}|;;;;;;;{12$",
" #34-55;;;;678$+",
" 90ab=c;dd;e1fg ",
" [ahij((kbl0mn$ ",
" op^q^^7r&]s/$+ ",
"@btu;vbwxy]zAB ",
"CzDEvEv;;DssF$ ",
"G.H{E{E{IxsJ$+ ",
" +...vEKxzLM ",
" +...z]n$ ",
" +... "};
Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
: QDialog( parent, name, modal, fl )
{
QStringList cmmds;
// cmmds=QStringList::split( " ", commands, false);
cmmds=commands;
// qDebug("count %d", cmmds.count());
if ( !name )
setName( tr("Output"));
resize( 196, 269 );
setCaption( name );
OutputLayout = new QGridLayout( this );
OutputLayout->setSpacing( 2);
OutputLayout->setMargin( 2);
QPushButton *docButton;
docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
docButton->setFixedSize( QSize( 20, 20 ) );
connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
// docButton->setFlat(TRUE);
OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
proc = new OProcess();
- connect(proc, SIGNAL(processExited(OProcess *)),
+ connect(proc, SIGNAL(processExited(OProcess*)),
this, SLOT( processFinished()));
- connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
- this, SLOT(commandStdout(OProcess *, char *, int)));
+ connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)),
+ this, SLOT(commandStdout(OProcess*,char*,int)));
- connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
- this, SLOT(commandStderr(OProcess *, char *, int)));
+ connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)),
+ this, SLOT(commandStderr(OProcess*,char*,int)));
-// connect( , SIGNAL(received(const QByteArray &)),
-// this, SLOT(commandStdin(const QByteArray &)));
+// connect( , SIGNAL(received(const QByteArray&)),
+// this, SLOT(commandStdin(const QByteArray&)));
// * proc << commands.latin1();
for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
qDebug( "%s", (*it).latin1() );
* proc << (*it).latin1();
}
if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
OutputEdit->append(tr("Process could not start") );
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
perror("Error: ");
QString errorMsg=tr("Error\n")+(QString)strerror(errno);
OutputEdit->append( errorMsg);
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
}
}
Output::~Output() {
}
void Output::saveOutput() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = QPEApplication::documentDir();
if(filename.right(1).find('/') == -1)
filename+="/";
QString name = fileDlg->LineEdit1->text();
filename+="text/plain/"+name;
qDebug(filename);
QFile f(filename);
f.open( IO_WriteOnly);
if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
DocLnk lnk;
lnk.setName(name); //sets file name
lnk.setFile(filename); //sets File property
lnk.setType("text/plain");
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
} else
qWarning("Could not write file");
f.close();
}
}
void Output::commandStdout(OProcess*, char *buffer, int buflen) {
qWarning("received stdout %d bytes", buflen);
// QByteArray data(buflen);
// data.fill(*buffer, buflen);
// for (uint i = 0; i < data.count(); i++ ) {
// printf("%c", buffer[i] );
// }
// printf("\n");
QString lineStr = buffer;
lineStr=lineStr.left(lineStr.length()-1);
OutputEdit->append(lineStr);
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
}
void Output::commandStdin( const QByteArray &data) {
qWarning("received stdin %d bytes", data.size());
// recieved data from the io layer goes to sz
proc->writeStdin(data.data(), data.size());
}
void Output::commandStderr(OProcess*, char *buffer, int buflen) {
qWarning("received stderrt %d bytes", buflen);
QString lineStr = buffer;
// lineStr=lineStr.left(lineStr.length()-1);
OutputEdit->append(lineStr);
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
}
void Output::processFinished() {
delete proc;
OutputEdit->append( tr("\nFinished\n") );
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
// close();
-// disconnect( layer(), SIGNAL(received(const QByteArray &)),
-// this, SLOT(commandStdin(const QByteArray &)));
+// 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.cpp b/noncore/apps/checkbook/checkbook.cpp
index 26b2533..1b933f2 100644
--- a/noncore/apps/checkbook/checkbook.cpp
+++ b/noncore/apps/checkbook/checkbook.cpp
@@ -1,340 +1,340 @@
/*
                This file is part of the OPIE Project
=.
             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This file is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "checkbook.h"
#include "cbinfo.h"
#include "transaction.h"
#include "traninfo.h"
#include "graph.h"
#include "graphinfo.h"
#include "password.h"
#include "cfg.h"
#include <qpe/qpeapplication.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include <qwhatsthis.h>
#include <qpopupmenu.h>
#define COL_ID 0
#define COL_SORTDATE 1
#define COL_NUM 2
#define COL_DATE 3
#define COL_DESC 4
#define COL_AMOUNT 5
#define COL_BAL 6
// --- Checkbook --------------------------------------------------------------
Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg )
: QDialog( parent, 0, TRUE, WStyle_ContextHelp )
{
info = i;
_pCfg=cfg;
// Title bar
if ( info->name() != "" )
{
QString tempstr = info->name();
tempstr.append( " - " );
tempstr.append( tr( "Checkbook" ) );
setCaption( tempstr );
}
else
{
setCaption( tr( "New checkbook" ) );
}
// Setup layout to make everything pretty
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Setup tabs for all info
mainWidget = new OTabWidget( this );
layout->addWidget( mainWidget );
mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) );
mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) );
mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) );
if( _pCfg->isShowLastTab() )
mainWidget->setCurrentTab( info->getLastTab() );
else
mainWidget->setCurrentTab( tr( "Info" ) );
- connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) );
+ connect( mainWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotTab(QWidget*) ) );
// Load checkbook information
loadCheckbook();
}
Checkbook::~Checkbook()
{
}
// --- initInfo ---------------------------------------------------------------
QWidget *Checkbook::initInfo()
{
QWidget *control = new QWidget( mainWidget, tr("Info") );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
// Password protection
passwordCB = new QCheckBox( tr( "Password protect" ), container );
QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) );
connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) );
layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 );
// Account name
QLabel *label = new QLabel( tr( "Name:" ), container );
QWhatsThis::add( label, tr( "Enter name of checkbook here." ) );
layout->addWidget( label, 1, 0 );
nameEdit = new QLineEdit( container );
QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) );
- connect( nameEdit, SIGNAL( textChanged( const QString & ) ),
- this, SLOT( slotNameChanged( const QString & ) ) );
+ connect( nameEdit, SIGNAL( textChanged(const QString&) ),
+ this, SLOT( slotNameChanged(const QString&) ) );
layout->addWidget( nameEdit, 1, 1 );
// Type of account
label = new QLabel( tr( "Type:" ), container );
QWhatsThis::add( label, tr( "Select type of checkbook here." ) );
layout->addWidget( label, 2, 0 );
typeList = new QComboBox( container );
QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) );
typeList->insertStringList( _pCfg->getAccountTypes() );
layout->addWidget( typeList, 2, 1 );
// Bank/institution name
label = new QLabel( tr( "Bank:" ), container );
QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) );
layout->addWidget( label, 3, 0 );
bankEdit = new QLineEdit( container );
QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) );
layout->addWidget( bankEdit, 3, 1 );
// Account number
label = new QLabel( tr( "Account number:" ), container );
QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) );
layout->addWidget( label, 4, 0 );
acctNumEdit = new QLineEdit( container );
QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) );
layout->addWidget( acctNumEdit, 4, 1 );
// PIN number
label = new QLabel( tr( "PIN number:" ), container );
QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) );
layout->addWidget( label, 5, 0 );
pinNumEdit = new QLineEdit( container );
QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) );
layout->addWidget( pinNumEdit, 5, 1 );
// Starting balance
label = new QLabel( tr( "Starting balance:" ), container );
QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) );
layout->addWidget( label, 6, 0 );
balanceEdit = new QLineEdit( container );
QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) );
- connect( balanceEdit, SIGNAL( textChanged( const QString & ) ),
- this, SLOT( slotStartingBalanceChanged( const QString & ) ) );
+ connect( balanceEdit, SIGNAL( textChanged(const QString&) ),
+ this, SLOT( slotStartingBalanceChanged(const QString&) ) );
layout->addWidget( balanceEdit, 6, 1 );
// Notes
label = new QLabel( tr( "Notes:" ), container );
QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) );
layout->addWidget( label, 7, 0 );
notesEdit = new QMultiLineEdit( container );
QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) );
notesEdit->setMinimumHeight( 25 );
notesEdit->setMaximumHeight( 65 );
layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 );
return control;
}
// --- initTransactions -------------------------------------------------------
QWidget *Checkbook::initTransactions()
{
QWidget *control = new QWidget( mainWidget, tr("Transactions") );
QGridLayout *layout = new QGridLayout( control );
layout->setSpacing( 2 );
layout->setMargin( 4 );
// Sort selector
QLabel *label = new QLabel( tr( "Sort by:" ), control );
QWhatsThis::add( label, tr( "Select checkbook sorting here." ) );
layout->addMultiCellWidget( label, 0, 0, 0, 1 );
_cbSortType=new QComboBox( control );
_cbSortType->insertItem( tr("Entry Order") );
_cbSortType->insertItem( tr("Date") );
_cbSortType->insertItem( tr("Number") );
layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 );
- connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) );
+ connect( _cbSortType, SIGNAL( activated(const QString&) ), this, SLOT( slotSortChanged(const QString&) ) );
// Table
tranTable = new QListView( control );
QFont fnt(QPEApplication::font());
fnt.setPointSize( fnt.pointSize()-1 );
tranTable->setFont( fnt );
QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) );
tranTable->addColumn( tr( "Id" ) );
tranTable->setColumnWidthMode( COL_ID, QListView::Manual );
tranTable->setColumnWidth( COL_ID, 0);
tranTable->addColumn( tr( "SortDate" ) );
tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual );
tranTable->setColumnWidth( COL_SORTDATE, 0);
tranTable->addColumn( tr( "Num" ) );
tranTable->addColumn( tr( "Date" ) );
//tranTable->addColumn( tr( "Cleared" ) );
tranTable->addColumn( tr( "Description" ) );
int column = tranTable->addColumn( tr( "Amount" ) );
tranTable->setColumnAlignment( column, Qt::AlignRight );
column=tranTable->addColumn( tr("Balance") );
tranTable->setColumnAlignment( column, Qt::AlignRight );
tranTable->setAllColumnsShowFocus( TRUE );
tranTable->setSorting( -1 );
layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 );
QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold );
- connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
- this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) );
- connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ),
+ connect( tranTable, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
+ this, SLOT( slotMenuTran(QListViewItem*,const QPoint&) ) );
+ connect( tranTable, SIGNAL( doubleClicked(QListViewItem*) ),
this, SLOT( slotEditTran() ) );
_sortCol=COL_ID;
// Buttons
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control );
QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) );
layout->addWidget( btn, 2, 0 );
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control );
QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) );
layout->addWidget( btn, 2, 1 );
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control );
QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) );
layout->addWidget( btn, 2, 2 );
return( control );
}
// --- initCharts -------------------------------------------------------------
QWidget *Checkbook::initCharts()
{
graphInfo = 0x0;
QWidget *control = new QWidget( mainWidget, tr("Charts") );
QGridLayout *layout = new QGridLayout( control );
layout->setSpacing( 2 );
layout->setMargin( 4 );
graphWidget = new Graph( control );
QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) );
layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 );
graphList = new QComboBox( control );
QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) );
graphList->insertItem( tr( "Account balance" ) );
graphList->insertItem( tr( "Withdrawals by category" ) );
graphList->insertItem( tr( "Deposits by category" ) );
layout->addMultiCellWidget( graphList, 1, 1, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control );
QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) );
layout->addWidget( btn, 1, 2 );
return control;
}
// --- loadCheckbook ----------------------------------------------------------
void Checkbook::loadCheckbook()
{
if ( !info )
{
return;
}
tranList = info->transactions();
passwordCB->setChecked( !info->password().isNull() );
nameEdit->setText( info->name() );
QString temptext = info->type();
int i = typeList->count();
while ( i > 0 )
{
i--;
typeList->setCurrentItem( i );
if ( typeList->currentText() == temptext )
{
break;
}
}
if( i<=0 ) {
typeList->insertItem( temptext, 0 );
typeList->setCurrentItem(0);
}
bankEdit->setText( info->bank() );
acctNumEdit->setText( info->account() );
pinNumEdit->setText( info->pin() );
temptext.setNum( info->startingBalance(), 'f', 2 );
balanceEdit->setText( temptext );
notesEdit->setText( info->notes() );
// Load transactions
float amount;
QString stramount;
for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() )
{
amount = tran->amount();
if ( tran->withdrawal() )
{
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp
index 37f05f0..d00e305 100644
--- a/noncore/apps/checkbook/listedit.cpp
+++ b/noncore/apps/checkbook/listedit.cpp
@@ -1,168 +1,168 @@
/*
                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"
#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 ) ) );
+ 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 &) ) );
+ 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 &) ) );
+ 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);
}
// --- fixTypes ----------------------------------------------------------------
// Makes sure all entries have a unique name and empty entries are replaced
// by a generic string. The first version performs the operation on a particular
// column, whereas the 2nd does it for all unique columns.
class ColMap {
public:
ColMap(QString sValue, QListViewItem *pEntry) {
_sValue=sValue;
_pEntry=pEntry;
}
QString &getValue() { return(_sValue); }
QListViewItem *getItem() { return(_pEntry); }
protected:
QString _sValue;
QListViewItem *_pEntry;
};
class ColList : public QList<QString>
{
public:
ColList() : QList<QString>() { }
protected:
int compareItems(QCollection::Item, QCollection::Item);
};
int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) {
return( ((QString *)i1)->compare(*(QString *)i2) );
}
void ListEdit::fixTypes(int iColumn)
{
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index d0fac3b..254ce6a 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -79,193 +79,193 @@ MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ )
connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
actionOpen->addTo( popup );
actionOpen->addTo( bar );
actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
0, this, 0 );
actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
actionDelete->addTo( popup );
actionDelete->addTo( bar );
popup->insertSeparator();
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this app." ) );
connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
a->addTo( popup );
a->addTo( bar );
mb->insertItem( tr( "Checkbook" ), popup );
// Load Checkbook selection list
checkbooks = new CBInfoList();
QDir checkdir( cbDir );
if (checkdir.exists() == true)
{
QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
QDir::Time );
CBInfo *cb = 0x0;
QString filename;
for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ )
{
filename = cbDir;
filename.append( (*it) );
cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename );
checkbooks->inSort( cb );
}
}
// Build Checkbook selection list control
cbList = 0x0;
buildList();
// open last book?
if( _cfg.isOpenLastBook() ) {
this->show();
this->showMaximized();
QListViewItem *itm=cbList->firstChild();
while( itm ) {
if( itm->text(posName)==_cfg.getLastBook() ) {
openBook( itm );
break;
}
itm=itm->nextSibling();
}
}
}
// --- ~MainWindow ------------------------------------------------------------
MainWindow::~MainWindow()
{
writeConfig();
}
// --- buildList --------------------------------------------------------------
void MainWindow::buildList()
{
if ( cbList )
delete cbList;
cbList = new QListView( this );
QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
if ( _cfg.getShowLocks() )
{
cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 );
posName = 1;
}
else
{
posName = 0;
}
cbList->addColumn( tr( "Checkbook Name" ) );
if ( _cfg.getShowBalances() )
{
int colnum = cbList->addColumn( tr( "Balance" ) );
cbList->setColumnAlignment( colnum, Qt::AlignRight );
}
cbList->setAllColumnsShowFocus( TRUE );
cbList->setSorting( posName );
QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
- connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
+ connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
this, SLOT( slotEdit() ) );
setCentralWidget( cbList );
for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() )
{
addCheckbook( cb );
}
}
void MainWindow::addCheckbook( CBInfo *cb )
{
QListViewItem *lvi = new QListViewItem( cbList );
if ( _cfg.getShowLocks() && !cb->password().isNull() )
{
lvi->setPixmap( 0, lockIcon );
}
lvi->setText( posName, cb->name() );
if ( _cfg.getShowBalances() )
{
QString balance;
balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() );
lvi->setText( posName + 1, balance );
}
}
void MainWindow::buildFilename( const QString &name )
{
tempFilename = cbDir;
tempFilename.append( name );
tempFilename.append( ".qcb" );
}
void MainWindow::slotNew()
{
CBInfo *cb = new CBInfo();
Checkbook *currcb = new Checkbook( this, cb, &_cfg );
if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
{
// Save new checkbook
buildFilename( cb->name() );
_cfg.setLastBook( cb->name() );
cb->setFilename( tempFilename );
cb->write();
// Add to listbox
checkbooks->inSort( cb );
addCheckbook( cb );
}
delete currcb;
}
// --- slotEdit ---------------------------------------------------------------
void MainWindow::slotEdit()
{
// get name and open it
QListViewItem *curritem = cbList->currentItem();
if ( !curritem )
return;
openBook( curritem );
}
// --- openBook ---------------------------------------------------------------
void MainWindow::openBook(QListViewItem *curritem)
{
// find book in List
QString currname=curritem->text(posName);
CBInfo *cb = checkbooks->first();
while ( cb ) {
if ( cb->name() == currname )
break;
cb = checkbooks->next();
}
if ( !cb ) return;
//
buildFilename( currname );
float currbalance = cb->balance();
bool currlock = !cb->password().isNull();
if ( currlock )
{
Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() )
{
delete pw;
return;
}
delete pw;
}
_cfg.setLastBook( currname );
Checkbook *currcb = new Checkbook( this, cb, &_cfg );
if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
{
diff --git a/noncore/apps/checkbook/password.cpp b/noncore/apps/checkbook/password.cpp
index f381271..89a6bc6 100644
--- a/noncore/apps/checkbook/password.cpp
+++ b/noncore/apps/checkbook/password.cpp
@@ -1,97 +1,97 @@
/*
                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 "password.h"
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>
static const char* const showhideimage_data[] = {
"16 16 2 1",
". c None",
"# c #000000",
"................",
"...#...###...##.",
"..#.#..#..#.##..",
"..###..###.##...",
".#...#.#..##....",
".#...#.#.##.....",
"........##.#..#.",
"..##...##...##..",
".#..#.###...##..",
".#...##..#.#..#.",
".#..##..........",
".#.##.#..#.#..#.",
"..##...##...##..",
".##....##...##..",
".#....#..#.#..#.",
"................"};
Password::Password( QWidget *parent, const char *caption, const char *prompt )
: QDialog( parent, 0x0, TRUE, 0x0 )
{
setCaption( caption );
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 2 );
layout->setMargin( 4 );
QLabel *label = new QLabel( prompt, this );
label->setAlignment( AlignLeft | AlignTop | WordBreak );
layout->addMultiCellWidget( label, 0, 0, 0, 1 );
pw = new QLineEdit( this );
pw->setEchoMode( QLineEdit::Password );
layout->addWidget( pw, 1, 0 );
QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data );
QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this );
btn->setMaximumSize( pic->width() + 10, pic->height() + 10 );
btn->setToggleButton( TRUE );
- connect( btn, SIGNAL( toggled( bool ) ), this, SLOT( slotTogglePassword( bool ) ) );
+ connect( btn, SIGNAL( toggled(bool) ), this, SLOT( slotTogglePassword(bool) ) );
layout->addWidget( btn, 1, 1 );
password == "";
}
Password::~Password()
{
}
void Password::accept()
{
password = pw->text();
QDialog::accept();
}
void Password::slotTogglePassword( bool showPW )
{
showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password );
}
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp
index a72a48b..1b08b24 100644
--- a/noncore/apps/checkbook/transaction.cpp
+++ b/noncore/apps/checkbook/transaction.cpp
@@ -6,267 +6,267 @@
 _;:,     .>    :=|. 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"
#include <qpe/datebookmonth.h>
#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 ) ) );
+ 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 &) ) );
+ 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." ) );
layout->addMultiCellWidget( catList, 3, 3, 1, 3 );
// Type
label = new QLabel( tr( "Type:" ), container );
QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) );
layout->addWidget( label, 4, 0 );
typeList = new QComboBox( container );
QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) );
layout->addMultiCellWidget( typeList, 4, 4, 1, 3 );
// Amount
label = new QLabel( tr( "Amount:" ), container );
QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) );
layout->addWidget( label, 5, 0 );
amtEdit = new QLineEdit( container );
QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) );
layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 );
// Fee
label = new QLabel( tr( "Fee:" ), container );
QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) );
layout->addWidget( label, 6, 0 );
feeEdit = new QLineEdit( container );
QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) );
layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 );
// Notes
label = new QLabel( tr( "Notes:" ), container );
QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) );
layout->addWidget( label, 7, 0 );
noteEdit = new QMultiLineEdit( container );
QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) );
layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 );
// init date
initFromInfo( info );
// not new handlers
connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) );
connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) );
- connect( catList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) );
- connect( typeList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) );
- connect( amtEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) );
- connect( feeEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) );
+ connect( catList, SIGNAL(activated(const QString&)), this, SLOT( slotNotNew() ) );
+ connect( typeList, SIGNAL(activated(const QString&)), this, SLOT( slotNotNew() ) );
+ connect( amtEdit, SIGNAL(textChanged(const QString&)), this, SLOT( slotNotNew() ) );
+ connect( feeEdit, SIGNAL(textChanged(const QString&)), this, SLOT( slotNotNew() ) );
connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) );
}
// --- initFromInfo -----------------------------------------------------------
void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld)
{
// Populate current values if provided
if ( info )
{
if ( info->withdrawal() )
{
withBtn->setChecked( TRUE );
slotWithdrawalClicked();
}
else
{
depBtn->setChecked( TRUE );
slotDepositClicked();
}
if( !bPopulateOld ) {
QDate dt = info->date();
slotDateChanged( dt.year(), dt.month(), dt.day() );
datePicker->setDate( dt );
numEdit->setText( info->number() );
}
QString temptext = info->category();
// set description field
int i;
for(i=_cbDesc->count()-1; i>=0; i--) {
if( _cbDesc->text(i)==info->desc() ) {
_cbDesc->setCurrentItem(i);
break;
}
}
if( i<=0 )
_cbDesc->setEditText( info->desc() );
i = catList->count();
while ( i > 0 )
{
i--;
catList->setCurrentItem( i );
if ( catList->currentText() == temptext )
{
break;
}
}
temptext = info->type();
i = typeList->count();
while ( i > 0 )
{
i--;
typeList->setCurrentItem( i );
if ( typeList->currentText() == temptext )
{
break;
}
}
amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) );
feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) );
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();
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index 5f7ad50..6ef1043 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -1,148 +1,148 @@
/***************************************************************************
* *
* 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 <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");
settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist");
settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
mainLayout->addWidget( settingList, 0);
qDebug("creating editor");
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( 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");
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);
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index d5c6d75..4c99964 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -113,103 +113,103 @@ void ODict::lookupLanguageNames( QString dictname )
Config cfg ( "odict" );
cfg.setGroup( "Method_"+dictname );
top_name_content = cfg.readEntry( "Lang1" );
bottom_name_content = cfg.readEntry( "Lang2" );
}
void ODict::saveConfig()
{
Config cfg ( "odict" );
cfg.setGroup( "generalsettings" );
cfg.writeEntry( "casesens" , casesens );
cfg.writeEntry( "lastdict" , query_co->currentText() );
}
void ODict::slotStartQuery()
{
QString querystring = query_le->text();
if ( !querystring.isEmpty() )
{
/*
* if the user has not yet defined a dictionary
*/
if ( !query_co->currentText() )
{
switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ),
tr( "No dictionary defined" ),
tr( "&Define one" ),
tr( "&Cancel" ),
0, // Define a dict
1 ) ) // Cancel choosen
{
case 0:
slotSettings();
break;
case 1: // stop here
return;
}
}
/*
* ok, the user has defined a dict
*/
ding->setCaseSensitive( casesens );
BroswerContent test = ding->setText( querystring );
browser_top->setText( test.top );
browser_bottom->setText( test.bottom );
}
}
void ODict::slotSettings()
{
ConfigDlg dlg( this, "Config" , true);
if ( dlg.exec() == QDialog::Accepted )
saveConfig();
}
void ODict::slotSetParameter( int count )
{
if ( count == 0 )
{
if ( casesens )
casesens = false;
else
casesens = true;
}
saveConfig();
}
void ODict::slotMethodChanged( const QString& methodnumber )
{
activated_name = methodnumber;
if ( activated_name != ding->loadedDict() )
{
ding->loadDict(activated_name);
lookupLanguageNames( activated_name );
top_name->setText( top_name_content );
bottom_name->setText( bottom_name_content );
}
}
void ODict::setupMenus()
{
menu = new QMenuBar( this );
settings = new QPopupMenu( menu );
setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
setting_a->addTo( settings );
setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 );
parameter = new QPopupMenu( menu );
- connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) );
+ connect( parameter, SIGNAL( activated(int) ), this, SLOT( slotSetParameter(int) ) );
parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 );
parameter->insertSeparator();
menu->insertItem( tr( "Settings" ) , settings );
menu->insertItem( tr( "Parameter" ) , parameter );
}
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp
index 3c010e9..b6401ed 100644
--- a/noncore/apps/opie-bartender/bartender.cpp
+++ b/noncore/apps/opie-bartender/bartender.cpp
@@ -9,195 +9,195 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "bartender.h"
#include "showdrinks.h"
#include "inputDialog.h"
#include "searchresults.h"
#include "bac.h"
#include <qpe/qpetoolbar.h>
#include <qmenubar.h>
//#include <opie2/colorpopupmenu.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qlineedit.h>
#include <qdir.h>
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qmultilineedit.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <qaction.h>
#include <qheader.h>
#include <qlistview.h>
#include <qlayout.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
Bartender::Bartender( QWidget* parent, const char* name, WFlags fl )
: QMainWindow( parent, name, fl ) {
if ( !name )
setName( "Bartender" );
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 2);
layout->setMargin( 2);
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
setCaption( tr( "Bartender" ) );
ToolBar1 = new QToolBar( this, "ToolBar1" );
ToolBar1->setFixedHeight(22);
layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 );
QMenuBar *menuBar = new QMenuBar( ToolBar1 );
QPopupMenu *fileMenu;
fileMenu = new QPopupMenu( this);
menuBar->insertItem( tr("File"), fileMenu );
fileMenu->insertItem(tr("New Drink"));
fileMenu->insertItem(tr("Open Drink"));
fileMenu->insertItem(tr("Find by Drink Name"));
fileMenu->insertItem(tr("Find by Alcohol"));
QPopupMenu *editMenu;
editMenu = new QPopupMenu( this);
menuBar->insertItem( tr("Edit"), editMenu );
editMenu->insertItem(tr("edit"));
connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) ));
connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) ));
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
a->addTo( ToolBar1 );
a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) );
a->addTo( ToolBar1 );
a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) );
a->addTo( ToolBar1 );
a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) );
a->addTo( ToolBar1 );
QPushButton *t;
t= new QPushButton( "BAC", ToolBar1, "bacButtin");
connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) );
DrinkView = new QListView( this, "DrinkView" );
DrinkView->addColumn( tr( "Name of Drink" ) );
// DrinkView->setRootIsDecorated( TRUE );
DrinkView->header()->hide();
QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold);
- connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink( QListViewItem*)));
- connect(DrinkView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
- this,SLOT( showDrink(int, QListViewItem *, const QPoint&, int)));
+ connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*)));
+ connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
+ this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int)));
layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 );
if(QDir("db").exists()) {
dbFile.setName( "db/drinkdb.txt");
} else
dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt");
initDrinkDb();
}
Bartender::~Bartender() {
}
/*
this happens right before exit */
void Bartender::cleanUp() {
dbFile.close();
}
void Bartender::initDrinkDb() {
if(!dbFile.isOpen())
if ( !dbFile.open( IO_ReadOnly)) {
QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
return;
}
fillList();
}
void Bartender::fillList() {
dbFile.at(1);
DrinkView->clear();
int i=0;
QListViewItem * item ;
QTextStream t( &dbFile);
QString s;
while ( !t.eof()) {
s = t.readLine();
if(s.find("#",0,TRUE) != -1) {
// qDebug(s.right(s.length()-2));
item= new QListViewItem( DrinkView, 0 );
item->setText( 0, s.right(s.length()-2));
i++;
}
}
qDebug("there are currently %d of drinks", i);
}
void Bartender::fileNew() {
New_Drink *newDrinks;
newDrinks = new New_Drink(this,"New Drink....", TRUE);
QString newName, newIng;
QPEApplication::execDialog( newDrinks );
newName = newDrinks->LineEdit1->text();
newIng= newDrinks->MultiLineEdit1->text();
if(dbFile.isOpen())
dbFile.close();
if ( !dbFile.open( IO_WriteOnly| IO_Append)) {
QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
return;
}
if(newDrinks ->result() == 1 ) {
QString newDrink="\n# "+newName+"\n";
newDrink.append(newIng+"\n");
qDebug("writing "+newDrink);
dbFile.writeBlock( newDrink.latin1(), newDrink.length());
clearList();
dbFile.close();
initDrinkDb();
}
delete newDrinks;
}
void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) {
switch (mouse) {
case 1:
// showDrink(item);
break;
case 2:
showDrink(item);
break;
}
}
void Bartender::showDrink( QListViewItem *item) {
if(item==NULL) return;
dbFile.at(0);
Show_Drink *showDrinks;
QString myDrink=item->text(0);
showDrinks = new Show_Drink(this, myDrink, TRUE);
QTextStream t( &dbFile);
QString s, s2;
diff --git a/noncore/apps/opie-bartender/searchresults.cpp b/noncore/apps/opie-bartender/searchresults.cpp
index 4900d1f..a511a57 100644
--- a/noncore/apps/opie-bartender/searchresults.cpp
+++ b/noncore/apps/opie-bartender/searchresults.cpp
@@ -1,43 +1,43 @@
/****************************************************************************
** Created: Sat Jul 20 08:23:27 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 "searchresults.h"
#include <qlistbox.h>
#include <qlayout.h>
Search_Results::Search_Results( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
if ( !name )
setName( drinkName);
drinkName = name;
setCaption( drinkName );
Layout5 = new QGridLayout( this );
Layout5->setSpacing( 6 );
Layout5->setMargin( 4 );
ListBox1 = new QListBox( this, "ListBox1" );
Layout5->addMultiCellWidget( ListBox1, 0, 1, 0, 3 );
- connect( ListBox1, SIGNAL( clicked( QListBoxItem *)), SLOT( listSelected( QListBoxItem *)) );
+ connect( ListBox1, SIGNAL( clicked(QListBoxItem*)), SLOT( listSelected(QListBoxItem*)) );
}
Search_Results::~Search_Results() {
}
void Search_Results::listSelected(QListBoxItem *) {
QDialog::accept();
}
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp
index 64046d8..0ac337f 100644
--- a/noncore/apps/opie-console/btconfigwidget.cpp
+++ b/noncore/apps/opie-console/btconfigwidget.cpp
@@ -1,139 +1,139 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qhbox.h>
#include <qradiobutton.h>
#include "iolayerbase.h"
#include "btconfigwidget.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 );
}
}
BTConfigWidget::BTConfigWidget( const QString& name,
QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
m_lay = new QVBoxLayout( this );
m_device = new QLabel( tr( "Device" ), this );
QHBox *deviceBox = new QHBox( this );
m_devRadio = new QRadioButton( deviceBox );
- connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) );
+ connect( m_devRadio, SIGNAL( toggled(bool) ), this, SLOT( slotDevRadio(bool) ) );
m_deviceCmb = new QComboBox( deviceBox );
m_deviceCmb->setEditable( TRUE );
QLabel *macLabel = new QLabel( this );
macLabel->setText( tr( "Or peer mac address" ) );
QHBox *macBox = new QHBox( this );
m_macRadio = new QRadioButton( macBox );
- connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) );
+ connect( m_macRadio, SIGNAL( toggled(bool) ), this, SLOT( slotMacRadio(bool) ) );
m_mac = new QLineEdit( macBox );
m_base = new IOLayerBase(this, "base");
m_lay->addWidget( m_device );
m_lay->addWidget( deviceBox );
m_lay->addWidget( macLabel );
m_lay->addWidget( macBox );
m_lay->addWidget( m_base );
m_deviceCmb->insertItem( "/dev/ttyU0" );
m_deviceCmb->insertItem( "/dev/ttyU1" );
}
BTConfigWidget::~BTConfigWidget() {
}
void BTConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry("Flow");
int rad_parity = prof.readNumEntry("Parity");
int speed = prof.readNumEntry("Speed");
QString mac = prof.readEntry("Mac");
if (!mac.isEmpty() ) {
m_mac->setText( mac );
} else {
m_devRadio->setChecked( true );
}
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 ( prof.readEntry("Device").isEmpty() ) return;
setCurrent( prof.readEntry("Device"), m_deviceCmb );
}
/*
* save speed,
* flow,
* parity
*/
void BTConfigWidget::save( Profile& prof ) {
int flow, parity, speed;
flow = parity = speed = 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:
diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp
index 6bc1240..526d55e 100644
--- a/noncore/apps/opie-console/dialdialog.cpp
+++ b/noncore/apps/opie-console/dialdialog.cpp
@@ -1,98 +1,98 @@
#include <qlayout.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qbuttongroup.h>
#include "dialdialog.h"
DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
setCaption( tr( "Enter number" ) );
QVBoxLayout *mainLayout = new QVBoxLayout( this );
QLabel *textLabel = new QLabel( this );
textLabel->setTextFormat( QLabel::RichText );
textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") );
m_dialLine = new QLineEdit( this );
m_dialLine->setReadOnly( true );
m_dialLine->setFrame( false );
m_dialLine->setAlignment( Qt::AlignLeft );
QFont dialLine_font( m_dialLine->font() );
dialLine_font.setBold( TRUE );
dialLine_font.setPointSize( 18 );
m_dialLine->setFont( dialLine_font );
QWidget* dialWidget = new QWidget( this );
QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 );
QButtonGroup *dialButtons = new QButtonGroup( );
QPushButton *number0 = new QPushButton( dialWidget );
number0->setText( QString( "0" ) );
QFont number0_font( number0->font() );
number0_font.setBold( TRUE );
number0->setFont( number0_font );
layout->addWidget( number0, 4, 1 );
dialButtons->insert( number0 );
int x = 0, y = 0;
for ( int i = 0 ; i < 9; i++ ) {
QPushButton *number = new QPushButton( dialWidget );
number->setText( QString( "%1" ).arg( i + 1 ) );
QFont number_font( number->font() );
number_font.setBold( TRUE );
number->setFont( number_font );
dialButtons->insert( number );
layout->addWidget( number, x, y );
if ( y < 2 ) {
y++;
} else {
x++;
y = 0;
}
}
- connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) );
+ connect( dialButtons, SIGNAL( clicked(int) ), this, SLOT( slotEnterNumber(int) ) );
mainLayout->addStretch( 2 );
mainLayout->addWidget( textLabel );
mainLayout->addStretch( 1 );
mainLayout->addWidget( m_dialLine );
mainLayout->addStretch( 2 );
mainLayout->addWidget( dialWidget );
mainLayout->addStretch( 4 );
}
void DialDialog::slotEnterNumber( int number ) {
// pretty stupid, just for testing .-)
m_number.append(QString("%1").arg(number));
setNumber(m_number);
}
DialDialog::~DialDialog() {
}
QString DialDialog::number() {
return m_number;
}
void DialDialog::setNumber( QString number )
{
m_dialLine->setText( QString("%1").arg( number ) );
}
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 2c1d888..99d069f 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,119 +1,119 @@
#include "TEmuVt102.h"
#include "profile.h"
#include "emulation_handler.h"
#include "script.h"
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) ) );
+ 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;
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 2bef801..fd30ad7 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -13,204 +13,204 @@
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Modified to suit opie-console */
/* */
/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */
/* */
/* -------------------------------------------------------------------------- */
/*! \class EmulationLayer
\brief Mediator between Widget and Screen.
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 Widget by certain rules.
\sa Widget \sa Screen
\par A note on refreshing
Although the modifications to the current screen image could immediately
be propagated via `Widget' 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 "emulation_layer.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* ------------------------------------------------------------------------- */
/* */
/* EmulationLayer */
/* */
/* ------------------------------------------------------------------------- */
#define CNTL(c) ((c)-'@')
/*!
*/
EmulationLayer::EmulationLayer( WidgetLayer* gui )
: decoder((QTextDecoder*)NULL)
{
this->gui = gui;
screen[0] = new Screen(gui->lines(),gui->columns());
screen[1] = new Screen(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( imageSizeChanged( int, int ) ),
- this,SLOT( onImageSizeChange( int, int ) ) );
- QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ),
- this,SLOT( historyCursorChange( int ) ) );
- QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ),
- this,SLOT( onKeyPress( QKeyEvent* ) ) );
- QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ),
- this,SLOT( onSelectionBegin( const int, const int ) ) );
- QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ),
- this,SLOT( onSelectionExtend( const int,const int ) ) );
- QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ),
- this,SLOT( setSelection( const bool ) ) );
+ QObject::connect(gui,SIGNAL( imageSizeChanged(int,int) ),
+ this,SLOT( onImageSizeChange(int,int) ) );
+ QObject::connect(gui,SIGNAL( changedHistoryCursor(int) ),
+ this,SLOT( historyCursorChange(int) ) );
+ QObject::connect(gui,SIGNAL( keyPressed(QKeyEvent*) ),
+ this,SLOT( onKeyPress(QKeyEvent*) ) );
+ QObject::connect(gui,SIGNAL( selectionBegin(const int,const int) ),
+ this,SLOT( onSelectionBegin(const int,const int) ) );
+ QObject::connect(gui,SIGNAL( selectionExtended(const int,const int) ),
+ this,SLOT( onSelectionExtend(const int,const int) ) );
+ QObject::connect(gui,SIGNAL( selectionEnd(const bool) ),
+ this,SLOT( setSelection(const bool) ) );
QObject::connect(gui,SIGNAL( selectionCleared() ),
this,SLOT( clearSelection() ) );
}
/*!
*/
EmulationLayer::~EmulationLayer()
{
delete screen[0];
delete screen[1];
bulk_timer.stop();
}
/*! change between primary and alternate screen
*/
void EmulationLayer::setScreen(int n)
{
scr = screen[n&1];
}
void EmulationLayer::setHistory(bool on)
{
screen[0]->setScroll(on);
if (!connected) return;
showBulk();
}
bool EmulationLayer::history()
{
return screen[0]->hasScroll();
}
void EmulationLayer::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 EmulationLayer::setKeytrans(int no)
{
keytrans = KeyTrans::find(no);
}
void EmulationLayer::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 EmulationLayer::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 EmulationLayer::onKeyPress( QKeyEvent* ev )
{
if (!connected) return; // someone else gets the keys
if (scr->getHistCursor() != scr->getHistLines());
scr->setHistCursor(scr->getHistLines());
if (!ev->text().isEmpty())
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index c232d89..eb32551 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -167,231 +167,231 @@ void FunctionKeyboard::paintKey(uint row, uint col) {
// 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");
kb = new FunctionKeyboard(this);
- connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
- this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool)));
+ 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&)));
+ 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&)));
+ 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&)));
+ 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);
}
}
void FunctionKeyboardConfig::slotChangeRows(int r) {
kb->changeRows(r);
}
void FunctionKeyboardConfig::slotChangeCols(int c) {
kb->changeCols(c);
}
void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
if (!pressed) return;
selectedHandle = "r" + QString::number(r) +
"c" + QString::number(c);
selectedRow = r;
selectedCol = c;
if (k.pixFile.isEmpty()) {
m_labels->setEditable(true);
m_labels->setCurrentItem(0);
m_labels->changeItem(k.label, 0);
} else {
// any better way to select the pixmap?
m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
m_labels->setEditable(false);
}
m_qvalues->changeItem(QString::number(k.qcode), 0);
m_uniValues->changeItem(QString::number(k.unicode), 0);
}
void FunctionKeyboardConfig::slotChangeIcon(int index) {
if (index == 0) {
// is text
m_labels->setEditable(true);
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp
index 37bf797..1a8c979 100644
--- a/noncore/apps/opie-console/io_bt.cpp
+++ b/noncore/apps/opie-console/io_bt.cpp
@@ -1,92 +1,92 @@
#include "io_bt.h"
IOBt::IOBt( const Profile &config ) : IOSerial( config ) {
m_attach = 0;
}
IOBt::~IOBt() {
if ( m_attach ) {
delete m_attach;
}
}
void IOBt::close() {
IOSerial::close();
// still need error handling
if ( m_attach ) {
delete m_attach;
m_attach = 0;
}
}
bool IOBt::open() {
bool ret = false;
// only set up bt stuff if mac address was set, otherwise use the device set
if ( !m_mac.isEmpty() ) {
// now it should also be checked, if there is a connection to the device with that mac allready
// hciattach here
m_attach = new OProcess();
*m_attach << "hciattach /dev/ttyS2 any 57600";
// then start hcid, then rcfomm handling (m_mac)
- connect( m_attach, SIGNAL( processExited( OProcess* ) ),
- this, SLOT( slotExited( OProcess* ) ) );
+ connect( m_attach, SIGNAL( processExited(OProcess*) ),
+ this, SLOT( slotExited(OProcess*) ) );
if ( m_attach->start() ) {
ret = IOSerial::open();
} else {
qWarning("could not attach to device");
delete m_attach;
m_attach = 0;
}
} else {
// directly to the normal serial
// TODO: look first if the connection really exists. ( is set up )
ret =IOSerial::open();
}
return ret;
}
void IOBt::reload( const Profile &config ) {
m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS);
m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS);
m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW);
}
QString IOBt::identifier() const {
return "bluetooth";
}
QString IOBt::name() const {
return "BLuetooth IO Layer";
}
void IOBt::slotExited( OProcess* proc ){
close();
delete proc;
}
QBitArray IOBt::supports() const {
return QBitArray( 3 );
}
bool IOBt::isConnected() {
return false;
}
void IOBt::send(const QByteArray &data) {
qDebug( "Please overload me..." );
}
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
index e360fb4..b281b7d 100644
--- a/noncore/apps/opie-console/io_irda.cpp
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -1,77 +1,77 @@
#include "io_irda.h"
IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) {
m_attach = 0;
}
IOIrda::~IOIrda() {
if ( m_attach ) {
delete m_attach;
}
}
void IOIrda::close() {
IOSerial::close();
// still need error handling
delete m_attach;
}
bool IOIrda::open() {
bool ret;
// irdaattach here
m_attach = new OProcess();
*m_attach << "irattach /dev/ttyS2 -s";
- connect( m_attach, SIGNAL( processExited( OProcess* ) ),
- this, SLOT( slotExited( OProcess* ) ) );
+ connect( m_attach, SIGNAL( processExited(OProcess*) ),
+ this, SLOT( slotExited(OProcess*) ) );
if ( m_attach->start() ) {
ret= IOSerial::open();
} else {
// emit error!!!
qWarning("could not attach to device");
delete m_attach;
m_attach = 0l;
}
return ret;
}
void IOIrda::reload( const Profile &config ) {
m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE);
m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY);
m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS);
m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS);
m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW);
}
QString IOIrda::identifier() const {
return "irda";
}
QString IOIrda::name() const {
return "Irda IO Layer";
}
void IOIrda::slotExited(OProcess* proc ){
close();
delete proc;
}
QBitArray IOIrda::supports()const {
return QBitArray( 3 );
}
bool IOIrda::isConnected() {
return false;
}
void IOIrda::send(const QByteArray &data) {
qDebug( "Please overload me..." );
}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 1d2385f..197f799 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -117,232 +117,232 @@ void MainWindow::initUI() {
connect( m_quickLaunch, SIGNAL( activated() ),
this, SLOT( slotQuickLaunch() ) );
QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
0, this, 0 );
m_transfer->addTo( m_console );
connect(m_transfer, SIGNAL(activated() ),
this, SLOT(slotTransfer() ) );
/*
* immediate change of line wrap policy
*/
m_isWrapped = false;
m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 );
m_wrap->addTo( m_console );
connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
/*
* fullscreen
*/
m_isFullscreen = false;
m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
, QString::null, 0, this, 0);
m_fullscreen->addTo( m_console );
connect( m_fullscreen, SIGNAL( activated() ),
this, SLOT( slotFullscreen() ) );
m_console->insertSeparator();
QAction *a = new QAction();
a->setText( tr("Save history") );
a->addTo( m_console );
connect(a, SIGNAL(activated() ),
this, SLOT(slotSaveHistory() ) );
/*
* terminate action
*/
m_terminate = new QAction();
m_terminate->setText( tr("Terminate") );
m_terminate->addTo( m_console );
connect(m_terminate, SIGNAL(activated() ),
this, SLOT(slotTerminate() ) );
m_closewindow = new QAction();
m_closewindow->setText( tr("Close Window") );
m_closewindow->addTo( m_console );
connect( m_closewindow, SIGNAL(activated() ),
this, SLOT(slotClose() ) );
/*
* script actions
*/
m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
m_recordScript->addTo(m_scripts);
connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
m_saveScript->addTo(m_scripts);
connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
/*
* action that open/closes the keyboard
*/
m_openKeys = new QAction (tr("Open Keyboard..."),
Resource::loadPixmap( "console/keys/keyboard_icon" ),
QString::null, 0, this, 0);
m_openKeys->setToggleAction(true);
connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
/* insert the submenu */
m_console->insertItem(tr("New from Profile"), m_sessionsPop,
-1, 0);
/* insert the connection menu */
m_bar->insertItem( tr("Connection"), m_console );
/* the scripts menu */
m_bar->insertItem( tr("Scripts"), m_scripts );
/* and the keyboard */
m_keyBar = new QToolBar(this);
addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
m_keyBar->setHorizontalStretchable( TRUE );
m_keyBar->hide();
m_kb = new FunctionKeyboard(m_keyBar);
- connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
- this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
+ connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
+ this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool)));
a = new QAction(tr("Copy"),
Resource::loadPixmap("copy"), QString::null,
0, this, 0 );
//a->addTo( m_icons );
connect( a, SIGNAL(activated() ),
this, SLOT(slotCopy() ) );
QAction *paste = new QAction(tr("Paste"),
Resource::loadPixmap("paste"), QString::null,
0, this, 0 );
connect( paste, SIGNAL(activated() ),
this, SLOT(slotPaste() ) );
newCon->addTo( m_icons );
//m_setProfiles->addTo( m_icons );
paste->addTo( m_icons );
m_openKeys->addTo(m_icons);
m_fullscreen->addTo( m_icons );
m_connect->setEnabled( false );
m_disconnect->setEnabled( false );
m_terminate->setEnabled( false );
m_transfer->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_fullscreen->setEnabled( false );
m_closewindow->setEnabled( false );
m_wrap->setEnabled( false );
/*
* connect to the menu activation
*/
- connect( m_sessionsPop, SIGNAL(activated( int ) ),
- this, SLOT(slotProfile( int ) ) );
+ connect( m_sessionsPop, SIGNAL(activated(int) ),
+ this, SLOT(slotProfile(int) ) );
m_consoleWindow = new TabWidget( this, "blah");
connect(m_consoleWindow, SIGNAL(activated(Session*) ),
this, SLOT(slotSessionChanged(Session*) ) );
setCentralWidget( m_consoleWindow );
slotQuickLaunch();
}
ProfileManager* MainWindow::manager() {
return m_manager;
}
TabWidget* MainWindow::tabWidget() {
return m_consoleWindow;
}
void MainWindow::populateProfiles() {
m_sessionsPop->clear();
Profile::ValueList list = manager()->all();
for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
m_sessionsPop->insertItem( (*it).name() );
}
}
void MainWindow::populateScripts() {
m_scriptsPop->clear();
m_scriptsData.clear();
DocLnkSet files(QPEApplication::documentDir(), "text/plain");
QListIterator<DocLnk> dit(files.children());
for (; dit.current(); ++dit) {
if (*dit && (*dit)->name().length()>0) {
QFileInfo info((*dit)->file());
if (info.extension(false) == "script") {
m_scriptsData.append(new DocLnk(**dit));
m_scriptsPop->insertItem((*dit)->name());
}
}
}
}
MainWindow::~MainWindow() {
delete m_factory;
manager()->save();
}
MetaFactory* MainWindow::factory() {
return m_factory;
}
Session* MainWindow::currentSession() {
return m_curSession;
}
QList<Session> MainWindow::sessions() {
return m_sessions;
}
void MainWindow::slotNew() {
ProfileEditorDialog dlg(factory() );
dlg.setCaption( tr("New Connection") );
int ret = QPEApplication::execDialog( &dlg );
if ( ret == QDialog::Accepted ) {
create( dlg.profile() );
}
}
void MainWindow::slotRecordScript() {
if (currentSession()) {
currentSession()->emulationHandler()->startRecording();
m_saveScript->setEnabled(true);
m_recordScript->setEnabled(false);
}
}
void MainWindow::slotSaveScript() {
if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
QMap<QString, QStringList> map;
QStringList text;
text << "text/plain";
map.insert(tr("Script"), text );
QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
if (!filename.isEmpty()) {
QFileInfo info(filename);
if (info.extension(FALSE) != "script")
filename += ".script";
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filename);
nf.setName(info.fileName());
FileManager fm;
fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
currentSession()->emulationHandler()->clearScript();
m_saveScript->setEnabled(false);
m_recordScript->setEnabled(true);
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 979e89d..6e1e23e 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -38,196 +38,196 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
initUI();
// Apply current profile
// plugin_plugin->load(profile);
}
Profile ProfileEditorDialog::profile() const
{
return m_prof;
}
void ProfileEditorDialog::initUI()
{
m_con = m_term = m_key = 0l;
QVBoxLayout *mainLayout = new QVBoxLayout( this );
tabWidget = new OTabWidget( this );
tabWidget->setTabStyle(OTabWidget::TextTab);
mainLayout->add(tabWidget);
/* base tabs */
tabprof = new QWidget(this);
m_tabTerm = new QWidget(this);
m_tabCon = new QWidget(this);
m_tabKey = new QWidget(this);
m_svCon = new QScrollView( m_tabCon );
m_svCon->setResizePolicy( QScrollView::AutoOneFit );
//m_svCon->setHScrollBarMode( QScrollView::AlwaysOff );
m_svCon->setFrameShape( QFrame::NoFrame );
m_svTerm = new QScrollView( m_tabTerm );
m_svTerm->setResizePolicy( QScrollView::AutoOneFit );
//m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff );
m_svTerm->setFrameShape( QFrame::NoFrame );
/* base layout for tabs */
m_layCon = new QHBoxLayout( m_tabCon , 2 );
m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
m_layKey = new QHBoxLayout( m_tabKey, 2 );
m_layCon->addWidget( m_svCon );
m_layTerm->addWidget( m_svTerm );
// profile tab
QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
m_name = new QLineEdit(tabprof);
QLabel *con = new QLabel(tr("Connection"), tabprof );
QLabel *term = new QLabel(tr("Terminal"), tabprof );
m_conCmb = new QComboBox( tabprof );
m_termCmb = new QComboBox( tabprof );
m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof);
// layouting
QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
vbox3->add(name);
vbox3->add(m_name);
vbox3->add(con );
vbox3->add(m_conCmb );
vbox3->add(term );
vbox3->add(m_termCmb );
vbox3->add(m_autoConnect);
vbox3->addStretch(1);
m_showconntab = 0;
tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys"));
tabWidget->setCurrentTab( tabprof );
// fill the comboboxes
QStringList list = m_fact->connectionWidgets();
QStringList::Iterator it;
for (it =list.begin(); it != list.end(); ++it ) {
m_conCmb->insertItem( (*it) );
}
list = m_fact->terminalWidgets();
for (it =list.begin(); it != list.end(); ++it ) {
m_termCmb->insertItem( (*it) );
}
// load profile values
m_name->setText(m_prof.name());
slotKeyActivated( "Default Keyboard" );
setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
slotTermActivated( m_fact->external(m_prof.terminalName() ) );
m_autoConnect->setChecked(m_prof.autoConnect());
// signal and slots
- connect(m_conCmb, SIGNAL(activated(const QString& ) ),
+ connect(m_conCmb, SIGNAL(activated(const QString&) ),
this, SLOT(slotConActivated(const QString&) ) );
- connect(m_termCmb, SIGNAL(activated(const QString& ) ),
- this, SLOT(slotTermActivated(const QString& ) ) );
+ connect(m_termCmb, SIGNAL(activated(const QString&) ),
+ this, SLOT(slotTermActivated(const QString&) ) );
}
ProfileEditorDialog::~ProfileEditorDialog() {
}
void ProfileEditorDialog::accept()
{
if(profName().isEmpty())
{
QMessageBox::information(this,
QObject::tr("Invalid profile"),
QObject::tr("Please enter a profile name."));
return;
}
// Save profile and plugin profile
//if(plugin_plugin) plugin_plugin->save();
// Save general values
m_prof.setName( profName() );
m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
m_prof.setAutoConnect( m_autoConnect->isChecked() );
if (m_con )
m_con->save( m_prof );
if (m_term )
m_term->save( m_prof );
if (m_key)
m_key->save( m_prof );
QDialog::accept();
}
QString ProfileEditorDialog::profName()const
{
return m_name->text();
}
QCString ProfileEditorDialog::profType()const
{
/*QStringList w = m_fact->configWidgets();
for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
if(device_box->currentText() == m_fact->name((*it))) return (*it);
*/
return QCString();
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotConActivated( const QString& str ) {
delete m_con;
m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() );
if ( !m_con ) {
m_con = new NoOptions( str, m_svCon->viewport(), "name");
}
// FIXME ugly hack right. Right solution would be to look into the layer and see if it
// supports auto connect and then set it as prefered
if ( m_conCmb ->currentText() == tr("Local Console") ) {
m_autoConnect->setChecked( true );
m_prof.writeEntry("Terminal", Profile::Linux );
slotTermActivated( m_fact->external (m_prof.terminalName() ) );
} else {
m_prof.writeEntry("Terminal", Profile::VT102 );
slotTermActivated( m_fact->external (m_prof.terminalName() ) );
m_autoConnect->setChecked( false );
}
m_con->load( m_prof );
m_svCon->addChild( m_con );
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotTermActivated( const QString& str ) {
delete m_term;
m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() );
if ( m_term ) {
m_term->load( m_prof );
m_svTerm->addChild( m_term );
}
}
void ProfileEditorDialog::slotKeyActivated(const QString &str) {
delete m_key;
m_key = m_fact->newKeyboardPlugin( str, m_tabKey );
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index 1034ede..b7f14c5 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,115 +1,115 @@
#include "file_layer.h"
#include "emulation_handler.h"
#include "session.h"
Session::Session() {
m_widget = 0l;
m_layer = 0l;
m_emu = 0l;
m_transfer = 0l;
}
Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay)
: m_name( na ), m_widget( widget ), m_layer( lay )
{
// m_widLay = 0l;
// m_emLay = 0l;
m_emu = 0l;
}
Session::~Session() {
delete m_layer;
delete m_emu;
delete m_widget;
/* the widget layer should be deleted by the m_widget */
}
QString Session::name()const {
return m_name;
}
QWidgetStack* Session::widgetStack() {
return m_widget;
}
IOLayer* Session::layer() {
return m_layer;
}
EmulationHandler* Session::emulationHandler() {
return m_emu;
}
QWidget* Session::widget() {
if (!m_emu )
return 0l;
return m_emu->widget();
}
Profile Session::profile()const {
return m_prof;
}
/*
WidgetLayer* Session::emulationWidget() {
return m_widLay;
}
*/
void Session::connect() {
if ( !m_layer || !m_emu )
return;
QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ),
m_emu, SLOT(recv(const QByteArray&) ) );
QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ),
m_layer, SLOT(send(const QByteArray&) ) );
- QObject::connect(m_emu, SIGNAL(changeSize(int, int) ),
- m_layer, SLOT(setSize(int, int) ) );
+ QObject::connect(m_emu, SIGNAL(changeSize(int,int) ),
+ m_layer, SLOT(setSize(int,int) ) );
}
void Session::disconnect() {
if ( !m_layer || !m_emu )
return;
QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ),
m_emu, SLOT(recv(const QByteArray&) ) );
QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ),
m_layer, SLOT(send(const QByteArray&) ) );
}
void Session::setName( const QString& na){
m_name = na;
}
void Session::setWidgetStack( QWidgetStack* wid ) {
delete m_emu;
m_emu = 0l;
delete m_widget;
/* the EmulationLayer was destroyed... */
m_widget = wid;
}
void Session::setIOLayer( IOLayer* lay ) {
delete m_layer;
m_layer = lay;
}
void Session::setEmulationHandler( EmulationHandler* lay ) {
delete m_emu;
m_emu = lay;
}
void Session::setProfile( const Profile& prof ) {
m_prof = prof;
}
/*
void Session::setEmulationWidget( WidgetLayer* lay ) {
delete m_widLay;
m_widLay = lay;
}
*/
void Session::setTransferDialog(QWidget *d)
{
m_transfer = d;
}
QWidget *Session::transferDialog()
{
return m_transfer;
}
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp
index c47e73e..2f82417 100644
--- a/noncore/apps/opie-console/sz_transfer.cpp
+++ b/noncore/apps/opie-console/sz_transfer.cpp
@@ -1,84 +1,84 @@
#include "sz_transfer.h"
#include <qfile.h>
#include <stdio.h>
#include <sys/termios.h>
SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t)
{
}
SzTransfer::~SzTransfer() {
}
void SzTransfer::sendFile(const QFile& file) {
sendFile(file.name());
}
void SzTransfer::sendFile(const QString& file) {
//setcbreak(2); /* raw no echo */
proc = new OProcess;
*proc << "sz";
*proc << "-v" << "-v" << "-b" << file;
- connect(proc, SIGNAL(processExited(OProcess *)),
+ connect(proc, SIGNAL(processExited(OProcess*)),
this, SLOT(sent()));
- connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
- this, SLOT(SzReceivedStdout(OProcess *, char *, int)));
- connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
- this, SLOT(SzReceivedStderr(OProcess *, char *, int)));
- connect(layer(), SIGNAL(received(const QByteArray &)),
- this, SLOT(receivedStdin(const QByteArray &)));
+ connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)),
+ this, SLOT(SzReceivedStdout(OProcess*,char*,int)));
+ connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)),
+ this, SLOT(SzReceivedStderr(OProcess*,char*,int)));
+ connect(layer(), SIGNAL(received(const QByteArray&)),
+ this, SLOT(receivedStdin(const QByteArray&)));
proc->start(OProcess::NotifyOnExit, OProcess::All);
}
void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) {
qWarning("recieved from sz on stdout %d bytes", buflen);
QByteArray data(buflen);
data.fill(*buffer, buflen);
for (uint i = 0; i < data.count(); i++ ) {
printf("%c", buffer[i] );
}
printf("\n");
// send out through the io layer
layer()->send(data);
}
void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) {
// parse and show data in a progress dialog/widget
printf("stderr:\n");
//for (int i = 0; i < length; i++)
// printf("%c", buffer[i]);
//printf("\n");
}
void SzTransfer::receivedStdin(const QByteArray &data) {
qWarning("recieved from io_serial %d bytes", data.size());
// recieved data from the io layer goes to sz
proc->writeStdin(data.data(), data.size());
}
void SzTransfer::sent() {
qWarning("sent file");
//setcbreak(0); /* default */
delete proc;
- disconnect(layer(), SIGNAL(received(const QByteArray &)),
- this, SLOT(receivedStdin(const QByteArray &)));
+ disconnect(layer(), SIGNAL(received(const QByteArray&)),
+ this, SLOT(receivedStdin(const QByteArray&)));
}
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp
index 4a7202d..b1725db 100644
--- a/noncore/apps/opie-console/test/senderui.cpp
+++ b/noncore/apps/opie-console/test/senderui.cpp
@@ -1,77 +1,77 @@
#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"
SenderUI::SenderUI()
: Sender() {
/* we do that manually */
Profile prof;
QString str = "/dev/bty0";
prof.writeEntry("Device",str );
prof.writeEntry("Baud", 19200 );
qWarning("prof " + prof.readEntry("Device") + " " + str);
ser = new IOSerial(prof);
- connect(ser, SIGNAL(received(const QByteArray& ) ),
+ connect(ser, SIGNAL(received(const QByteArray&) ),
this, SLOT(got(const QByteArray&) ) );
if ( ser->open() )
qWarning("opened!!!");
else
qWarning("could not open");
}
SenderUI::~SenderUI() {
}
void SenderUI::slotSendFile() {
sz = new FileTransfer(FileTransfer::SY, ser);
sz->sendFile("/home/ich/bootopie-v06-13.jffs2");
connect (sz, SIGNAL(sent()),
this, SLOT(fileTransComplete()));
}
void SenderUI::slotSend() {
QCString str = MultiLineEdit1->text().utf8();
qWarning("sending: %s", str.data() );
str = str.replace( QRegExp("\n"), "\r");
ser->send( str );
}
void SenderUI::got(const QByteArray& ar) {
qWarning("got:");
for ( uint i = 0; i < ar.count(); i++ ) {
printf("%c", ar[i] );
}
printf("\n");
}
void SenderUI::fileTransComplete() {
qWarning("file transfer complete");
}
void SenderUI::send() {
}
void SenderUI::slotRev(){
qWarning("Going to receive!");
FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
rev->receive();
}
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index 30e7caf..d494a6c 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -32,205 +32,205 @@ TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const ch
group = new QButtonGroup(QObject::tr("Transfer mode"), this);
mode_send = new QRadioButton(QObject::tr("Send"), group);
mode_receive = new QRadioButton(QObject::tr("Receive"), group);
group->insert(mode_send, id_send);
group->insert(mode_receive, id_receive);
vbox2 = new QVBoxLayout(group, 2);
vbox2->addSpacing(10);
hbox3 = new QHBoxLayout(vbox2, 2);
hbox3->add(mode_send);
hbox3->add(mode_receive);
mode_send->setChecked(true);
m_transfermode = id_send;
file = new QLabel(QObject::tr("Send file"), this);
mode = new QLabel(QObject::tr("Transfer protocol"), this);
progress = new QLabel(QObject::tr("Progress"), this);
status = new QLabel(QObject::tr("Status"), this);
statusbar = new QLabel(QObject::tr("Ready"), this);
statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
protocol = new QComboBox(this);
QStringList list = m_win->factory()->fileTransferLayers();
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
protocol->insertItem((*it));
filename = new QLineEdit(this);
progressbar = new QProgressBar(this);
progressbar->setProgress(0);
selector = new QPushButton("...", this);
ok = new QPushButton(QObject::tr("Start transfer"), this);
cancel = new QPushButton(QObject::tr("Cancel"), this);
vbox = new QVBoxLayout(this, 2);
vbox->add(group);
vbox->add(file);
hbox = new QHBoxLayout(vbox, 0);
hbox->add(filename);
hbox->add(selector);
vbox->add(mode);
vbox->add(protocol);
vbox->add(progress);
vbox->add(progressbar);
vbox->add(status);
vbox->add(statusbar);
vbox->addStretch(1);
hbox2 = new QHBoxLayout(vbox, 2);
hbox2->add(ok);
hbox2->add(cancel);
setCaption(QObject::tr("File transfer"));
show();
connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int)));
}
TransferDialog::~TransferDialog()
{
}
void TransferDialog::slotFilename()
{
QString f;
f = Opie::OFileDialog::getOpenFileName(0);
if(!f.isNull()) filename->setText(f);
}
void TransferDialog::slotTransfer()
{
if((m_transfermode == id_send) && (filename->text().isEmpty()))
{
QMessageBox::information(this,
QObject::tr("Attention"),
QObject::tr("No file has been specified."));
return;
}
ok->setEnabled(false);
cleanup();
m_autocleanup = 0;
if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending..."));
else statusbar->setText(QObject::tr("Receiving..."));
if(m_transfermode == id_send)
{
m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
m_lay->sendFile(filename->text());
- connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)),
- SLOT(slotProgress(const QString&, int, int, int, int, int)));
- connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
+ connect(m_lay, SIGNAL(progress(const QString&,int,int,int,int,int)),
+ SLOT(slotProgress(const QString&,int,int,int,int,int)));
+ connect(m_lay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&)));
connect(m_lay, SIGNAL(sent()), SLOT(slotSent()));
}
else
{
m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer());
m_recvlay->receive();
- connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)),
- SLOT(slotProgress(const QString&, int, int, int, int, int)));
- connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
+ connect(m_recvlay, SIGNAL(progress(const QString&,int,int,int,int,int)),
+ SLOT(slotProgress(const QString&,int,int,int,int,int)));
+ connect(m_recvlay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&)));
connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&)));
}
}
void TransferDialog::cleanup()
{
if(m_lay)
{
m_lay->cancel();
delete m_lay;
m_lay = 0l;
}
if(m_recvlay)
{
m_recvlay->cancel();
delete m_recvlay;
m_recvlay = 0l;
}
}
void TransferDialog::slotCancel()
{
ok->setEnabled(true);
statusbar->setText(QObject::tr("Ready"));
if((m_lay) || (m_recvlay))
{
cleanup();
if(m_autocleanup)
{
m_running = false;
close();
}
else
{
QMessageBox::information(this,
QObject::tr("Cancelled"),
QObject::tr("The file transfer has been cancelled."));
}
}
else
{
m_running = false;
close();
}
}
void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int )
{
progressbar->setProgress(progress);
}
void TransferDialog::slotError(int error, const QString& )
{
statusbar->setText(QObject::tr("Ready"));
switch(error)
{
case FileTransferLayer::NotSupported:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Operation not supported."));
break;
case FileTransferLayer::StartError:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Transfer could not be started."));
break;
case FileTransferLayer::NoError:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("No error."));
break;
case FileTransferLayer::Undefined:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Undefined error occured."));
break;
case FileTransferLayer::Incomplete:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Incomplete transfer."));
break;
case FileTransferLayer::Unknown:
default:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Unknown error occured."));
break;
}
m_autocleanup = 1;
}
void TransferDialog::slotSent()
{
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index e759249..b0d589e 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -236,317 +236,317 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
}
else if (rot.contains("Rot180"))
{
m_rot = 180;
}
else if (rot.contains("Rot270"))
{
m_rot = 270;
}
// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot);
*/
m_autogenstr = "^ *[A-Z].*[a-z] *$";
#ifdef USEQPE
setIcon( Resource::loadPixmap( PICDIR "uqtreader") );
#else
setIcon( QPixmap (PICDIR "uqtreader.png") );
#endif /* USEQPE */
// QToolBar *bar = new QToolBar( this );
// menubar = new QToolBar( this );
#ifdef USEQPE
Config config( APPDIR );
#else
QDir d = QDir::home(); // "/"
if ( !d.cd(APPDIR) ) { // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
d = QDir::home();
d.mkdir(APPDIR);
d.cd(APPDIR);
}
QFileInfo fi(d, INIFILE);
// qDebug("Path:%s", (const char*)fi.absFilePath());
Config config(fi.absFilePath());
#endif
config.setGroup("Toolbar");
m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
menubar = new QToolBar("Menus", this, m_tbposition);
// fileBar = new QToolBar("File", this);
// QToolBar* viewBar = new QToolBar("File", this);
// QToolBar* navBar = new QToolBar("File", this);
// QToolBar* markBar = new QToolBar("File", this);
#ifdef USEQPE
mb = new QMenuBar( menubar );
#else
mb = new QMenuBar( menubar );
#endif
//#ifdef USEQPE
QPopupMenu* tmp = new QPopupMenu(mb);
mb->insertItem( geticon( "AppsIcon" ), tmp );
//#else
// QMenuBar* tmp = mb;
//#endif
QPopupMenu *file = new QPopupMenu( mb );
tmp->insertItem( tr( "File" ), file );
QPopupMenu *navigation = new QPopupMenu(mb);
tmp->insertItem( tr( "Navigation" ), navigation );
QPopupMenu *view = new QPopupMenu( mb );
tmp->insertItem( tr( "View" ), view );
QPopupMenu *marks = new QPopupMenu( this );
tmp->insertItem( tr( "Marks" ), marks );
QPopupMenu *settings = new QPopupMenu( this );
tmp->insertItem( tr( "Settings" ), settings );
// addToolBar(menubar, "Menus",QMainWindow::Top);
// addToolBar(fileBar, "Toolbar",QMainWindow::Top);
// QPopupMenu *edit = new QPopupMenu( this );
/*
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
a->addTo( bar );
a->addTo( file );
*/
editorStack = new QWidgetStack( this );
setCentralWidget( editorStack );
searchVisible = FALSE;
regVisible = FALSE;
m_fontVisible = false;
m_annoWin = new CAnnoEdit(editorStack);
editorStack->addWidget(m_annoWin, get_unique_id());
- connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
+ connect( m_annoWin, SIGNAL( finished(const QString&,const QString&) ), this, SLOT( addAnno(const QString&,const QString&) ) );
connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
m_infoWin = new infowin(editorStack);
editorStack->addWidget(m_infoWin, get_unique_id());
connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
m_graphicwin = new GraphicWin(editorStack);
editorStack->addWidget(m_graphicwin, get_unique_id());
connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
// bkmkselector = new QListBox(editorStack, "Bookmarks");
bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
// connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
editorStack->addWidget( bkmkselector, get_unique_id() );
/*
importSelector = new FileSelector( "*", editorStack, "importselector", false );
- connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) );
+ connect( importSelector, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( importFile(const DocLnk&) ) );
editorStack->addWidget( importSelector, get_unique_id() );
// don't need the close visible, it is redundant...
importSelector->setCloseVisible( FALSE );
*/
// qDebug("Reading file list");
readfilelist();
reader = new QTReader( editorStack );
reader->bDoUpdates = false;
#ifdef USEQPE
((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
#endif
// qDebug("Reading config");
// Config config( APPDIR );
config.setGroup( "View" );
m_debounce = config.readNumEntry("Debounce", 0);
#ifdef USEQPE
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
#else
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
#endif
reader->bstripcr = config.readBoolEntry( "StripCr", true );
reader->bfulljust = config.readBoolEntry( "FullJust", false );
reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
reader->btextfmt = config.readBoolEntry( "TextFmt", false );
reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
reader->bpeanut = config.readBoolEntry( "Peanut", false );
reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
reader->bdepluck = config.readBoolEntry( "Depluck", false );
reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
reader->bonespace = config.readBoolEntry( "OneSpace", false );
reader->bunindent = config.readBoolEntry( "Unindent", false );
reader->brepara = config.readBoolEntry( "Repara", false );
reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
reader->bindenter = config.readNumEntry( "Indent", 0 );
reader->m_textsize = config.readNumEntry( "FontSize", 12 );
reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
reader->m_lastfile = config.readEntry( "LastFile", QString::null );
reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
reader->m_encd = config.readNumEntry( "Encoding", 0 );
reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
reader->m_overlap = config.readNumEntry( "Overlap", 0 );
reader->m_border = config.readNumEntry( "Margin", 6 );
#ifdef REPALM
reader->brepalm = config.readBoolEntry( "Repalm", true );
#endif
reader->bremap = config.readBoolEntry( "Remap", true );
reader->bmakebold = config.readBoolEntry( "MakeBold", false );
reader->setContinuous(config.readBoolEntry( "Continuous", true ));
m_targetapp = config.readEntry( "TargetApp", QString::null );
m_targetmsg = config.readEntry( "TargetMsg", QString::null );
#ifdef _SCROLLPIPE
reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
#endif
m_twoTouch = config.readBoolEntry( "TwoTouch", false);
m_doAnnotation = config.readBoolEntry( "Annotation", false);
m_doDictionary = config.readBoolEntry( "Dictionary", false);
m_doClipboard = config.readBoolEntry( "Clipboard", false);
m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
m_leftScroll = config.readBoolEntry("LeftScroll", false);
m_rightScroll = config.readBoolEntry("RightScroll", false);
m_upScroll = config.readBoolEntry("UpScroll", true);
m_downScroll = config.readBoolEntry("DownScroll", true);
m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
#ifndef USEQPE
config.setGroup( "Geometry" );
setGeometry(0,0,
config.readNumEntry( "width", QApplication::desktop()->width()/2 ),
config.readNumEntry( "height", QApplication::desktop()->height()/2 ));
move(
config.readNumEntry( "x", 20 ),
config.readNumEntry( "y", 20 ));
#endif
setTwoTouch(m_twoTouch);
connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) );
connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
- connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) );
+ connect( reader, SIGNAL( OnWordSelected(const QString&,size_t,const QString&) ), this, SLOT( OnWordSelected(const QString&,size_t,const QString&) ) );
connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) );
editorStack->addWidget( reader, get_unique_id() );
m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL);
connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) );
m_preferences_action->addTo( settings );
m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL);
connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) );
m_saveconfig_action->addTo( settings );
m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL);
connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) );
m_loadconfig_action->addTo( settings );
m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL);
connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) );
m_tidyconfig_action->addTo( settings );
settings->insertSeparator();
m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL);
connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) );
m_toolbarprefs_action->addTo( settings );
m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 );
connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
m_open_action->addTo( file );
m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) );
m_close_action->addTo( file );
#ifdef _SCRIPT
a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) );
a->addTo( file );
#endif
/*
a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
a->addTo( file );
a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( filebar() );
a->addTo( edit );
*/
m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL);
connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) );
m_info_action->addTo( file );
m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true );
connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
m_touch_action->setOn(m_twoTouch);
m_touch_action->addTo( file );
m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL);
connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) );
file->insertSeparator();
// a->addTo( bar );
m_find_action->addTo( file );
m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL);
connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) );
m_exportlinks_action->addTo( file );
m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true );
connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
m_scrollButton->addTo(navigation);
m_scrollButton->setOn(false);
m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL);
connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) );
m_start_action->addTo(navigation);
m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
m_end_action->addTo(navigation);
m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
m_jump_action->addTo(navigation);
m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
m_pageline_action->addTo(navigation);
m_pageline_action->setOn(reader->m_bpagemode);
m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
m_pageup_action->addTo( navigation );
m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
m_pagedn_action->addTo( navigation );
@@ -633,266 +633,266 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
view->insertSeparator();
m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this);
connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) );
m_setenc_action->addTo( view );
m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true);
connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
m_setmono_action->addTo( view );
m_setmono_action->setOn(reader->m_bMonoSpaced);
// a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
// a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 );
// a->addTo( filebar() );
// view->insertSeparator();
/*
a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
a->setOn(reader->m_bMonoSpaced);
a->addTo( view );
*/
/*
a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
a->addTo( view );
*/
m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL);
connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
m_mark_action->addTo( marks );
m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL);
connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) );
m_annotate_action->addTo( marks );
m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false );
connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
m_goto_action->addTo( marks );
m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL);
connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
m_delete_action->addTo( marks );
m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false );
connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
marks->insertSeparator();
m_autogen_action->addTo( marks );
m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL);
connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
m_clear_action->addTo( marks );
m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL );
connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
m_save_action->addTo( marks );
m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL);
connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
marks->insertSeparator();
m_tidy_action->addTo( marks );
m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL);
connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) );
marks->insertSeparator();
m_startBlock_action->addTo( marks );
m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL);
connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) );
m_endBlock_action->addTo( marks );
m_bkmkAvail = NULL;
setToolBarsMovable(m_tbmove);
addtoolbars(&config);
pbar = new QProgressBar(this);
pbar->hide();
searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
searchBar->setHorizontalStretchable( TRUE );
connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
searchEdit = new QLineEdit( searchBar, "searchEdit" );
// QFont f("unifont", 16 /*, QFont::Bold*/);
// searchEdit->setFont( f );
searchBar->setStretchableWidget( searchEdit );
#ifdef __ISEARCH
- connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
- this, SLOT( search( const QString& ) ) );
+ connect( searchEdit, SIGNAL( textChanged(const QString&) ),
+ this, SLOT( search(const QString&) ) );
#else
- connect( searchEdit, SIGNAL( returnPressed( ) ),
- this, SLOT( search( ) ) );
+ connect( searchEdit, SIGNAL( returnPressed() ),
+ this, SLOT( search() ) );
#endif
QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
a->addTo( searchBar );
a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
a->addTo( searchBar );
searchBar->hide();
regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE );
connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
regBar->setHorizontalStretchable( TRUE );
regEdit = new QLineEdit( regBar, "regEdit" );
// regEdit->setFont( f );
regBar->setStretchableWidget( regEdit );
- connect( regEdit, SIGNAL( returnPressed( ) ),
+ connect( regEdit, SIGNAL( returnPressed() ),
this, SLOT( do_regaction() ) );
a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
a->addTo( regBar );
a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
a->addTo( regBar );
regBar->hide();
m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
m_fontBar->setHorizontalStretchable( TRUE );
// qDebug("Font selector");
m_fontSelector = new QComboBox(false, m_fontBar);
m_fontBar->setStretchableWidget( m_fontSelector );
{
#ifndef USEQPE
QFontDatabase f;
#else
FontDatabase f;
#endif
QStringList flist = f.families();
bool realfont = false;
for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
{
if (reader->m_fontname == *nm)
{
realfont = true;
}
if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm);
}
if (!realfont) reader->m_fontname = flist[0];
} // delete the FontDatabase!!!
- connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
+ connect( m_fontSelector, SIGNAL( activated(const QString&) ),
this, SLOT( do_setfont(const QString&) ) );
- connect( m_fontSelector, SIGNAL( activated(int ) ),
+ connect( m_fontSelector, SIGNAL( activated(int) ),
this, SLOT( do_setencoding(int) ) );
m_fontBar->hide();
m_fontVisible = false;
#ifdef USEMSGS
- connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
- this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
+ connect(qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
+ this, SLOT( msgHandler(const QCString&,const QByteArray&) ) );
#endif
// qDebug("Initing");
reader->init();
// qDebug("Inited");
// m_buttonAction[m_spaceTarget]->setOn(true);
// qDebug("fonting");
do_setfont(reader->m_fontname);
if (!reader->m_lastfile.isEmpty())
{
// qDebug("doclnk");
// doc = new DocLnk(reader->m_lastfile);
// qDebug("doclnk done");
if (pOpenlist != NULL)
{
/*
int ind = 0;
Bkmk* p = (*pOpenlist)[ind];
while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
{
p = (*pOpenlist)[++ind];
}
*/
Bkmk* p = NULL;
for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
{
p = iter.pContent();
if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
{
break;
}
// qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
p = NULL;
}
if (p != NULL)
{
// qDebug("openfrombkmk");
if (!openfrombkmk(p))
showEditTools();
}
else
{
// qDebug("openfile");
openFile( reader->m_lastfile );
}
}
else
{
// qDebug("Openfile 2");
if (!reader->m_lastfile.isEmpty())
openFile( reader->m_lastfile );
}
}
else
{
showEditTools();
}
// qApp->processEvents();
reader->bDoUpdates = true;
reader->update();
config.setGroup("Version");
int major = config.readNumEntry("Major", 0);
int bkmktype = config.readNumEntry("BkmkType", 0);
char minor = config.readNumEntry("Minor", 0);
if (CheckVersion(major, bkmktype, minor))
{
config.writeEntry("Major", major);
config.writeEntry("BkmkType", bkmktype);
config.writeEntry("Minor", (int)minor);
}
// qDebug("finished update");
}
void QTReaderApp::addtoolbars(Config* config)
{
config->setGroup("Toolbar");
if (fileBar != NULL)
{
if (fileBar != menubar)
{
fileBar->clear();
}
else
{
m_preferences_action->removeFrom( filebar() );
m_open_action->removeFrom( filebar() );
m_close_action->removeFrom( filebar() );
m_info_action->removeFrom( filebar() );
m_touch_action->removeFrom( filebar() );
m_find_action->removeFrom( filebar() );
}
}
m_preferences_action->addTo( filebar() );
addfilebar(config, "Open", m_open_action);
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp
index ebd14f3..e1cde6c 100644
--- a/noncore/apps/opie-reader/fileBrowser.cpp
+++ b/noncore/apps/opie-reader/fileBrowser.cpp
@@ -1,176 +1,176 @@
/****************************************************************************
Derived from a file browser which was
** copyright 2001 ljp ljp@llornkcor.com
Extensive modification by Tim Wentford to allow it to work in rotated mode
****************************************************************************/
#include "fileBrowser.h"
#include "QtrListView.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#ifndef _WINDOWS
#include <unistd.h>
#endif
#include <qlayout.h>
#ifdef _WINDOWS
#include <direct.h>
#endif
#include <qpe/qpeapplication.h>
fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath )
: QDialog( parent, name, true,
fl/* | WStyle_Customize | WStyle_Tool*/),
filterspec(QDir::All)
{
// showMaximized();
if ( !name )
setName( "fileBrowser" );
/*
if (parent != NULL)
{
#ifdef OPIE
move(0,0);
resize( parent->width(), parent->height() );
#else
setGeometry(parent->x(), parent->y(), parent->width(), parent->height() );
#endif
}
*/
// showFullScreen();
setCaption(tr( "Browse for file" ) );
filterStr=filter;
buttonOk = new QPushButton( this, "buttonOk" );
buttonOk->setFixedSize( 25, 25 );
buttonOk->setAutoDefault( false );
buttonOk->setText( tr( "/" ) );
buttonShowHidden = new QPushButton( this, "buttonShowHidden" );
// buttonShowHidden->setFixedSize( 50, 25 );
buttonShowHidden->setText( tr( "Hidden" ) );
buttonShowHidden->setAutoDefault( false );
buttonShowHidden->setToggleButton( true );
buttonShowHidden->setOn( false );
dirLabel = new QLabel(this, "DirLabel");
dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak);
dirLabel->setText(currentDir.canonicalPath());
ListView = new QtrListView( this, "ListView" );
ListView->addColumn( tr( "Name" ) );
ListView->setSorting( 2, FALSE);
ListView->addColumn( tr( "Size" ) );
ListView->setSelectionMode(QListView::Single);
ListView->setAllColumnsShowFocus( TRUE );
ListView->setColumnWidthMode(0, QListView::Manual);
ListView->setColumnWidthMode(1, QListView::Manual);
// signals and slots connections
connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) );
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) );
- connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
- connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
- connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
- connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
+ connect( ListView, SIGNAL(doubleClicked(QListViewItem*)), SLOT(listDoubleClicked(QListViewItem*)) );
+ connect( ListView, SIGNAL(clicked(QListViewItem*)), SLOT(listClicked(QListViewItem*)) );
+ connect( ListView, SIGNAL(OnOKButton(QListViewItem*)), SLOT(listClicked(QListViewItem*)) );
+ connect( ListView, SIGNAL(OnCentreButton(QListViewItem*)), SLOT(listClicked(QListViewItem*)) );
connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) );
QVBoxLayout* grid = new QVBoxLayout(this);
QHBoxLayout* hgrid = new QHBoxLayout(grid);
hgrid->addWidget(dirLabel,1);
hgrid->addWidget(buttonShowHidden);
hgrid->addWidget(buttonOk);
grid->addWidget(ListView,1);
if (allownew)
{
m_filename = new QLineEdit(this);
grid->addWidget(m_filename);
connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() ));
}
else
{
m_filename = NULL;
}
if (QFileInfo(iPath).exists())
{
currentDir.setPath(iPath);
#ifdef _WINDOWS
_chdir(iPath.latin1());
#else
chdir(iPath.latin1());
#endif
}
else
{
currentDir.setPath(QDir::currentDirPath());
chdir(QDir::currentDirPath().latin1());
}
populateList();
if (modal)
QPEApplication::showDialog( this );
}
void fileBrowser::resizeEvent(QResizeEvent* e)
{
ListView->setColumnWidth(1,(ListView->width())/4);
ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1));
}
fileBrowser::~fileBrowser()
{
}
void fileBrowser::populateList()
{
ListView->clear();
////qDebug(currentDir.canonicalPath());
// currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks );
currentDir.setFilter( filterspec );
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
currentDir.setNameFilter(filterStr);
// currentDir.setNameFilter("*.txt;*.etx");
QString fileL, fileS;
const QFileInfoList *list = currentDir.entryInfoList();
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) )
{
if (fi->fileName() != ".")
{
fileS.sprintf( "%10li", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
if( fi->isDir() )
{
fileL+="/";
}
else
{
//// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
}
new QListViewItem( ListView,fileL,fileS );
}
++it;
}
ListView->setSorting( 2, FALSE);
dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
ListView->setFocus();
}
void fileBrowser::upDir()
{
//// qDebug(currentDir.canonicalPath());
}
void fileBrowser::listClicked(QListViewItem *selectedItem)
{
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp
index 1fb2a3d..061748e 100644
--- a/noncore/apps/opie-sheet/mainwindow.cpp
+++ b/noncore/apps/opie-sheet/mainwindow.cpp
@@ -1,142 +1,142 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
* Opie Sheet (formerly Sheet/Qt)
* by Serdar Ozler <sozler@sitebest.com>
*/
#include "mainwindow.h"
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qmessagebox.h>
#include <qradiobutton.h>
#include "cellformat.h"
#include "numberdlg.h"
#include "textdlg.h"
#include "sortdlg.h"
#include "finddlg.h"
#define DEFAULT_NUM_ROWS 300
#define DEFAULT_NUM_COLS (26*3)
#define DEFAULT_NUM_SHEETS 3
MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl)
:QMainWindow(parent, n, fl)
{
// initialize variables
documentModified=FALSE;
// construct objects
currentDoc=0;
fileSelector=new FileSelector("application/sheet-qt", this, QString::null);
ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE);
connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide()));
- connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &)));
- connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &)));
- connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &)));
+ connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&)));
+ connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&)));
+ connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&)));
connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide()));
listSheets.setAutoDelete(TRUE);
initActions();
initMenu();
initEditToolbar();
initFunctionsToolbar();
initStandardToolbar();
initSheet();
// set window title
setCaption(tr("Opie Sheet"));
// create sheets
selectorFileNew(DocLnk());
}
MainWindow::~MainWindow()
{
if (currentDoc) delete currentDoc;
}
void MainWindow::documentSave(DocLnk *lnkDoc)
{
FileManager fm;
QByteArray streamBuffer;
QDataStream stream(streamBuffer, IO_WriteOnly);
typeSheet *currentSheet=findSheet(sheet->getName());
if (!currentSheet)
{
QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!"));
return;
}
sheet->copySheetData(&currentSheet->data);
stream.writeRawBytes("SQT100", 6);
stream << (Q_UINT32)listSheets.count();
for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next())
{
stream << tempSheet->name << (Q_UINT32)tempSheet->data.count();
for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next())
stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data;
}
lnkDoc->setType("application/sheet-qt");
if (!fm.saveFile(*lnkDoc, streamBuffer))
{
QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!"));
return;
}
documentModified=FALSE;
}
void MainWindow::documentOpen(const DocLnk &lnkDoc)
{
FileManager fm;
QByteArray streamBuffer;
if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer))
{
QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!"));
documentModified=FALSE;
selectorFileNew(DocLnk());
return;
}
QDataStream stream(streamBuffer, IO_ReadOnly);
Q_UINT32 countSheet, countCell, i, j, row, col, alignment;
typeSheet *newSheet;
typeCellData *newCell;
char fileFormat[7];
stream.readRawBytes(fileFormat, 6);
fileFormat[6]=0;
if ((QString)fileFormat!="SQT100")
{
QMessageBox::critical(this, tr("Error"), tr("Invalid file format!"));
documentModified=FALSE;
selectorFileNew(DocLnk());
return;
}
stream >> countSheet;
for (i=0; i<countSheet; ++i)
{
newSheet=new typeSheet;
newSheet->data.setAutoDelete(TRUE);
stream >> newSheet->name >> countCell;
comboSheets->insertItem(newSheet->name);
for (j=0; j<countCell; ++j)
{
newCell=new typeCellData;
stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data;
newCell->col=col;
@@ -487,253 +487,253 @@ void MainWindow::initMenu()
addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig);
addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig);
addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig);
addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig);
addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig);
addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig);
submenuFuncTrig->insertSeparator();
addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig);
addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig);
addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig);
addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig);
addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig);
addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig);
submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig);
submenuFuncString=new QPopupMenu;
addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString);
addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString);
addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString);
addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString);
submenuFuncString->insertSeparator();
addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString);
addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString);
addFlyAction(tr("FIND(what,where,pos)"),
tr("FIND(what,where,pos)"), "FIND(",submenuFuncString);
addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString);
addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString);
submenuFuncString->insertSeparator();
addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString);
addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString);
submenuFunc->insertItem(tr("&Strings"), submenuFuncString);
submenuFuncStat=new QPopupMenu;
addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat);
addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat);
addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat);
addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat);
addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat);
addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat);
addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat);
submenuFuncStat->insertSeparator();
addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat);
addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat);
addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat);
addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat);
addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat);
addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat);
addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat);
submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat);
submenuFuncScientific=new QPopupMenu;
addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific);
addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific);
addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific);
addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific);
submenuFuncScientific->insertSeparator();
addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific);
addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific);
addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific);
addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific);
addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific);
addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific);
submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific);
submenuFuncDistr=new QPopupMenu;
addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr);
addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr);
addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr);
addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr);
addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr);
addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr);
addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr);
addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr);
submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr);
menuInsert->insertSeparator();
insertCells->addTo(menuInsert);
insertRows->addTo(menuInsert);
insertCols->addTo(menuInsert);
insertSheets->addTo(menuInsert);
}
void MainWindow::initStandardToolbar()
{
toolbarStandard=new QToolBar(this);
toolbarStandard->setHorizontalStretchable(TRUE);
moveToolBar(toolbarStandard, Top);
fileNew->addTo(toolbarStandard);
fileOpen->addTo(toolbarStandard);
fileSave->addTo(toolbarStandard);
comboSheets=new QComboBox(toolbarStandard);
toolbarStandard->setStretchableWidget(comboSheets);
- connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &)));
+ connect(comboSheets, SIGNAL(activated(const QString&)), this, SLOT(slotSheetChanged(const QString&)));
}
void MainWindow::initFunctionsToolbar()
{
toolbarFunctions=new QToolBar(this);
toolbarFunctions->setHorizontalStretchable(TRUE);
moveToolBar(toolbarFunctions, Bottom);
funcEqual->addTo(toolbarFunctions);
funcPlus->addTo(toolbarFunctions);
funcMinus->addTo(toolbarFunctions);
funcCross->addTo(toolbarFunctions);
funcDivide->addTo(toolbarFunctions);
funcParanOpen->addTo(toolbarFunctions);
funcParanClose->addTo(toolbarFunctions);
funcComma->addTo(toolbarFunctions);
toolFunction=new QToolButton(toolbarFunctions);
toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" ));
toolFunction->setTextLabel(tr("Functions"));
toolFunction->setPopup(submenuFunc);
toolFunction->setPopupDelay(0);
}
void MainWindow::initEditToolbar()
{
toolbarEdit=new QToolBar(this);
toolbarEdit->setHorizontalStretchable(TRUE);
moveToolBar(toolbarEdit, Bottom);
editAccept->addTo(toolbarEdit);
editCancel->addTo(toolbarEdit);
editData=new QLineEdit(toolbarEdit);
toolbarEdit->setStretchableWidget(editData);
connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept()));
editCellSelect->addTo(toolbarEdit);
}
void MainWindow::slotHelpAbout()
{
QDialog dialogAbout(this, 0, TRUE);
dialogAbout.resize(width()-40, height()-80);
dialogAbout.setCaption(tr("About Opie Sheet"));
QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout);
label.setGeometry(dialogAbout.rect());
label.setAlignment(Qt::AlignCenter | Qt::WordBreak);
dialogAbout.exec();
}
void MainWindow::initSheet()
{
sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this);
setCentralWidget(sheet);
- connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &)));
- connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &)));
+ connect(sheet, SIGNAL(currentDataChanged(const QString&)), editData, SLOT(setText(const QString&)));
+ connect(sheet, SIGNAL(cellClicked(const QString&)), this, SLOT(slotCellClicked(const QString&)));
connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified()));
connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut()));
connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy()));
connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear()));
}
void MainWindow::slotEditAccept()
{
sheet->setData(editData->text());
}
void MainWindow::slotEditCancel()
{
editData->setText(sheet->getData());
}
void MainWindow::slotCellSelect(bool lock)
{
sheet->lockClicks(lock);
}
void MainWindow::addToData(const QString &data)
{
editData->setText(editData->text().insert(editData->cursorPosition(), data));
}
void MainWindow::slotFuncOutput()
{
if (sender()->isA("QAction"))
addToData(((QAction *)sender())->toolTip());
}
void MainWindow::slotInsertRows()
{
NumberDialog dialogNumber(this);
if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted)
sheet->insertRows(dialogNumber.getValue());
}
void MainWindow::slotInsertCols()
{
NumberDialog dialogNumber(this);
if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted)
sheet->insertColumns(dialogNumber.getValue());
}
void MainWindow::slotInsertSheets()
{
NumberDialog dialogNumber(this);
if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted)
for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet();
}
void MainWindow::slotCellClicked(const QString &cell)
{
editCellSelect->setOn(FALSE);
addToData(cell);
}
typeSheet *MainWindow::createNewSheet()
{
typeSheet *newSheet=new typeSheet;
int currentNo=1, tempNo=0;
bool ok;
for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next())
if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok)
currentNo=tempNo+1;
newSheet->name=tr("Sheet")+QString::number(currentNo);
newSheet->data.setAutoDelete(TRUE);
comboSheets->insertItem(newSheet->name);
listSheets.append(newSheet);
return newSheet;
}
typeSheet *MainWindow::findSheet(const QString &name)
{
for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next())
if (tempSheet->name==name)
return tempSheet;
return NULL;
}
void MainWindow::slotSheetChanged(const QString &name)
{
sheet->copySheetData(&findSheet(sheet->getName())->data);
sheet->setName(name);
sheet->setSheetData(&findSheet(name)->data);
sheet->ReCalc();
}
void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w)
{
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp
index f303d33..d4419af 100644
--- a/noncore/apps/opie-sheet/sheet.cpp
+++ b/noncore/apps/opie-sheet/sheet.cpp
@@ -1,143 +1,143 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
* Opie Sheet (formerly Sheet/Qt)
* by Serdar Ozler <sozler@sitebest.com>
*/
#include "sheet.h"
#include <qmessagebox.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define DEFAULT_COL_WIDTH 50
Sheet::Sheet(int numRows, int numCols, QWidget *parent)
:QTable(numRows, numCols, parent)
{
defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine);
defaultCellData.data="";
defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern);
defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop);
defaultCellData.fontColor=Qt::black;
defaultCellData.font=font();
defaultCellData.borders=defaultBorders;
clicksLocked=FALSE;
selectionNo=-1;
setSelectionMode(QTable::Single);
sheetData.setAutoDelete(TRUE);
clipboardData.setAutoDelete(TRUE);
for (int i=0; i<numCols; ++i)
horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH);
- connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int)));
- connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int)));
+ connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int)));
+ connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int)));
}
Sheet::~Sheet()
{
}
typeCellData *Sheet::findCellData(int row, int col)
{
typeCellData *tempCellData;
for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
{
if (tempCellData->row==row && tempCellData->col==col) return tempCellData;
}
return NULL;
}
void Sheet::slotCellSelected(int row, int col)
{
typeCellData *cellData=findCellData(row, col);
if (cellData)
{
emit currentDataChanged(cellData->data);
}else
emit currentDataChanged("");
}
typeCellData *Sheet::createCellData(int row, int col)
{
if (row<0 || col<0) return NULL;
typeCellData *cellData=new typeCellData;
cellData->row=row;
cellData->col=col;
cellData->data=defaultCellData.data;
cellData->borders=defaultCellData.borders;
cellData->alignment=defaultCellData.alignment;
cellData->font=defaultCellData.font;
cellData->fontColor=defaultCellData.fontColor;
cellData->background=defaultCellData.background;
sheetData.append(cellData);
return cellData;
}
void Sheet::slotCellChanged(int row, int col)
{
typeCellData *cellData=findCellData(row, col);
if (!cellData) cellData=createCellData(row, col);
if (cellData) cellData->data=text(row, col);
for (cellData=sheetData.first(); cellData; cellData=sheetData.next())
{
// modified by Toussis Manolis koppermind@panafonet.gr
// the parser was crashing if there were no closed parenthesis.
int w1,ii=0;
for(w1=0;w1<=(int)text(row, col).length();w1++)
{
if(text(row,col)[w1]=='(') ii++;
if(text(row,col)[w1]==')') ii--;
};
if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data));
//end of modification
// old was plain:
//setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data));
};
emit sheetModified();
}
void Sheet::ReCalc(void)
{
typeCellData* cellData;
for (cellData=sheetData.first(); cellData; cellData=sheetData.next())
{
//printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col);
slotCellChanged(cellData->row,cellData->col);
};
};
void Sheet::swapCells(int row1, int col1, int row2, int col2)
{
typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2);
if (!cellData1) cellData1=createCellData(row1, col1);
if (!cellData2) cellData2=createCellData(row2, col2);
if (cellData1 && cellData2)
{
QString tempData(cellData1->data);
cellData1->data=cellData2->data;
cellData2->data=tempData;
setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data));
setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data));
emit sheetModified();
}
}
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp
index 6bb524f..90e1a70 100644
--- a/noncore/apps/opie-write/mainwindow.cpp
+++ b/noncore/apps/opie-write/mainwindow.cpp
@@ -30,345 +30,345 @@
#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()),
this, SLOT(showEditTools()) );
- QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk &)),
- this, SLOT(openFile(const DocLnk &)) );
+ QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk&)),
+ this, SLOT(openFile(const DocLnk&)) );
QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)),
this, SLOT(newFile(const DocLnk&)) );
if ( fileSelector->fileCount() < 1 )
fileNew();
else {
fileOpen();
}
doConnections( editor );
setCentralWidget( editorStack );
}
MainWindow::~MainWindow()
{
save();
}
void MainWindow::setupActions()
{
setToolBarsMovable(false);
tbMenu = new QToolBar( this );
tbMenu->setHorizontalStretchable( TRUE );
QMenuBar *menu = new QMenuBar( tbMenu );
tbEdit = new QToolBar( this );
QPopupMenu *file = new QPopupMenu( this );
menu->insertItem( tr("File"), file );
QPopupMenu *edit = new QPopupMenu( this );
menu->insertItem( tr("Edit"), edit );
// ### perhaps these shortcut keys should have some
// IPaq keys defined???
QAction *a;
a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 );
connect( a, SIGNAL(activated()), this, SLOT(fileNew()) );
a->addTo( file );
a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) );
a->addTo( file );
a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"),
QString::null, 0, this, "editUndo" );
connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) );
a->addTo( tbEdit );
a->addTo( edit );
a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"),
QString::null, 0, this, "editRedo" );
connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) );
a->addTo( tbEdit );
a->addTo( edit );
edit->insertSeparator();
a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"),
QString::null, 0, this, "editCopy" );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) );
a->addTo( tbEdit );
a->addTo( edit );
a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"),
QString::null, 0, this, "editCut" );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) );
a->addTo( tbEdit );
a->addTo( edit );
a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"),
QString::null, 0, this, "editPaste" );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( tbEdit );
a->addTo( edit );
tbFont = new QToolBar( this );
tbFont->setLabel( "Font Actions" );
tbFont->setHorizontalStretchable(TRUE);
comboFont = new QComboBox( FALSE, tbFont );
FontDatabase db;
QStringList f= db.families();
comboFont->insertStringList( db.families() );
- connect( comboFont, SIGNAL( activated( const QString & ) ),
- this, SLOT( textFamily( const QString & ) ) );
+ connect( comboFont, SIGNAL( activated(const QString&) ),
+ this, SLOT( textFamily(const QString&) ) );
comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) );
comboFont->setMaximumWidth(90);
comboSize = new QComboBox( TRUE, tbFont );
QValueList<int> sizes = db.standardSizes();
QValueList<int>::Iterator it = sizes.begin();
for ( ; it != sizes.end(); ++it )
comboSize->insertItem( QString::number( *it ) );
- connect( comboSize, SIGNAL( activated( const QString & ) ),
- this, SLOT( textSize( const QString & ) ) );
+ connect( comboSize, SIGNAL( activated(const QString&) ),
+ this, SLOT( textSize(const QString&) ) );
comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
comboSize->setFixedWidth( 38 );
tbStyle = new QToolBar( this );
tbStyle->setLabel( "Style Actions" );
actionTextBold = new QAction( tr( "Bold" ),
Resource::loadPixmap("bold"),
QString::null, CTRL + Key_B,
this, "textBold" );
connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
actionTextBold->addTo( tbStyle );
actionTextBold->setToggleAction( TRUE );
actionTextItalic = new QAction( tr( "Italic" ),
Resource::loadPixmap("italic"),
tr( "&Italic" ), CTRL + Key_I,
this, "textItalic" );
connect( actionTextItalic, SIGNAL( activated() ), this,
SLOT( textItalic() ) );
actionTextItalic->addTo( tbStyle );
actionTextItalic->setToggleAction( TRUE );
actionTextUnderline = new QAction( tr( "Underline" ),
Resource::loadPixmap("underline"),
tr( "&Underline" ), CTRL + Key_U,
this, "textUnderline" );
connect( actionTextUnderline, SIGNAL( activated() ),
this, SLOT( textUnderline() ) );
actionTextUnderline->addTo( tbStyle );
actionTextUnderline->setToggleAction( TRUE );
alignMenu = new ButtonMenu( tbStyle );
alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft );
alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter );
alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight );
alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify );
connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) );
}
Qt3::QTextEdit *MainWindow::currentEditor() const
{
return editor;
}
void MainWindow::doConnections( Qt3::QTextEdit *e )
{
- connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
- this, SLOT( fontChanged( const QFont & ) ) );
- connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
- this, SLOT( colorChanged( const QColor & ) ) );
- connect( e, SIGNAL( currentAlignmentChanged( int ) ),
- this, SLOT( alignmentChanged( int ) ) );
+ connect( e, SIGNAL( currentFontChanged(const QFont&) ),
+ this, SLOT( fontChanged(const QFont&) ) );
+ connect( e, SIGNAL( currentColorChanged(const QColor&) ),
+ this, SLOT( colorChanged(const QColor&) ) );
+ connect( e, SIGNAL( currentAlignmentChanged(int) ),
+ this, SLOT( alignmentChanged(int) ) );
}
void MainWindow::updateFontSizeCombo( const QFont &f )
{
comboSize->clear();
FontDatabase fdb;
QValueList<int> sizes = fdb.pointSizes( f.family() );
QValueList<int>::Iterator it = sizes.begin();
for ( ; it != sizes.end(); ++it )
comboSize->insertItem( QString::number( *it ) );
}
void MainWindow::editUndo()
{
if ( !currentEditor() )
return;
currentEditor()->undo();
}
void MainWindow::editRedo()
{
if ( !currentEditor() )
return;
currentEditor()->redo();
}
void MainWindow::editCut()
{
if ( !currentEditor() )
return;
currentEditor()->cut();
}
void MainWindow::editCopy()
{
if ( !currentEditor() )
return;
currentEditor()->copy();
}
void MainWindow::editPaste()
{
if ( !currentEditor() )
return;
currentEditor()->paste();
}
void MainWindow::textBold()
{
if ( !currentEditor() )
return;
currentEditor()->setBold( actionTextBold->isOn() );
}
void MainWindow::textUnderline()
{
if ( !currentEditor() )
return;
currentEditor()->setUnderline( actionTextUnderline->isOn() );
}
void MainWindow::textItalic()
{
if ( !currentEditor() )
return;
currentEditor()->setItalic( actionTextItalic->isOn() );
}
void MainWindow::textFamily( const QString &f )
{
if ( !currentEditor() )
return;
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,
diff --git a/noncore/apps/opie-write/qtextedit.cpp b/noncore/apps/opie-write/qtextedit.cpp
index 27dd515..73b7b7b 100644
--- a/noncore/apps/opie-write/qtextedit.cpp
+++ b/noncore/apps/opie-write/qtextedit.cpp
@@ -584,194 +584,194 @@ static bool block_set_alignment = FALSE;
The new alignment is \a a.
\sa setAlignment()
*/
/*! \fn void QTextEdit::cursorPositionChanged( QTextCursor *c )
This signal is emitted if the position of the cursor changed. \a c
points to the text cursor object.
\sa setCursorPosition()
*/
/*! \overload void QTextEdit::cursorPositionChanged( int para, int pos )
This signal is emitted if the position of the cursor changed. \a
para contains the paragraph index and \a pos contains the character
position within the paragraph.
\sa setCursorPosition()
*/
/*! \fn void QTextEdit::returnPressed()
This signal is emitted if the user pressed the Return or the Enter key.
*/
/*!
\fn QTextCursor *QTextEdit::textCursor() const
Returns the text edit's text cursor.
\warning QTextCursor is not in the public API, but in special
circumstances you might wish to use it.
*/
/*! Constructs an empty QTextEdit with parent \a parent and name \a
name.
*/
QTextEdit::QTextEdit( QWidget *parent, const char *name )
: QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ),
doc( new QTextDocument( 0 ) ), undoRedoInfo( doc )
{
init();
}
/*!
Constructs a QTextEdit with parent \a parent and name \a name. The
text edit will display the text \a text using context \a context.
The \a context is a path which the text edit's QMimeSourceFactory
uses to resolve the locations of files and images. It is passed to
the mimeSourceFactory() when quering data.
For example if the text contains an image tag,
\c{<img src="image.png">}, and the context is "path/to/look/in", the
QMimeSourceFactory will try to load the image from
"path/to/look/in/image.png". If the tag was
\c{<img src="/image.png">}, the context will not be used (because
QMimeSourceFactory recognizes that we have used an absolute path)
and will try to load "/image.png". The context is applied in exactly
the same way to \e hrefs, for example,
\c{<a href="target.html">Target</a>}, would resolve to
"path/to/look/in/target.html".
*/
QTextEdit::QTextEdit( const QString& text, const QString& context,
QWidget *parent, const char *name)
: QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ),
doc( new QTextDocument( 0 ) ), undoRedoInfo( doc )
{
init();
setText( text, context );
}
/*! \reimp */
QTextEdit::~QTextEdit()
{
delete undoRedoInfo.d;
undoRedoInfo.d = 0;
delete cursor;
delete doc;
delete d;
}
void QTextEdit::init()
{
setFrameStyle( Sunken );
undoEnabled = TRUE;
readonly = TRUE;
setReadOnly( FALSE );
d = new QTextEditPrivate;
- connect( doc, SIGNAL( minimumWidthChanged( int ) ),
- this, SLOT( documentWidthChanged( int ) ) );
+ connect( doc, SIGNAL( minimumWidthChanged(int) ),
+ this, SLOT( documentWidthChanged(int) ) );
mousePressed = FALSE;
inDoubleClick = FALSE;
modified = FALSE;
onLink = QString::null;
overWrite = FALSE;
wrapMode = WidgetWidth;
wrapWidth = -1;
wPolicy = AtWhiteSpace;
inDnD = FALSE;
doc->setFormatter( new QTextFormatterBreakWords );
doc->formatCollection()->defaultFormat()->setFont( QScrollView::font() );
doc->formatCollection()->defaultFormat()->setColor( colorGroup().color( QColorGroup::Text ) );
currentFormat = doc->formatCollection()->defaultFormat();
currentAlignment = Qt3::AlignAuto;
viewport()->setBackgroundMode( PaletteBase );
viewport()->setAcceptDrops( TRUE );
resizeContents( 0, doc->lastParagraph() ?
( doc->lastParagraph()->paragId() + 1 ) * doc->formatCollection()->defaultFormat()->height() : 0 );
setKeyCompression( TRUE );
viewport()->setMouseTracking( TRUE );
#ifndef QT_NO_CURSOR
viewport()->setCursor( isReadOnly() ? arrowCursor : ibeamCursor );
#endif
cursor = new QTextCursor( doc );
formatTimer = new QTimer( this );
connect( formatTimer, SIGNAL( timeout() ),
this, SLOT( formatMore() ) );
lastFormatted = doc->firstParagraph();
scrollTimer = new QTimer( this );
connect( scrollTimer, SIGNAL( timeout() ),
this, SLOT( autoScrollTimerDone() ) );
interval = 0;
changeIntervalTimer = new QTimer( this );
connect( changeIntervalTimer, SIGNAL( timeout() ),
this, SLOT( doChangeInterval() ) );
cursorVisible = TRUE;
blinkTimer = new QTimer( this );
connect( blinkTimer, SIGNAL( timeout() ),
this, SLOT( blinkCursor() ) );
#ifndef QT_NO_DRAGANDDROP
dragStartTimer = new QTimer( this );
connect( dragStartTimer, SIGNAL( timeout() ),
this, SLOT( startDrag() ) );
#endif
formatMore();
blinkCursorVisible = FALSE;
viewport()->setFocusProxy( this );
viewport()->setFocusPolicy( WheelFocus );
viewport()->installEventFilter( this );
installEventFilter( this );
}
void QTextEdit::paintDocument( bool drawAll, QPainter *p, int cx, int cy, int cw, int ch )
{
bool drawCur = hasFocus() || viewport()->hasFocus();
if ( hasSelectedText() || isReadOnly() || !cursorVisible )
drawCur = FALSE;
QColorGroup g = colorGroup();
if ( doc->paper() )
g.setBrush( QColorGroup::Base, *doc->paper() );
if ( contentsY() < doc->y() ) {
p->fillRect( contentsX(), contentsY(), visibleWidth(), doc->y(),
g.brush( QColorGroup::Base ) );
}
if ( drawAll && doc->width() - contentsX() < cx + cw ) {
p->fillRect( doc->width() - contentsX(), cy, cx + cw - doc->width() + contentsX(), ch,
g.brush( QColorGroup::Base ) );
}
p->setBrushOrigin( -contentsX(), -contentsY() );
lastFormatted = doc->draw( p, cx, cy, cw, ch, g, !drawAll, drawCur, cursor );
if ( lastFormatted == doc->lastParagraph() )
resizeContents( contentsWidth(), doc->height() );
if ( contentsHeight() < visibleHeight() && ( !doc->lastParagraph() || doc->lastParagraph()->isValid() ) && drawAll )
p->fillRect( 0, contentsHeight(), visibleWidth(),
visibleHeight() - contentsHeight(), g.brush( QColorGroup::Base ) );
}
/*! \reimp */
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp
index 5ef5454..0fe5b09 100755
--- a/noncore/apps/qashmoney/accountdisplay.cpp
+++ b/noncore/apps/qashmoney/accountdisplay.cpp
@@ -1,390 +1,390 @@
#include <qmessagebox.h>
#include <qheader.h>
#include "accountdisplay.h"
#include "newaccount.h"
#include "transaction.h"
#include "transferdialog.h"
#include "transfer.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 () ) );
+ 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 () ) );
+ 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 () ) );
+ 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 ) ) );
+ 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 * ) ) );
+ 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 ) ) );
+ 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 );
// 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();
newaccount->startdate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
//add account information if user pushes OK button
if ( newaccount->exec() == QDialog::Accepted )
{
if ( newaccount->childcheckbox->isChecked () == TRUE ) // set a parent id and type for a child account
{
// go through the parentlist we created and determine the parent accountid
// we can't use the name of the account because there may be two accounts
// with the same name. This function does it all by accountid
int counter;
for ( counter = 0; counter < listview->childCount() + 1; counter++ )
if ( ( parentlist [ counter ] [ 2 ].toInt() ) == newaccount->childbox->currentItem() )
{
parentid = parentlist [ counter ] [ 1 ].toInt();
break;
}
type = ( newaccount->accounttype->currentItem() ) + 6; // sets account ids for child accounts. See accountdisplay.h for types
}
else
{
parentid = -1;
type = newaccount->accounttype->currentItem(); // sets account ids for parent accounts
}
// add the new account
if ( newaccount->getDateEdited () == TRUE )
account->addAccount ( newaccount->accountname->text(), parentid, newaccount->accountbalance->text().toFloat(), type,
newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), newaccount->getYear(),
newaccount->getMonth(), newaccount->getDay(), newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() );
else
account->addAccount ( newaccount->accountname->text (), parentid, newaccount->accountbalance->text().toFloat(), type,
newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), defaultyear,
defaultmonth, defaultday, newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() );
if ( parentid != -1 )
account->changeParentAccountBalance ( parentid );
// redisplay accounts
// this function clears the account display first
account->displayAccounts ( listview );
setToggleButton();
}
maintabs->setTabEnabled ( tab2, FALSE );
}
void AccountDisplay::deleteAccount ()
{
if ( listview->selectedItem() == 0 )
QMessageBox::warning ( this, "QashMoney", "Please select an account\nto delete.");
else if ( listview->selectedItem()->parent() == 0 && listview->selectedItem()->childCount() != 0 )
QMessageBox::warning ( this, "QashMoney", "Can't delete parent accounts\nwith children");
else
{
QMessageBox mb ( "Delete Account", "This will delete all transactions\nand transfers for this account.", QMessageBox::Information, QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton );
if ( mb.exec() == QMessageBox::Ok )
{
int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
int parentid = account->getParentAccountID ( accountid );
// delete all the transactions and transfers for the account
transaction->deleteAllTransactions ( accountid );
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 * ) ) );
+ 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 * ) ) );
+ 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());
// 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 * ) ) );
+ 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
{
// set the accountid
int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt();
//construct new dialog box
QDialog *editaccountwindow = new QDialog ( this, 0, TRUE );
editaccountwindow->setCaption ( "Edit Account" );
// construct the items which will go in the dialog bix
QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow );
QLineEdit *accountname = new QLineEdit ( editaccountwindow );
QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow );
QLineEdit *accountdescription = new QLineEdit ( editaccountwindow );
Currency *currencybox = new Currency ( editaccountwindow );
QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 );
layout->addWidget ( namelabel );
layout->addWidget ( accountname );
layout->addWidget ( descriptionlabel );
layout->addWidget ( accountdescription );
layout->addWidget ( currencybox );
//set the account name
accountname->setText ( listview->selectedItem()->text ( 0 ) );
diff --git a/noncore/apps/qashmoney/budgetdisplay.cpp b/noncore/apps/qashmoney/budgetdisplay.cpp
index d4047bf..3fc4e6c 100755
--- a/noncore/apps/qashmoney/budgetdisplay.cpp
+++ b/noncore/apps/qashmoney/budgetdisplay.cpp
@@ -1,178 +1,178 @@
#include <qmessagebox.h>
#include <qheader.h>
#include <sqlite.h>
#include "budgetdisplay.h"
#include "budget.h"
#include "datepicker.h"
#include "transaction.h"
extern Preferences *preferences;
extern Budget *budget;
extern Transaction *transaction;
BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent )
{
QFont font = this->font();
font.setWeight ( QFont::Bold );
//set the default date to today
newDate = QDate::currentDate ();
year = newDate.year();
month = newDate.month();
day = newDate.day();
datelabel = preferences->getDate ( year, month );
setCaption ( "Budget" );
firstline = new QHBox ( this );
firstline->setSpacing ( 2 );
secondline = new QHBox ( this );
secondline->setSpacing ( 10 );
menu = new QMenuBar ( this );
menu->setFrameStyle ( QFrame::Box | QFrame::Sunken );
budgetmenu = new QPopupMenu ( this );
lineitemsmenu = new QPopupMenu ( this );
datemenu = new QPopupMenu ( this );
menu->insertItem ( "Budget", budgetmenu );
menu->insertItem ( "Line Item", lineitemsmenu );
menu->insertItem ( "Date", datemenu );
- budgetmenu->insertItem ( "New", this, SLOT ( newBudget () ), 0, 1 );
- budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget () ), 0, 2 );
- budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget () ), 0, 3 );
- lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem () ), 0, 1 );
- lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem () ), 0, 2 );
- lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem () ), 0, 3 );
+ budgetmenu->insertItem ( "New", this, SLOT ( newBudget() ), 0, 1 );
+ budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget() ), 0, 2 );
+ budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget() ), 0, 3 );
+ lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem() ), 0, 1 );
+ lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem() ), 0, 2 );
+ lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem() ), 0, 3 );
datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) );
budgetbox = new QComboBox ( firstline );
- connect ( budgetbox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentBudget ( int ) ) );
+ connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) );
budgetview = new QComboBox ( firstline );
budgetview->insertItem ( "Month" );
budgetview->insertItem ( "Year" );
- connect ( budgetview, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentView ( int ) ) );
+ connect ( budgetview, SIGNAL ( activated(int) ), this, SLOT ( setCurrentView(int) ) );
budgeted = new QLabel ( secondline );
budgeted->setFont ( font );
actual = new QLabel ( secondline );
actual->setFont ( font );
date = new QLabel ( secondline );
date->setFont ( font );
listview = new QListView ( this );
listview->setAllColumnsShowFocus ( TRUE );
listview->setShowSortIndicator ( TRUE );
listview->setRootIsDecorated ( TRUE );
listview->setMultiSelection ( FALSE );
listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13
listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14
listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15
listview->addColumn ( "", 0 ); // line item ids
listview->setColumnWidthMode ( 0, QListView::Manual );
listview->setColumnWidthMode ( 1, QListView::Manual );
listview->setColumnWidthMode ( 2, QListView::Manual );
listview->setColumnAlignment ( 1, Qt::AlignRight );
listview->setColumnAlignment ( 2, Qt::AlignRight );
listview->setColumnWidthMode ( 3, QListView::Manual );
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 ) ) );
+ connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
+ connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
// pull the column sorting preference from the preferences table, and configure the listview accordingly
int column = 0;
int direction = 0;
preferences->getSortingPreference ( 3, &column, &direction );
listview->setSorting ( column, direction );
displayBudgetNames();
layout = new QVBoxLayout ( this, 2, 2 );
layout->setMenuBar ( menu );
layout->addWidget ( firstline );
layout->addWidget ( secondline );
layout->addWidget ( listview );
}
void BudgetDisplay::deleteBudget ()
{
listview->clear();
transaction->clearBudgetIDs ( currentbudget );
budget->deleteBudget ( currentbudget );
if ( budgetbox->count() != 0 )
displayBudgetNames();
checkBudgets();
}
void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize )
{
switch ( column )
{
case 0:
preferences->changeColumnPreference ( 13, newsize );
break;
case 1:
preferences->changeColumnPreference ( 14, newsize );
break;
case 2:
preferences->changeColumnPreference ( 15, newsize );
break;
}
}
void BudgetDisplay::saveSortingPreference ( int column )
{
preferences->changeSortingPreference ( 3, column );
}
int BudgetDisplay::getIDColumn ()
{
int counter;
int columns = listview->columns();
for ( counter = 0; counter <= columns; counter++ )
if ( listview->header()->label ( counter ).length() == 0 )
return counter;
}
void BudgetDisplay::newBudget ()
{
constructBudgetWindow();
int response = nb->exec();
if ( response == 1 )
{
// open a new budget object
int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 );
transaction->clearBudgetIDs ( addedbudget );
displayBudgetNames();
}
checkBudgets();
}
void BudgetDisplay::constructBudgetWindow ()
{
//construct and format the new budget window
nb = new QDialog ( this, 0, TRUE );
nb->setCaption ( "Budget" );
QLabel *namelabel = new QLabel ( "Budget Name", nb );
budgetname = new QLineEdit ( nb );
QLabel *descriptionlabel = new QLabel ( "Description", nb );
description = new QLineEdit ( nb );
currencybox = new Currency ( nb );
QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 );
layout->addWidget ( namelabel );
layout->addWidget ( budgetname );
layout->addWidget ( descriptionlabel );
layout->addWidget ( description );
layout->addWidget ( currencybox );
}
void BudgetDisplay::displayBudgetNames ()
{
budgetbox->clear();
if ( budget->getNumberOfBudgets() != 0 )
{
ids = budget->getBudgetIDs();
for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it )
{
diff --git a/noncore/apps/qashmoney/calculator.cpp b/noncore/apps/qashmoney/calculator.cpp
index 0e0a043..2c92103 100755
--- a/noncore/apps/qashmoney/calculator.cpp
+++ b/noncore/apps/qashmoney/calculator.cpp
@@ -1,113 +1,113 @@
#include "calculator.h"
#include <qpushbutton.h>
Calculator::Calculator ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
display = new QLineEdit ( this, "display" );
display->setFrame ( FALSE );
display->setAlignment ( Qt::AlignRight );
QPushButton *one = new QPushButton ( "1", this, "one" ); // make buttons for first row
one->setFlat ( TRUE );
- connect ( one, SIGNAL ( released () ), this, SLOT ( displayOne () ) );
+ connect ( one, SIGNAL ( released() ), this, SLOT ( displayOne() ) );
QPushButton *two = new QPushButton ( "2", this, "two" );
two->setFlat ( TRUE );
- connect ( two, SIGNAL ( released () ), this, SLOT ( displayTwo () ) );
+ connect ( two, SIGNAL ( released() ), this, SLOT ( displayTwo() ) );
QPushButton *three = new QPushButton ( "3", this, "three" );
three->setFlat ( TRUE );
- connect ( three, SIGNAL ( released () ), this, SLOT ( displayThree () ) );
+ connect ( three, SIGNAL ( released() ), this, SLOT ( displayThree() ) );
QPushButton *four = new QPushButton ( "4", this, "four" ); // make buttons for second row
four->setFlat ( TRUE );
- connect ( four, SIGNAL ( released () ), this, SLOT ( displayFour () ) );
+ connect ( four, SIGNAL ( released() ), this, SLOT ( displayFour() ) );
QPushButton *five = new QPushButton ( "5", this, "five" );
five->setFlat ( TRUE );
- connect ( five, SIGNAL ( released () ), this, SLOT ( displayFive () ) );
+ connect ( five, SIGNAL ( released() ), this, SLOT ( displayFive() ) );
QPushButton *six = new QPushButton ( "6", this, "six" );
six->setFlat ( TRUE );
- connect ( six, SIGNAL ( released () ), this, SLOT ( displaySix () ) );
+ connect ( six, SIGNAL ( released() ), this, SLOT ( displaySix() ) );
QPushButton *seven = new QPushButton ( "7", this, "seven" ); // make buttons for third row
seven->setFlat ( TRUE );
- connect ( seven, SIGNAL ( released () ), this, SLOT ( displaySeven () ) );
+ connect ( seven, SIGNAL ( released() ), this, SLOT ( displaySeven() ) );
QPushButton *eight = new QPushButton ( "8", this, "eight" );
eight->setFlat ( TRUE );
- connect ( eight, SIGNAL ( released () ), this, SLOT ( displayEight () ) );
+ connect ( eight, SIGNAL ( released() ), this, SLOT ( displayEight() ) );
QPushButton *nine = new QPushButton ( "9", this, "nine" );
nine->setFlat ( TRUE );
- connect ( nine, SIGNAL ( released () ), this, SLOT ( displayNine () ) );
+ connect ( nine, SIGNAL ( released() ), this, SLOT ( displayNine() ) );
QPushButton *zero = new QPushButton ( "0", this, "zero" );
zero->setFlat ( TRUE );
- connect ( zero, SIGNAL ( released () ), this, SLOT ( displayZero () ) );
+ connect ( zero, SIGNAL ( released() ), this, SLOT ( displayZero() ) );
QPushButton *dp = new QPushButton ( ".", this, "dp" );
dp->setFlat ( TRUE );
- connect ( dp, SIGNAL ( released () ), this, SLOT ( displayPoint () ) );
+ connect ( dp, SIGNAL ( released() ), this, SLOT ( displayPoint() ) );
QPushButton *back = new QPushButton ( "<-", this, "back" );
back->setFlat ( TRUE );
- connect ( back, SIGNAL ( released () ), this, SLOT ( back () ) );
+ connect ( back, SIGNAL ( released() ), this, SLOT ( back() ) );
layout = new QGridLayout ( this, 5, 3, 5, 1, "calculatorlayout" );
layout->addMultiCellWidget ( display, 0, 0, 0, 2 );
layout->addWidget ( one, 1, 0 );
layout->addWidget ( two, 1, 1 );
layout->addWidget ( three, 1, 2 );
layout->addWidget ( four, 2, 0 );
layout->addWidget ( five, 2, 1 );
layout->addWidget ( six, 2, 2 );
layout->addWidget ( seven, 3, 0 );
layout->addWidget ( eight, 3, 1 );
layout->addWidget ( nine, 3, 2 );
layout->addWidget ( zero, 4, 0 );
layout->addWidget ( dp, 4, 1 );
layout->addWidget ( back, 4, 2 );
}
void Calculator::displayOne ()
{ display->insert ( "1" ); }
void Calculator::displayTwo ()
{ display->insert ( "2" ); }
void Calculator::displayThree ()
{ display->insert ( "3" ); }
void Calculator::displayFour ()
{ display->insert ( "4" ); }
void Calculator::displayFive ()
{ display->insert ( "5" ); }
void Calculator::displaySix ()
{ display->insert ( "6" ); }
void Calculator::displaySeven ()
{ display->insert ( "7" ); }
void Calculator::displayEight ()
{ display->insert ( "8" ); }
void Calculator::displayNine ()
{ display->insert ( "9" ); }
void Calculator::displayZero ()
{ display->insert ( "0" ); }
void Calculator::displayPoint ()
{ display->insert ( "." ); }
void Calculator::back ()
{ display->backspace(); }
diff --git a/noncore/apps/qashmoney/datepicker.cpp b/noncore/apps/qashmoney/datepicker.cpp
index 02fbcf3..7997c0b 100755
--- a/noncore/apps/qashmoney/datepicker.cpp
+++ b/noncore/apps/qashmoney/datepicker.cpp
@@ -1,95 +1,95 @@
#include "datepicker.h"
DatePicker::DatePicker ( QDate entrydate ) : QDialog ( 0, 0, TRUE )
{
setCaption ( "Select Date" );
date = entrydate;
day = date.day();
month = date.month();
year = date.year();
daylabel = new QLabel ( "Day", this );
monthlabel = new QLabel ( "Month", this );
yearlabel = new QLabel ( "Year", this );
daybox = new QComboBox ( this, "daybox" );
- connect ( daybox, SIGNAL ( activated ( int ) ), this, SLOT ( setDay ( int ) ) );
+ connect ( daybox, SIGNAL ( activated(int) ), this, SLOT ( setDay(int) ) );
displayDays ( daybox );
monthbox = new QComboBox ( this, "monthbox" );
- connect ( monthbox, SIGNAL ( activated ( int ) ), this, SLOT ( setMonth ( int ) ) );
+ connect ( monthbox, SIGNAL ( activated(int) ), this, SLOT ( setMonth(int) ) );
displayMonths ( monthbox );
yearbox = new QComboBox ( this, "yearbox" );
- connect ( yearbox, SIGNAL ( activated ( int ) ), this, SLOT ( setYear ( int ) ) );
+ connect ( yearbox, SIGNAL ( activated(int) ), this, SLOT ( setYear(int) ) );
displayYears ( yearbox );
layout = new QGridLayout ( this, 2, 3, 5, 5, "datepickerlayout" );
layout->addWidget ( daylabel, 0, 2 );
layout->addWidget ( monthlabel, 0, 1 );
layout->addWidget ( yearlabel, 0, 0 );
layout->addWidget ( daybox, 1, 2 );
layout->addWidget ( monthbox, 1, 1 );
layout->addWidget ( yearbox, 1, 0 );
}
void DatePicker::displayDays ( QComboBox *daybox )
{
int counter;
int days = date.daysInMonth();
for ( counter = 1; counter <= days; counter++ )
daybox->insertItem ( QString::number ( counter ) );
daybox->setCurrentItem ( ( date.day() ) - 1 );
}
void DatePicker::displayMonths ( QComboBox *monthbox )
{
int counter;
for ( counter = 1; counter <= 12; counter++ )
monthbox->insertItem ( QString::number ( counter ) );
monthbox->setCurrentItem ( ( date.month() ) - 1 );
}
void DatePicker::displayYears ( QComboBox *yearbox )
{
int counter;
int indexcounter = 0;
int yearindex = 0;
int year = date.year();
for ( counter = ( year - 1 ); counter <= ( year + 1 ); counter++ )
{
yearbox->insertItem ( QString::number ( counter ) );
if ( date.year() == counter )
yearindex = indexcounter;
indexcounter ++;
}
yearbox->setCurrentItem ( yearindex );
}
void DatePicker::setDay ( int index )
{
day = daybox->text ( index ).toInt();
}
void DatePicker::setMonth ( int index )
{
month = monthbox->text( index ).toInt();
}
void DatePicker::setYear ( int index )
{
year = yearbox->text ( index ).toInt();
}
int DatePicker::getDay ()
{ return day; }
int DatePicker::getMonth ()
{ return month; }
int DatePicker::getYear ()
{ return year; }
diff --git a/noncore/apps/qashmoney/memorydialog.cpp b/noncore/apps/qashmoney/memorydialog.cpp
index e9ebd54..ba11540 100755
--- a/noncore/apps/qashmoney/memorydialog.cpp
+++ b/noncore/apps/qashmoney/memorydialog.cpp
@@ -1,86 +1,86 @@
#include "memorydialog.h"
#include "memory.h"
#include <qmessagebox.h>
extern Memory *memory;
MemoryDialog::MemoryDialog () : QDialog ( 0, 0, TRUE )
{
setCaption ( tr ( "Edit Memory" ) );
listbox = new QListBox ( this, "listbox" );
memory->displayMemoryItems ( listbox );
listbox->clearSelection();
secondline = new QHBox ( this );
newbutton = new QPushButton ( secondline );
newbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/new.png") );
- connect ( newbutton, SIGNAL ( released () ), this, SLOT ( addItem () ) );
+ connect ( newbutton, SIGNAL ( released() ), this, SLOT ( addItem() ) );
editbutton = new QPushButton ( secondline );
editbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
- connect ( editbutton, SIGNAL ( released () ), this, SLOT ( editItem () ) );
+ connect ( editbutton, SIGNAL ( released() ), this, SLOT ( editItem() ) );
deletebutton = new QPushButton( secondline );
deletebutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/delete.png") );
- connect ( deletebutton, SIGNAL ( released () ), this, SLOT ( deleteItem () ) );
+ connect ( deletebutton, SIGNAL ( released() ), this, SLOT ( deleteItem() ) );
lineedit = new QLineEdit ( this );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( listbox );
layout->addWidget ( secondline );
layout->addWidget ( lineedit );
}
MemoryDialog::~MemoryDialog()
{
}
void MemoryDialog::addItem ()
{
if ( lineedit->text().length() != 0 )
{
memory->addMemoryItem ( lineedit->text() );
listbox->clear ();
memory->displayMemoryItems ( listbox );
listbox->clearFocus();
listbox->clearSelection ();
lineedit->clear();
}
}
void MemoryDialog::editItem ()
{
if ( listbox->currentItem() != -1 )
{
lineedit->setText ( listbox->currentText() );
memory->deleteMemoryItem ( listbox->currentText() );
listbox->clear ();
memory->displayMemoryItems ( listbox );
listbox->clearSelection();
}
else
QMessageBox::warning ( this, "QashMoney", "Please select an item to edit." );
}
void MemoryDialog::deleteItem ()
{
if ( listbox->currentItem() != -1 )
{
memory->deleteMemoryItem ( listbox->currentText() );
listbox->clear ();
memory->displayMemoryItems ( listbox );
listbox->clearSelection();
}
else
QMessageBox::warning ( this, "QashMoney", "Please select an item to delete." );
}
diff --git a/noncore/apps/qashmoney/newaccount.cpp b/noncore/apps/qashmoney/newaccount.cpp
index 7e57a18..5932182 100755
--- a/noncore/apps/qashmoney/newaccount.cpp
+++ b/noncore/apps/qashmoney/newaccount.cpp
@@ -1,180 +1,180 @@
#include "newaccount.h"
#include "calculator.h"
#include "datepicker.h"
#include <qmultilineedit.h>
extern Preferences *preferences;
NewAccount::NewAccount ( QWidget *parent, const char *name, bool modal ) : QDialog ( parent, name, modal )
{
accountdescription = "";
dateedited = FALSE;
setCaption( tr( "Account" ) );
namelabel = new QLabel ( "Account Name", this );
accountbox = new QHBox ( this );
accountname = new QLineEdit ( accountbox );
descriptionbutton = new QPushButton ( accountbox );
descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) );
datelabel = new QLabel ( "Date", this );
datebox = new QHBox ( this );
startdate = new QLineEdit ( datebox );
startdate->setDisabled ( TRUE );
datebutton = new QPushButton ( datebox );
datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
childcheckbox = new QCheckBox ( this );
childcheckbox->setText( tr ( "Child Account" ) );
childlabel = new QLabel ( "Child of", this );
childbox = new QComboBox ( FALSE, this );
hideChildPulldownMenu ();
balancelabel = new QLabel ( "Balance", this );
balancebox = new QHBox ( this );
accountbalance = new QLineEdit ( balancebox );
accountbalance->setText ( "0.00" );
balancecalculator = new QPushButton( balancebox );
balancecalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
creditlimitlabel = new QLabel ( "Credit Limit", this );
creditlimitbox = new QHBox ( this );
creditlimit = new QLineEdit ( creditlimitbox );
creditlimitbox->setEnabled ( FALSE );
creditlimitcalculator = new QPushButton( creditlimitbox );
creditlimitcalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
currencybox = new Currency ( this );
typelabel = new QLabel ( "Type", this );
accounttype = new QComboBox ( FALSE, this );
accounttype->insertItem( tr( "Bank" ) );
accounttype->insertItem( tr( "Cash" ) );
accounttype->insertItem( tr( "Credit Card" ) );
accounttype->insertItem( tr( "Equity" ) );
accounttype->insertItem( tr( "Asset" ) );
accounttype->insertItem( tr( "Liability" ) );
layout = new QGridLayout ( this, 7, 2, 4, 2 );
layout->addWidget ( namelabel , 0, 0, Qt::AlignLeft );
layout->addWidget ( accountbox, 1, 0, Qt::AlignLeft );
layout->addWidget ( datelabel, 2, 0, Qt::AlignLeft );
layout->addWidget ( datebox, 3, 0, Qt::AlignLeft );
layout->addWidget ( childcheckbox, 4, 0, Qt::AlignLeft );
layout->addWidget ( childlabel, 5, 0, Qt::AlignLeft );
layout->addWidget ( childbox, 6, 0, Qt::AlignLeft );
layout->addWidget ( balancelabel, 0, 1, Qt::AlignLeft );
layout->addWidget ( balancebox, 1, 1, Qt::AlignLeft );
layout->addWidget ( creditlimitlabel, 2, 1, Qt::AlignLeft );
layout->addWidget ( creditlimitbox, 3, 1, Qt::AlignLeft );
layout->addWidget ( currencybox, 4, 1, Qt::AlignLeft );
layout->addWidget ( typelabel, 5, 1, Qt::AlignLeft );
layout->addWidget ( accounttype, 6, 1, Qt::AlignLeft );
- connect ( childcheckbox, SIGNAL ( clicked () ), this, SLOT ( showChildPulldownMenu() ) );
+ connect ( childcheckbox, SIGNAL ( clicked() ), this, SLOT ( showChildPulldownMenu() ) );
connect ( balancecalculator, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
connect ( creditlimitcalculator, SIGNAL ( released() ), this, SLOT ( showCreditLimitCalculator() ) );
- connect ( accounttype, SIGNAL ( activated ( int ) ), this, SLOT ( activateCreditLimit ( int ) ) );
- connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
- connect ( descriptionbutton, SIGNAL ( released () ), this, SLOT ( addAccountDescription() ) );
+ connect ( accounttype, SIGNAL ( activated(int) ), this, SLOT ( activateCreditLimit(int) ) );
+ connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
+ connect ( descriptionbutton, SIGNAL ( released() ), this, SLOT ( addAccountDescription() ) );
}
NewAccount::~NewAccount ()
{
}
void NewAccount::showChildPulldownMenu ()
{
if ( childcheckbox->isChecked() == TRUE )
{
childlabel->setEnabled ( TRUE );
childbox->setEnabled ( TRUE );
}
else
hideChildPulldownMenu();
}
void NewAccount::hideChildPulldownMenu ()
{
childlabel->setEnabled ( FALSE );
childbox->setEnabled ( FALSE );
}
void NewAccount::showCalculator ()
{
Calculator *calculator = new Calculator ( this );
calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
if ( calculator->exec () == QDialog::Accepted )
accountbalance->setText ( calculator->display->text() );
}
void NewAccount::showCreditLimitCalculator ()
{
Calculator *calculator = new Calculator ( this );
calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
if ( calculator->exec () == QDialog::Accepted )
creditlimit->setText ( calculator->display->text() );
}
void NewAccount::activateCreditLimit ( int index )
{
if ( index == 2 || index == 5 )
creditlimitbox->setEnabled ( TRUE );
else
{
creditlimit->clear ();
creditlimitbox->setEnabled ( FALSE );
}
}
void NewAccount::showCalendar ()
{
QDate newDate = QDate::currentDate ();
DatePicker *dp = new DatePicker ( newDate );
dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
int response = dp->exec();
if ( response == QDialog::Accepted )
{
// Set date integers
year = dp->getYear();
month = dp->getMonth();
day = dp->getDay();
// Set dateedited to TRUE
// This tells the accountdisplay object that the user edited an account
// and did change the date
dateedited = TRUE;
// Display date with our selected format
startdate->setText ( preferences->getDate ( year, month, day ) );
}
}
bool NewAccount::getDateEdited ()
{
return dateedited;
}
int NewAccount::getDay ()
{
return day;
}
int NewAccount::getMonth ()
{
return month;
}
int NewAccount::getYear ()
{
return year;
}
QString NewAccount::getDescription ()
{
diff --git a/noncore/apps/qashmoney/newtransaction.cpp b/noncore/apps/qashmoney/newtransaction.cpp
index 5c78139..87b7f7e 100755
--- a/noncore/apps/qashmoney/newtransaction.cpp
+++ b/noncore/apps/qashmoney/newtransaction.cpp
@@ -1,184 +1,184 @@
#include "newtransaction.h"
#include "calculator.h"
#include "datepicker.h"
#include "budget.h"
#include <qmultilineedit.h>
extern Budget *budget;
extern Preferences *preferences;
NewTransaction::NewTransaction ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
transactiondescription = "";
currentlineitem = -1;
currentbudget = -1;
dateedited = FALSE;
setCaption( tr( "Transaction" ) );
// START FIRST COLUMN
namelabel = new QLabel ( "Transaction", this );
transactionnamebox = new QHBox ( this );
transactionname = new QComboBox ( transactionnamebox );
transactionname->setEditable ( TRUE );
descriptionbutton = new QPushButton ( transactionnamebox );
descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) );
- connect ( descriptionbutton, SIGNAL ( released () ), this, SLOT ( addTransactionDescription() ) );
+ connect ( descriptionbutton, SIGNAL ( released() ), this, SLOT ( addTransactionDescription() ) );
amountlabel = new QLabel ( "Amount", this );
transactionamountbox = new QHBox ( this );
transactionamount = new QLineEdit ( transactionamountbox );
transactionamount->setAlignment ( Qt::AlignRight );
transactionamount->setText ( "0.00" );
calculatorbutton = new QPushButton( transactionamountbox );
calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
datelabel = new QLabel ( "Date", this );
transactiondatebox = new QHBox ( this );
transactiondate = new QLineEdit ( transactiondatebox );
transactiondate->setAlignment ( Qt::AlignRight );
transactiondate->setDisabled ( TRUE );
datebutton = new QPushButton( transactiondatebox );
datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
- connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
+ connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
clearedcheckbox = new QCheckBox ( "Cleared", this );
depositbox = new QCheckBox ( "Credit", this );
// START SECOND COLUMN
numberlabel = new QLabel ( "Number", this );
transactionnumber = new QLineEdit ( this );
budgetlabel = new QLabel ( "Budget", this );
budgetbox = new QComboBox ( FALSE, this );
lineitemlabel = new QLabel ( "LineItem", this );
lineitembox = new QComboBox ( FALSE, this );
layout = new QGridLayout ( this, 7, 2, 2, 2 );
layout->addWidget ( namelabel, 0, 0, Qt::AlignLeft );
layout->addWidget ( transactionnamebox, 1, 0, Qt::AlignLeft );
layout->addWidget ( amountlabel, 2, 0, Qt::AlignLeft );
layout->addWidget ( transactionamountbox, 3, 0, Qt::AlignLeft );
layout->addWidget ( datelabel, 4, 0, Qt::AlignLeft );
layout->addWidget ( transactiondatebox, 5, 0, Qt::AlignLeft );
layout->addWidget ( clearedcheckbox, 6, 0, Qt::AlignLeft );
layout->addWidget ( numberlabel, 0, 1, Qt::AlignLeft );
layout->addWidget ( transactionnumber, 1, 1, Qt::AlignLeft );
layout->addWidget ( budgetlabel, 2, 1, Qt::AlignLeft );
layout->addWidget ( budgetbox, 3, 1, Qt::AlignLeft );
layout->addWidget ( lineitemlabel, 4, 1, Qt::AlignLeft );
layout->addWidget ( lineitembox, 5, 1, Qt::AlignLeft );
layout->addWidget ( depositbox, 6, 1, Qt::AlignLeft );
if ( budget->getNumberOfBudgets() != 0 )
{
budgetnameslist = budget->getBudgetNames();
budgetidslist = budget->getBudgetIDs();
budgetbox->insertStringList ( *budgetnameslist );
lineitemlabel->setEnabled ( FALSE );
lineitembox->setEnabled ( FALSE );
- connect ( budgetbox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentBudget ( int ) ) );
- connect ( lineitembox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentLineItem ( int ) ) );
+ connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) );
+ connect ( lineitembox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentLineItem(int) ) );
}
else
{
budgetlabel->setEnabled ( FALSE );
budgetbox->setEnabled ( FALSE );
lineitemlabel->setEnabled ( FALSE );
lineitembox->setEnabled ( FALSE );
}
}
NewTransaction::~NewTransaction ()
{
}
void NewTransaction::showCalculator ()
{
Calculator *calculator = new Calculator ( this );
calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
if ( calculator->exec () == QDialog::Accepted )
transactionamount->setText ( calculator->display->text() );
}
void NewTransaction::showCalendar ()
{
QDate newDate = QDate::currentDate ();
DatePicker *dp = new DatePicker ( newDate );
dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
int response = dp->exec();
if ( response == QDialog::Accepted )
{
// Set date integers
year = dp->getYear();
month = dp->getMonth();
day = dp->getDay();
// Set dateedited to TRUE
// This tells the transactiondisplay object that the user edited an transaction
// and did change the date3
dateedited = TRUE;
// Display date with our selected format
transactiondate->setText ( preferences->getDate ( year, month, day ) );
}
}
bool NewTransaction::getDateEdited ()
{
return dateedited;
}
int NewTransaction::getDay ()
{
return day;
}
int NewTransaction::getMonth ()
{
return month;
}
int NewTransaction::getYear ()
{
return year;
}
QString NewTransaction::getDescription ()
{
return transactiondescription;
}
void NewTransaction::setDescription ( QString description )
{
transactiondescription = description;
}
void NewTransaction::addTransactionDescription ()
{
// Function for adding or editing an transaction description.
QDialog *description = new QDialog ( this, "description", TRUE );
description->setCaption ( "Notes" );
QMultiLineEdit *enter = new QMultiLineEdit ( description );
enter->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
enter->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
enter->setWordWrap ( QMultiLineEdit::WidgetWidth );
if ( transactiondescription != "(NULL)" )
enter->setText ( transactiondescription );
if ( description->exec () == QDialog::Accepted )
transactiondescription = enter->text ();
}
int NewTransaction::getNameIndex ( QString name )
{
int counter;
int items = transactionname->count();
diff --git a/noncore/apps/qashmoney/preferencedialogs.cpp b/noncore/apps/qashmoney/preferencedialogs.cpp
index 5408a5b..b83c957 100755
--- a/noncore/apps/qashmoney/preferencedialogs.cpp
+++ b/noncore/apps/qashmoney/preferencedialogs.cpp
@@ -1,216 +1,216 @@
#include "preferencedialogs.h"
#include "preferences.h"
extern Preferences *preferences;
DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
setCaption( tr( "Date" ) );
QLabel *datelabel = new QLabel ( "Format", this );
dateformat = new QComboBox ( this );
dateformat->setEditable ( FALSE );
dateformat->insertItem ( "yyyymmdd" );
dateformat->insertItem ( "yymmdd" );
dateformat->insertItem ( "mmddyyyy" );
dateformat->insertItem ( "mmddyy" );
dateformat->insertItem ( "yyyyddmm" );
dateformat->insertItem ( "yyddmm" );
dateformat->insertItem ( "ddmmyyyy" );
dateformat->insertItem ( "ddmmyy" );
- connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) );
+ connect ( dateformat, SIGNAL ( activated(int) ), this, SLOT ( changeDateFormat(int) ) );
QLabel *dateseparatorlabel = new QLabel ( "Separator", this );
dateseparator = new QComboBox ( this );
dateseparator->insertItem ( "/" );
dateseparator->insertItem ( "-" );
dateseparator->insertItem ( "." );
- connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) );
+ connect ( dateseparator, SIGNAL ( activated(int) ), this, SLOT ( changeDateSeparator(int) ) );
defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
- connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) );
+ connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultDatePreferences() ) );
dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( datelabel );
layout->addWidget ( dateformat );
layout->addWidget ( dateseparatorlabel );
layout->addWidget ( dateseparator );
layout->insertSpacing ( 4, 5 );
layout->addWidget ( defaults );
}
DatePreferences::~DatePreferences ()
{
}
void DatePreferences::changeDateFormat ( int index )
{
index ++;
preferences->changePreference ( 1, index );
}
void DatePreferences::changeDateSeparator ( int index )
{
index ++;
preferences->changePreference ( 2, index );
}
void DatePreferences::setDefaultDatePreferences ()
{
preferences->setDefaultDatePreferences ();
dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
}
// START TRANSACTION PREFERENCES
TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
setCaption( tr ( "Transaction" ) );
showclearedtransactions = new QCheckBox ( this );
showclearedtransactions->setText ( "Show Cleared Transactions" );
limittransactionsbox = new QHBox ( this );
limittransactionsbox->setSpacing ( 2 );
limittransactionslabel = new QLabel ( "Show ", limittransactionsbox );
limittransactions = new QComboBox ( limittransactionsbox );
QLabel *limittransactionslabel2 = new QLabel ( "of cleared transactions. ", limittransactionsbox );
limittransactions->insertItem ( "14 days" );
limittransactions->insertItem ( "30 days" );
limittransactions->insertItem ( "90 days" );
limittransactions->insertItem ( "180 days" );
limittransactions->insertItem ( "365 days" );
limittransactions->insertItem ( "All" );
limittransactions->setCurrentItem ( preferences->getPreference ( 7 ) );
excludetransfers = new QCheckBox ( this );
excludetransfers->setText ( "Include Transfers In Limit View" );
if ( preferences->getPreference ( 3 ) == 1 )
showclearedtransactions->setChecked ( TRUE );
else
showclearedtransactions->setChecked ( FALSE );
if ( preferences->getPreference ( 6 ) == 1 )
excludetransfers->setChecked ( TRUE );
else
excludetransfers->setChecked ( FALSE );
defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
- connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) );
+ connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultTransactionPreferences() ) );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( showclearedtransactions );
layout->addWidget ( limittransactionsbox );
layout->addWidget ( excludetransfers );
layout->insertSpacing ( 3, 5 );
layout->addWidget ( defaults );
- connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) );
- connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) );
- connect ( limittransactions, SIGNAL ( activated ( int ) ), this, SLOT ( changeLimitTransactionsPreference ( int ) ) );
+ connect ( showclearedtransactions, SIGNAL ( toggled(bool) ), this, SLOT ( changeShowClearedPreference(bool) ) );
+ connect ( excludetransfers, SIGNAL ( toggled(bool) ), this, SLOT ( changeExcludeTranfersPreference(bool) ) );
+ connect ( limittransactions, SIGNAL ( activated(int) ), this, SLOT ( changeLimitTransactionsPreference(int) ) );
}
TransactionPreferences::~TransactionPreferences ()
{
}
void TransactionPreferences::changeLimitTransactionsPreference ( int pref )
{
preferences->changePreference ( 7, pref );
}
void TransactionPreferences::changeShowClearedPreference ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 3, 1 );
else
preferences->changePreference ( 3, 0 );
}
void TransactionPreferences::changeExcludeTranfersPreference ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 6, 1 );
else
preferences->changePreference ( 6, 0 );
}
void TransactionPreferences::setDefaultTransactionPreferences ()
{
preferences->changePreference ( 3, 0 );
preferences->changePreference ( 6, 0 );
preferences->changePreference ( 7, 0 );
showclearedtransactions->setChecked ( FALSE );
limittransactions->setCurrentItem ( 0 );
}
// START ACCOUNT PREFERNCES
AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
{
setCaption( tr ( "Account" ) );
currencysupport = new QCheckBox ( this );
currencysupport->setText ( "Enable Currency Support" );
onetouch = new QCheckBox ( this );
onetouch->setText ( "One Touch Account Viewing" );
if ( preferences->getPreference ( 4 ) == 1 )
currencysupport->setChecked ( TRUE );
else
currencysupport->setChecked ( FALSE );
if ( preferences->getPreference ( 5 ) == 1 )
onetouch->setChecked ( TRUE );
else
onetouch->setChecked ( FALSE );
defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
- connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) );
+ connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultAccountPreferences() ) );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( currencysupport );
layout->addWidget ( onetouch );
layout->insertSpacing ( 2, 5 );
layout->addWidget ( defaults );
- connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) );
- connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) );
+ connect ( currencysupport, SIGNAL ( toggled(bool) ), this, SLOT ( changeCurrencySupport(bool) ) );
+ connect ( onetouch, SIGNAL ( toggled(bool) ), this, SLOT ( changeOneTouchViewing(bool) ) );
}
AccountPreferences::~AccountPreferences ()
{
}
void AccountPreferences::changeCurrencySupport ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 4, 1 );
else
preferences->changePreference ( 4, 0 );
}
void AccountPreferences::changeOneTouchViewing ( bool state )
{
if ( state == TRUE )
preferences->changePreference ( 5, 1 );
else
preferences->changePreference ( 5, 0 );
}
void AccountPreferences::setDefaultAccountPreferences ()
{
preferences->changePreference ( 4, 0 );
preferences->changePreference ( 5, 0 );
currencysupport->setChecked ( FALSE );
onetouch->setChecked ( FALSE );
}
diff --git a/noncore/apps/qashmoney/qashmoney.cpp b/noncore/apps/qashmoney/qashmoney.cpp
index d4cbc14..1455eb0 100755
--- a/noncore/apps/qashmoney/qashmoney.cpp
+++ b/noncore/apps/qashmoney/qashmoney.cpp
@@ -1,166 +1,166 @@
#include "qashmoney.h"
#include "preferencedialogs.h"
#include "memorydialog.h"
#include <qheader.h>
Budget *budget = new Budget ();
Preferences *preferences = new Preferences ();
Account *account = new Account ();
Transaction *transaction = new Transaction ();
Transfer *transfer = new Transfer ();
Memory *memory = new Memory ();
QashMoney::QashMoney () : QWidget ()
{
preferences->addPreferences ();
preferences->initializeColumnPreferences ();
preferences->initializeSortingPreferences ();
// set the text in the upper part of the frame
setCaption ( tr ( "QashMoney" ) );
// Create new menubar for our mainwindow
// and add menu items
mainmenu = new QMenuBar ( this );
mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
preferencesmenu = new QPopupMenu ( this );
utilitiesmenu = new QPopupMenu ( this );
mainmenu->insertItem ( "Preferences", preferencesmenu );
mainmenu->insertItem ( "Utilities", utilitiesmenu );
- preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog () ) );
- preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog () ) );
- preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog () ) );
- utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog () ) );
+ preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog() ) );
+ preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog() ) );
+ preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog() ) );
+ utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog() ) );
// create the main tabwidget for displaying accounts and transactions
maintabs = new QTabWidget ( this );
tab = new QWidget ( this );
tab_2 = new QWidget ( this );
tab_3 = new QWidget ( this );
maintabs->addTab ( tab, "Accounts" );
maintabs->addTab ( tab_2, "Transactions" );
maintabs->addTab ( tab_3, "Budgets" );
tabheight = tab->height();
maintabs->setTabEnabled ( tab_2, FALSE );
// create a new account display object
accountdisplay = new AccountDisplay ( maintabs );
accountdisplay->setTabs ( tab_2, maintabs );
- connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( setTransactionTab () ) );
+ connect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( setTransactionTab() ) );
// set the connection to disable the one touch account viewing if we are transfering money
- connect ( accountdisplay->transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( toggleOneTouchViewing ( bool ) ) );
+ connect ( accountdisplay->transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( toggleOneTouchViewing(bool) ) );
// create a new transactiondisplay object
transactiondisplay = new TransactionDisplay ( maintabs );
transactiondisplay->hide();
// create new budgetdisplay object
budgetdisplay = new BudgetDisplay ( maintabs );
budgetdisplay->hide();
tabslayout = new QVBoxLayout ( maintabs, 4, 2 );
tabslayout->addSpacing ( tabheight );
tabslayout->addWidget ( accountdisplay );
tabslayout->addWidget ( transactiondisplay );
tabslayout->addWidget ( budgetdisplay );
// connect a change in the maintabs with changing the tab display
- connect ( maintabs, SIGNAL ( currentChanged ( QWidget * ) ), this, SLOT ( changeTabDisplay () ) );
+ connect ( maintabs, SIGNAL ( currentChanged(QWidget*) ), this, SLOT ( changeTabDisplay() ) );
// create layout that will contain the menubar and the maintabs
layout = new QVBoxLayout ( this, 2, 2 );
layout->setMenuBar ( mainmenu );
layout->addWidget ( maintabs );
}
QashMoney::~QashMoney ()
{
delete budget;
delete preferences;
delete account;
delete transaction;
delete transfer;
delete memory;
}
void QashMoney::changeTabDisplay ()
{
// if the user pressed the transactions tab, hide the account display
// object and create a new transaction display
if ( maintabs->currentPageIndex() == 1 )
{
// initialize variables
bool children = FALSE;
// hide the account display and define accountid
int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
//remove all the columns from the transactiondisplay
int columns = transactiondisplay->listview->columns();
int counter;
for ( counter = 0; counter <= columns; counter++ )
transactiondisplay->listview->removeColumn ( 0 );
// set the account name and account balance
QString name = account->getAccountName ( accountid );
QString balance = account->getAccountBalance ( accountid );
transactiondisplay->name->setText ( name );
transactiondisplay->balance->setText ( balance );
// clear the limitbox
transactiondisplay->limitbox->clear();
// get parent account id
int parentaccountid = account->getParentAccountID ( accountid );
// add columns based on which account is selected
// this first if determines if we selected a parent with no children or a child
// in these cases, we add standard three columns for date, transaction, amount
transactiondisplay->listview->addColumn ( "Date", 0 );
transactiondisplay->listview->addColumn ( "Transaction", 0 );
transactiondisplay->listview->addColumn ( "Amt", 0);
transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight );
transactiondisplay->listview->addColumn ( "", 0 );
if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children
{
// add an extra column for the account name for eac child transaction
transactiondisplay->listview->addColumn ( "Acct", 0 );
children = TRUE;
// hide the new transaction button
transactiondisplay->newtransaction->setEnabled ( FALSE );
}
else //we selected a parent without children or a child
transactiondisplay->newtransaction->setEnabled ( TRUE );
// disable the transactionid column so it can't be red
transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 );
// set the accountid and children variables
transactiondisplay->setChildren ( children );
transactiondisplay->setAccountID ( accountid );
setTransactionDisplayDate ();
// display transactions
transactiondisplay->listview->clear();
QString displaytext = "%";
displaytext.prepend ( transactiondisplay->limitbox->text() );
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
// display transfers
transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
// open a new preferences object and resize the transaction display columns
// each column will have a different size based on whether we are looking at a child
// account or children through a parent
if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns
{
transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width
transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual );
transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width
transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual );
@@ -259,144 +259,144 @@ void QashMoney::displayDatePreferencesDialog ()
// set children so we can let displayTransfers know if there are children for the selected account
bool children;
if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
children = TRUE;
else
children = FALSE;
// redisplay transactions if they are visible incorporating
// any changes to the date format
transactiondisplay->listview->clear();
QString displaytext = "%";
displaytext.prepend ( transactiondisplay->limitbox->text() );
setTransactionDisplayDate();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
if ( transfer->getNumberOfTransfers() != 0 )
transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
}
else if ( accountdisplay->isVisible() )
{
accountdisplay->listview->clearSelection();
maintabs->setTabEnabled ( tab_2, FALSE );
}
else
budgetdisplay->updateBudgetInformation();
}
void QashMoney::displayTransactionPreferencesDialog ()
{
// display a dialog for setting preferences for transactions
TransactionPreferences *td = new TransactionPreferences ( this );
td->exec ();
if ( transactiondisplay->isVisible() )
{
// set the account id
int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
// set children so we can let displayTransfers know if there are children for the selected account
bool children;
if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
children = TRUE;
else
children = FALSE;
// redisplay transactions incorporating any transaction preference changes
transactiondisplay->listview->clear();
QString displaytext = "%";
displaytext.prepend ( transactiondisplay->limitbox->text() );
setTransactionDisplayDate();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
if ( transfer->getNumberOfTransfers() != 0 )
transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
}
else
{
accountdisplay->listview->clearSelection();
maintabs->setTabEnabled ( tab_2, FALSE );
}
}
void QashMoney::displayAccountPreferencesDialog ()
{
// display a dialog for setting preferences for accounts
AccountPreferences *ap = new AccountPreferences ( this );
ap->exec ();
if ( accountdisplay->isVisible() && account->getNumberOfAccounts() != 0 )
{
accountdisplay->listview->clear();
account->displayAccounts ( accountdisplay->listview );
accountdisplay->listview->clearSelection();
maintabs->setTabEnabled ( tab_2, FALSE );
}
changeTabDisplay();
}
void QashMoney::displayMemoryDialog ()
{
// opens a dialog to add, edit and delete memory items
MemoryDialog *md = new MemoryDialog ();
md->exec();
}
void QashMoney::showTransactions ()
{
maintabs->setCurrentPage ( 1 );
}
void QashMoney::enableOneTouchViewing ()
{
if ( preferences->getPreference ( 5 ) == 1 )
- connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) );
+ connect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) );
else
- disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) );
+ disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) );
}
void QashMoney::disableOneTouchViewing ()
{
- disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) );
+ disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) );
}
void QashMoney::toggleOneTouchViewing ( bool state )
{
if ( state == TRUE )
disableOneTouchViewing();
else
enableOneTouchViewing();
}
void QashMoney::setTransactionDisplayDate ()
{
// determine how many days of transactions to show
int limittype = preferences->getPreference ( 7 );
if ( limittype != 5 ) // set today's date if we are not showing all transactions
{
QDate today = QDate::currentDate ();
switch ( limittype ) // if we are not showing all transactions
{
case 0: // viewing two weeks
newdate = today.addDays ( -14 );
break;
case 1: // viewing one month
newdate = today.addDays ( -30 );
break;
case 2: // three months
newdate = today.addDays ( -90 );
break;
case 3: // six months
newdate = today.addDays ( -180 );
break;
case 4: // one year
newdate = today.addDays ( -365 );
break;
}
}
else
newdate = QDate ( 1900, 1, 1 );
}
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
index 474f11e..0b94d62 100755
--- a/noncore/apps/qashmoney/transactiondisplay.cpp
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -1,312 +1,312 @@
#include "transactiondisplay.h"
#include "newtransaction.h"
#include "account.h"
#include "budget.h"
#include "memory.h"
#include "transfer.h"
#include "calculator.h"
#include "datepicker.h"
#include <qmessagebox.h>
#include <qheader.h>
#include <qmultilineedit.h>
extern Transaction *transaction;
extern Budget *budget;
extern Account *account;
extern Preferences *preferences;
extern Memory *memory;
extern Transfer *transfer;
TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
{
// set transactiondisplay variables;
accountid = 0;
children = TRUE;
firstline = new QHBox ( this );
firstline->setSpacing ( 2 );
newtransaction = new QPushButton ( firstline );
newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
- connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) );
+ connect ( newtransaction, SIGNAL ( released() ), this, SLOT ( addTransaction() ) );
edittransaction = new QPushButton ( firstline );
edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
- connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) );
+ connect ( edittransaction, SIGNAL ( released() ), this, SLOT ( checkListViewEdit() ) );
deletetransaction = new QPushButton ( firstline );
deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
- connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) );
+ connect ( deletetransaction, SIGNAL ( released() ), this, SLOT ( checkListViewDelete() ) );
toggletransaction = new QPushButton ( firstline );
toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") );
- connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) );
+ connect ( toggletransaction, SIGNAL ( released() ), this, SLOT ( checkListViewToggle() ) );
viewtransactionnotes = new QPushButton ( firstline );
viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") );
- connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) );
+ connect ( viewtransactionnotes, SIGNAL ( released() ), this, SLOT ( showTransactionNotes() ) );
secondline = new QHBox ( this );
secondline->setSpacing ( 5 );
name = new QLabel ( secondline );
balance = new QLabel ( secondline );
QLabel *limit = new QLabel ( "Limit", secondline );
limitbox = new QLineEdit ( secondline );
limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
- connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) );
+ connect ( limitbox, SIGNAL ( textChanged(const QString&) ), this, SLOT ( limitDisplay(const QString&) ) );
listview = new QListView ( this );
listview->setAllColumnsShowFocus ( TRUE );
listview->setShowSortIndicator ( TRUE );
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 ) ) );
+ 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, 2 );
layout->addWidget ( firstline );
layout->addWidget ( secondline );
layout->addWidget ( listview );
}
void TransactionDisplay::addTransaction ()
{
// create local variables
int cleared = -1;
// create new transaction window
NewTransaction *newtransaction = new NewTransaction ( this );
int width = this->size().width();
newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
// enter today's date in the date box as defaul
QDate today = QDate::currentDate ();
int defaultday = today.day();
int defaultmonth = today.month();
int defaultyear = today.year();
newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
// add memory items to the transactionname combobox
memory->displayMemoryItems ( newtransaction->transactionname );
newtransaction->transactionname->insertItem ( "", 0 );
if ( newtransaction->exec () == QDialog::Accepted )
{
if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction
cleared = 1;
else
cleared = 0;
float amount = newtransaction->transactionamount->text().toFloat();
if ( newtransaction->depositbox->isChecked() == FALSE )
amount = amount * -1;
// add the transaction name to the memory items
memory->addMemoryItem ( newtransaction->transactionname->currentText() );
// add the transaction
if ( newtransaction->getDateEdited () == TRUE )
transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(),
newtransaction->getCurrentLineItem() );
else
transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
// redisplay transactions
listview->clear();
QString displaytext = "%";
displaytext.prepend ( limitbox->text() );
setTransactionDisplayDate ();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
// redisplay transfers
if ( transfer->getNumberOfTransfers() > 0 )
transfer->displayTransfers ( listview, accountid, children, displaydate );
// add the transaction amount to the account it's associated with
// and update its parent account balance if necessary
account->updateAccountBalance ( accountid );
if ( account->getParentAccountID ( accountid ) != -1 )
account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
// format then reset the account balance
redisplayAccountBalance ();
}
}
void TransactionDisplay::checkListViewEdit ()
{
if ( listview->selectedItem() == 0 )
QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit.");
else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
editTransfer ();
else
editTransaction();
}
void TransactionDisplay::showCalculator ()
{
Calculator *calculator = new Calculator ( this );
if ( calculator->exec () == QDialog::Accepted )
amount->setText ( calculator->display->text() );
}
void TransactionDisplay::showCalendar ()
{
QDate newDate = QDate::currentDate ();
DatePicker *dp = new DatePicker ( newDate );
if ( dp->exec () == QDialog::Accepted )
{
year = dp->getYear();
month = dp->getMonth();
day = dp->getDay();
date->setText ( preferences->getDate ( year, month, day ) );
}
}
void TransactionDisplay::editTransfer ()
{
transferid = listview->currentItem()->text ( getIDColumn() ).toInt();
fromaccount = transfer->getFromAccountID ( transferid );
toaccount = transfer->getToAccountID ( transferid );
year = transfer->getYear ( transferid );
month = transfer->getMonth ( transferid );
day = transfer->getDay ( transferid );
QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE );
editransfer->setCaption ( "Transfer" );
QStringList accountnames = account->getAccountNames();
QStringList accountids = account->getAccountIDs();
QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer );
QFont f = this->font();
f.setWeight ( QFont::Bold );
fromaccountlabel->setFont ( f );
QComboBox *fromaccountbox = new QComboBox ( editransfer );
fromaccountbox->insertStringList ( accountnames );
fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) );
QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer );
toaccountlabel->setFont ( f );
QComboBox *toaccountbox = new QComboBox ( editransfer );
toaccountbox->insertStringList ( accountnames );
toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) );
QLabel *datelabel = new QLabel ( "Date", editransfer );
QHBox *datebox = new QHBox ( editransfer );
datebox->setSpacing ( 2 );
date = new QLineEdit ( datebox );
date->setAlignment ( Qt::AlignRight );
date->setDisabled ( TRUE );
date->setText ( preferences->getDate ( year, month, day ) );
QPushButton *datebutton = new QPushButton ( datebox );
datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
- connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
+ connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
QLabel *amounttlabel = new QLabel ( "Amount", editransfer );
QHBox *amountbox = new QHBox ( editransfer );
amountbox->setSpacing ( 2 );
amount = new QLineEdit ( amountbox );
amount->setAlignment ( Qt::AlignRight );
amount->setText ( transfer->getAmount ( transferid ) );
QPushButton *calculatorbutton = new QPushButton( amountbox );
calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer );
QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 );
layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
layout->addWidget ( fromaccountbox, Qt::AlignLeft );
layout->addWidget ( toaccountlabel, Qt::AlignLeft );
layout->addWidget ( toaccountbox, Qt::AlignLeft );
layout->addSpacing ( 5 );
layout->addWidget ( datelabel, Qt::AlignLeft );
layout->addWidget ( datebox, Qt::AlignLeft );
layout->addWidget ( amounttlabel, Qt::AlignLeft );
layout->addWidget ( amountbox, Qt::AlignLeft );
layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
if ( editransfer->exec() == QDialog::Accepted )
{
//get fromaccount
fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt();
//get to account
toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt();
//set cleared flag
int cleared = 0;
if ( clearedcheckbox->isChecked() == TRUE )
cleared = 1;
//update transfer
transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ),
day, month, year, amount->text().toFloat(), cleared, transferid );
account->updateAccountBalance ( fromaccount );
if ( account->getParentAccountID ( fromaccount ) != -1 )
account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) );
updateAndDisplay ( toaccount );
}
}
void TransactionDisplay::editTransaction ()
{
int cleared;
// set the transaction id and budgetid
int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
int budgetid = transaction->getBudgetID ( transactionid );
int lineitemid = transaction->getLineItemID ( transactionid );
// create edit transaction window
NewTransaction *newtransaction = new NewTransaction ( this );
int width = this->width();
newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
// enter the date in the date box
newtransaction->year = transaction->getYear ( transactionid );
newtransaction->month = transaction->getMonth ( transactionid );
newtransaction->day = transaction->getDay ( transactionid );
newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) );
// set the description
newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) );
// add memory items to the transactionname combobox
memory->displayMemoryItems ( newtransaction->transactionname );
// add correct transaction name
newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) );
// add transaction number
newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) );
// add transaction amount
newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) );
// check for and set the correct budget
if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item
{
newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 );
if ( lineitemid >= 1 )
diff --git a/noncore/apps/qashmoney/transferdialog.cpp b/noncore/apps/qashmoney/transferdialog.cpp
index 558abec..7a12fbf 100755
--- a/noncore/apps/qashmoney/transferdialog.cpp
+++ b/noncore/apps/qashmoney/transferdialog.cpp
@@ -1,112 +1,112 @@
#include "transferdialog.h"
#include "datepicker.h"
#include "calculator.h"
extern Preferences *preferences;
extern Account *account;
TransferDialog::TransferDialog ( QWidget *parent, int fromaccountid, int toaccountid ) : QDialog ( parent, 0, TRUE )
{
dateedited = FALSE;
setCaption ( "Transfer" );
fromaccountlabel = new QLabel ( "From account:", this );
QFont f = this->font();
f.setWeight ( QFont::Bold );
fromaccountlabel->setFont ( f );
fromaccount = new QLabel ( account->getAccountName ( fromaccountid ), this );
toaccountlabel = new QLabel ( "To Account:", this );
toaccountlabel->setFont ( f );
toaccount = new QLabel ( account->getAccountName ( toaccountid ), this );
datelabel = new QLabel ( "Date", this );
datebox = new QHBox ( this );
datebox->setSpacing ( 2 );
date = new QLineEdit ( datebox );
date->setAlignment ( Qt::AlignRight );
date->setDisabled ( TRUE );
datebutton = new QPushButton ( datebox );
datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
- connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
+ connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
amounttlabel = new QLabel ( "Amount", this );
amountbox = new QHBox ( this );
amountbox->setSpacing ( 2 );
amount = new QLineEdit ( amountbox );
amount->setAlignment ( Qt::AlignRight );
calculatorbutton = new QPushButton( amountbox );
calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
clearedcheckbox = new QCheckBox ( "Cleared", this );
layout = new QVBoxLayout ( this, 4, 2 );
layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
layout->addWidget ( fromaccount, Qt::AlignLeft );
layout->addWidget ( toaccountlabel, Qt::AlignLeft );
layout->addWidget ( toaccount, Qt::AlignLeft );
layout->addSpacing ( 5 );
layout->addWidget ( datelabel, Qt::AlignLeft );
layout->addWidget ( datebox, Qt::AlignLeft );
layout->addWidget ( amounttlabel, Qt::AlignLeft );
layout->addWidget ( amountbox, Qt::AlignLeft );
layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
}
bool TransferDialog::getDateEdited ()
{
return dateedited;
}
void TransferDialog::showCalendar ()
{
QDate newDate = QDate::currentDate ();
DatePicker *dp = new DatePicker ( newDate );
if ( dp->exec () == QDialog::Accepted )
{
// Set date integers
year = dp->getYear();
month = dp->getMonth();
day = dp->getDay();
// Set dateedited to TRUE
// This tells the accountdisplay object that the user edited an account
// and did change the date
dateedited = TRUE;
// Display date with our selected format
date->setText ( preferences->getDate ( year, month, day ) );
}
}
int TransferDialog::getDay ()
{
return day;
}
int TransferDialog::getMonth ()
{
return month;
}
int TransferDialog::getYear ()
{
return year;
}
void TransferDialog::showCalculator ()
{
Calculator *calculator = new Calculator ( this );
if ( calculator->exec () == QDialog::Accepted )
amount->setText ( calculator->display->text() );
}
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp
index f35dfcd..4c6d809 100644
--- a/noncore/apps/tableviewer/tableviewer.cpp
+++ b/noncore/apps/tableviewer/tableviewer.cpp
@@ -62,200 +62,200 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f
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(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 &)));
+ connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)),
+ this, SLOT(openDocument(const DocLnk&)));
main_layout->addWidget(menu);
main_layout->addWidget(cw);
setCentralWidget(cw);
}
/*!
Destroys the TableViewerWindow
*/
TableViewerWindow::~TableViewerWindow()
{
if(dirty)
saveDocument();
}
/*!
Opens a file dialog and loads the file specified by the dialog
*/
void TableViewerWindow::selectDocument()
{
if(dirty)
saveDocument();
current_view = FileState;
cw->raiseWidget(current_view);
fileSelector->reread();
}
void TableViewerWindow::saveDocument()
{
if(!dirty)
return;
FileManager fm;
QIODevice *dev = fm.saveFile(doc);
if(!ds->saveSource(dev, doc.type())){
qWarning("Save unsuccessful");
return;
}
dev->close();
dirty = FALSE;
}
void TableViewerWindow::newDocument()
{
DocLnk nf;
nf.setType("text/x-xml-tableviewer");
nf.setName("table");
delete ds;
ds = new DBStore();
ts.current_column = 0;
ts.kRep = ds->getKeys();
browseView->reset();
listView->reset();
filterView->reset();
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);
diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp
index 4c47951..e82018c 100644
--- a/noncore/apps/tableviewer/ui/commonwidgets.cpp
+++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp
@@ -1,136 +1,136 @@
/**********************************************************************
** 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 <qlineedit.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <qpe/datebookmonth.h>
#include <qpopupmenu.h>
#include <qspinbox.h>
#include "commonwidgets.h"
DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f )
: QToolButton(parent, name)
{
QPopupMenu *m1 = new QPopupMenu(this);
dateSelector = new DateBookMonth(m1, 0, TRUE);
m1->insertItem(dateSelector);
setPopup(m1);
setPopupDelay(0);
- connect(dateSelector, SIGNAL(dateClicked(int, int, int)),
+ connect(dateSelector, SIGNAL(dateClicked(int,int,int)),
this, SLOT(subValueChanged()));
setText(dateSelector->selectedDate().toString());
}
DateEdit::~DateEdit() {}
QDate DateEdit::date() const
{
return dateSelector->selectedDate();
}
void DateEdit::setDate(QDate d)
{
dateSelector->setDate(d.year(), d.month(), d.day());
setText(d.toString());
}
QSizePolicy DateEdit::sizePolicy() const
{
QSizePolicy sp;
sp.setHorData(QToolButton::sizePolicy().horData());
sp.setVerData(QSizePolicy::Fixed);
return sp;
}
void DateEdit::clear()
{
QDate today = QDate::currentDate();
dateSelector->setDate(today.year(), today.month(), today.day());
setText(today.toString());
}
void DateEdit::subValueChanged()
{
QDate current = dateSelector->selectedDate();
setText(current.toString());
emit valueChanged(current);
}
TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f )
: QWidget(parent, name, f)
{
QHBoxLayout *layout = new QHBoxLayout(this, 0);
layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this));
hourKey->setWrapping(true);
hourKey->setMinimumWidth(30);
hourKey->setMaximumWidth(35);
layout->addWidget(new QLabel(" : ", this));
layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this));
minuteKey->setWrapping(true);
minuteKey->setMinimumWidth(30);
minuteKey->setMaximumWidth(35);
layout->addWidget(new QLabel(" : ", this));
layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0));
secondKey->setWrapping(true);
secondKey->setMinimumWidth(30);
secondKey->setMaximumWidth(35);
layout->addWidget(ampm = new QComboBox(this));
ampm->insertItem("AM");
ampm->insertItem("PM");
layout->addStretch(-1);
clear();
connect(secondKey, SIGNAL(valueChanged(const QString&)),
this, SLOT(subValueChanged()));
connect(minuteKey, SIGNAL(valueChanged(const QString&)),
this, SLOT(subValueChanged()));
connect(hourKey, SIGNAL(valueChanged(const QString&)),
this, SLOT(subValueChanged()));
connect(ampm, SIGNAL(activated(int)),
this, SLOT(subValueChanged()));
}
TimeEdit::~TimeEdit() {}
QTime TimeEdit::time() const
{
int s,m,h;
s = secondKey->text().toInt();
m = minuteKey->text().toInt();
h = hourKey->text().toInt();
if(ampm->currentItem() == 1) {
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
index 22bac55..8a65ed1 100644
--- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp
+++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
@@ -1,123 +1,123 @@
/**********************************************************************
** 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 "tvbrowseview.h"
#include "browsekeyentry.h"
#include <qtoolbutton.h>
#include <qtextview.h>
#include <qtextbrowser.h>
#include <qlayout.h>
#include "../xmlencodeattr.h"
/*!
\class TVBrowseView
\brief The widget describing how to draw the browse view user interface
This widget allows for the user to browse through the table, one element
at a time, or search on a single key. Its main goal is to show a
single element in a readable format and make it easy for the user to
rapidly find specific elements in the table.
*/
/*!
Constructs a new TVBrowseView widget
*/
TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name,
WFlags fl )
{
if (!name)
setName("BrowseView");
// setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) );
QVBoxLayout *vlayout = new QVBoxLayout(this);
textViewDisplay = new QTextBrowser(this, "textViewDisplay");
vlayout->addWidget( textViewDisplay );
keyEntry = new TVBrowseKeyEntry(this, "keyEntry");
vlayout->addWidget( keyEntry );
/* connect the signals down */
- connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)),
- this, SIGNAL(searchOnKey(int, TVVariant)));
+ connect(keyEntry, SIGNAL(searchOnKey(int,TVVariant)),
+ this, SIGNAL(searchOnKey(int,TVVariant)));
connect(keyEntry, SIGNAL(sortChanged(int)),
this, SIGNAL(sortChanged(int)));
ts = t;
keyEntry->setTableState(t);
}
/*!
Destroys the TVBrowseView widget
*/
TVBrowseView::~TVBrowseView()
{
}
void TVBrowseView::rebuildData()
{
if(!ts)
return;
if(!ts->current_elem) {
/* also disable buttons */
textViewDisplay->setText("");
return;
}
setDisplayText(ts->current_elem);
}
/* Reset to initial state */
void TVBrowseView::reset()
{
textViewDisplay->setText("");
keyEntry->reset();
}
/*!
sets the data element to be displayed to element
*/
void TVBrowseView::setDisplayText(const DataElem *element)
{
QString rep = "";
KeyListIterator it(*ts->kRep);
while (it.current()) {
if (element->hasValidValue(it.currentKey())) {
if(it.currentKey() == ts->current_column) {
rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>"
+ encodeAttr(it.current()->name())
+ ":</FONT></B> ";
} else {
rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> ";
}
rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>";
}
++it;
}
textViewDisplay->setText(rep);
textViewDisplay->scrollToAnchor("ckey");
}
void TVBrowseView::rebuildKeys()
{
keyEntry->rebuildKeys();
}
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp
index b03e846..22f1fb7 100644
--- a/noncore/apps/tableviewer/ui/tvfilterview.cpp
+++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp
@@ -1,188 +1,188 @@
/**********************************************************************
** 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 "tvfilterview.h"
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qlayout.h>
#include <qheader.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qpe/qpeapplication.h>
TVFilterView::TVFilterView(TableState *t, QWidget* parent,
const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl)
{
if ( !name )
setName( "Filter View" );
QVBoxLayout *vlayout = new QVBoxLayout(this);
display = new QListView(this, "display");
display->addColumn("Key");
display->addColumn("Constraint");
display->addColumn("Value");
display->header()->setClickEnabled(FALSE);
display->header()->setResizeEnabled(FALSE);
vlayout->addWidget(display);
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
newFilterButton = new QPushButton(this, "new Filter");
newFilterButton->setMaximumSize(QSize(50, 32767));
newFilterButton->setText("New");
hlayout->addWidget(newFilterButton);
deleteFilterButton = new QPushButton(this, "delete Filter");
deleteFilterButton->setMaximumSize(QSize(50, 32767));
deleteFilterButton->setText("Delete");
hlayout->addWidget(deleteFilterButton);
clearFilterButton = new QPushButton(this, "delete Filter");
clearFilterButton->setMaximumSize(QSize(60, 32767));
clearFilterButton->setText("Clear All");
hlayout->addWidget(clearFilterButton);
vlayout->addLayout(hlayout);
QHBoxLayout *hlayout2 = new QHBoxLayout;
keyNameCombo = new QComboBox(FALSE, this, "key name");
keyNameCombo->setEnabled(FALSE);
hlayout2->addWidget(keyNameCombo);
QLabel *label = new QLabel(this);
label->setText("has value");
hlayout2->addWidget(label);
keyEntry = new TVFilterKeyEntry(this, "key entry");
keyEntry->setEnabled(FALSE);
vlayout->addLayout(hlayout2);
vlayout->addWidget(keyEntry);
connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() ));
connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm()));
connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms()));
connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() ));
connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() ));
connect(display, SIGNAL(selectionChanged(QListViewItem*)), this,
- SLOT(setTerm(QListViewItem *)));
+ SLOT(setTerm(QListViewItem*)));
ts = t;
current = 0;
terms.setAutoDelete(true);
do_filter = false;
#ifdef Q_WS_QWS
QPEApplication::showDialog( this );
#endif
}
/*!
Destroys the TVFilterView widget
*/
TVFilterView::~TVFilterView()
{
}
void TVFilterView::rebuildData()
{
}
void TVFilterView::reset()
{
keyNameCombo->clear();
keyIds.clear();
}
void TVFilterView::rebuildKeys()
{
int i;
if (!ts) return;
if(!ts->kRep) return;
keyEntry->setTableState(ts);
/* set up the list of keys that can be compared on */
keyNameCombo->clear();
KeyListIterator it(*ts->kRep);
i = 0;
while(it.current()) {
if(ts->kRep->validIndex(it.currentKey())) {
keyNameCombo->insertItem(it.current()->name());
keyIds.insert(i, it.currentKey());
++i;
}
++it;
}
}
bool TVFilterView::passesFilter(DataElem *d) {
if (!filterActive()) return true;
FilterTerm *t;
for (t = terms.first(); t != 0; t = terms.next() ) {
/* check against filter */
switch(t->ct) {
case ct_less:
if (!d->lessThan(t->keyIndex, t->value))
return false;
break;
case ct_more:
if (!d->moreThan(t->keyIndex, t->value))
return false;
break;
case ct_equal:
if (!d->equalTo(t->keyIndex, t->value))
return false;
break;
case ct_contains:
if (!d->contains(t->keyIndex, t->value))
return false;
break;
case ct_startswith:
if (!d->startsWith(t->keyIndex, t->value))
return false;
break;
case ct_endswith:
if (!d->endsWith(t->keyIndex, t->value))
return false;
break;
default:
qWarning("TVFilterView::passesFilter() "
"unrecognized filter type");
return false;
}
}
return true;
}
bool TVFilterView::filterActive() const
{
/* when button operated, also check the do_filter value
diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp
index b25e813..b10ff1d 100644
--- a/noncore/apps/tableviewer/ui/tvlistview.cpp
+++ b/noncore/apps/tableviewer/ui/tvlistview.cpp
@@ -11,194 +11,194 @@
** 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"
#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(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");
}
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(
diff --git a/noncore/apps/tinykate/libkate/document/katedialogs.cpp b/noncore/apps/tinykate/libkate/document/katedialogs.cpp
index 2f0ed7b..f4edd7e 100644
--- a/noncore/apps/tinykate/libkate/document/katedialogs.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedialogs.cpp
@@ -1,162 +1,162 @@
/***************************************************************************
katedialogs.cpp - description
-------------------
copyright : (C) 2001 by The Kate Team
(C) 2002 by Joseph Wenninger
email : kwrite-devel@kde.org
jowenn@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "katedialogs.h"
#include <klocale.h>
#include <kdebug.h>
#include <qgroupbox.h>
#include <qvgroupbox.h>
#include <qhgroupbox.h>
#include <qhbox.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qwidgetstack.h>
#include <qlabel.h>
#include <qlistview.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qcheckbox.h>
//FIXME #include <kcharsets.h>
#include <kglobal.h>
#include <qmap.h>
#include <kmessagebox.h>
#include <kstddirs.h>
/*******************************************************************************************************************
* Context Editor *
*******************************************************************************************************************/
StyleChanger::StyleChanger( QWidget *parent )
: QWidget(parent)
{
QLabel *label;
QGridLayout *glay = new QGridLayout( this, 4, 3, 0, KDialog::spacingHint() );
CHECK_PTR(glay);
glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better
glay->setColStretch( 2, 10 );
col = new KColorButton(this);
CHECK_PTR(col);
- connect(col,SIGNAL(changed(const QColor &)),this,SLOT(changed()));
+ connect(col,SIGNAL(changed(const QColor&)),this,SLOT(changed()));
label = new QLabel(col,i18n("Normal:"),this);
CHECK_PTR(label);
glay->addWidget(label,0,0);
glay->addWidget(col,1,0);
selCol = new KColorButton(this);
CHECK_PTR(selCol);
- connect(selCol,SIGNAL(changed(const QColor &)),this,SLOT(changed()));
+ connect(selCol,SIGNAL(changed(const QColor&)),this,SLOT(changed()));
label = new QLabel(selCol,i18n("Selected:"),this);
CHECK_PTR(label);
glay->addWidget(label,2,0);
glay->addWidget(selCol,3,0);
bold = new QCheckBox(i18n("Bold"),this);
CHECK_PTR(bold);
connect(bold,SIGNAL(clicked()),SLOT(changed()));
glay->addWidget(bold,1,2);
italic = new QCheckBox(i18n("Italic"),this);
CHECK_PTR(italic);
connect(italic,SIGNAL(clicked()),SLOT(changed()));
glay->addWidget(italic,2,2);
}
void StyleChanger::setRef(ItemStyle *s) {
style = s;
col->setColor(style->col);
selCol->setColor(style->selCol);
bold->setChecked(style->bold);
italic->setChecked(style->italic);
}
void StyleChanger::setEnabled(bool enable) {
col->setEnabled(enable);
selCol->setEnabled(enable);
bold->setEnabled(enable);
italic->setEnabled(enable);
}
void StyleChanger::changed() {
if (style) {
style->col = col->color();
style->selCol = selCol->color();
style->bold = bold->isChecked();
style->italic = italic->isChecked();
}
}
HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList,
HlDataList *highlightDataList,
int hlNumber, QWidget *parent,
const char *name, bool modal )
:KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok)
{
// QVBox *page = makeVBoxMainWidget();
QFrame *page=addPage("FIXME");
(new QVBoxLayout(page))->setAutoAdd(true);
content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page);
}
void HighlightDialog::done(int r)
{
kdDebug(13010)<<"HighlightDialod done"<<endl;
content->saveData();
KDialogBase::done(r);
}
HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList,
HlDataList* highlightDataList,
int hlNumber,QWidget *parent, const char *name)
:QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L)
{
// defaults =========================================================
QFrame *page1 = new QFrame(this);
addTab(page1,i18n("&Defaults"));
QGridLayout *grid = new QGridLayout(page1, 1, 1);
QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 );
/*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 );
QComboBox *styleCombo = new QComboBox( false, dvbox1 );
defaultStyleChanger = new StyleChanger( dvbox1 );
for( int i = 0; i < hlManager->defaultStyles(); i++ ) {
styleCombo->insertItem(hlManager->defaultStyleName(i));
}
connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int)));
grid->addWidget(dvbox1, 0,0);
defaultChanged(0);
// highlight modes =====================================================
QFrame *page2 = new QFrame(this);
addTab(page2,i18n("&Highlight Modes"));
//grid = new QGridLayout(page2,2,2);
QVBoxLayout *bl=new QVBoxLayout(page2);
bl->setAutoAdd(true);
QHGroupBox *hbox1 = new QHGroupBox( i18n("Config Select"), page2 );
@@ -193,193 +193,193 @@ HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *st
styleDefault = new QCheckBox(i18n("Default"), vbox2 );
connect(styleDefault,SIGNAL(clicked()),SLOT(changed()));
styleChanger = new StyleChanger( vbox2 );
hlDataList = highlightDataList;
hlChanged(hlNumber);
}
void HighlightDialogPage::defaultChanged(int z)
{
defaultStyleChanger->setRef(defaultItemStyleList->at(z));
}
void HighlightDialogPage::hlChanged(int z)
{
writeback();
hlData = hlDataList->at(z);
wildcards->setText(hlData->wildcards);
mimetypes->setText(hlData->mimetypes);
itemCombo->clear();
for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L;
itemData = hlData->itemDataList.next()) {
kdDebug(13010) << itemData->name << endl;
itemCombo->insertItem(i18n(itemData->name.latin1()));
}
itemChanged(0);
}
void HighlightDialogPage::itemChanged(int z)
{
itemData = hlData->itemDataList.at(z);
styleDefault->setChecked(itemData->defStyle);
styleChanger->setRef(itemData);
}
void HighlightDialogPage::changed()
{
itemData->defStyle = styleDefault->isChecked();
}
void HighlightDialogPage::writeback() {
if (hlData) {
hlData->wildcards = wildcards->text();
hlData->mimetypes = mimetypes->text();
}
}
void HighlightDialogPage::saveData() {
kdDebug(13010)<<"HighlightDialogPage::saveData()"<<endl;
writeback();
}
void HighlightDialogPage::hlEdit() {
HlEditDialog diag(0,0,"hlEdit", true,hlData);
diag.show();
}
void HighlightDialogPage::hlNew() {
HlEditDialog diag(0,0,"hlEdit",true,0);
diag.show();
}
HlEditDialog::HlEditDialog(HlManager *,QWidget *parent, const char *name, bool modal,HlData *data)
:KDialogBase(KDialogBase::Swallow, i18n("Highlight Conditions"), Ok|Cancel, Ok, parent, name, modal)
{
currentItem=0;
transTableCnt=0;
QHBox *wid=new QHBox(this);
QVBox *lbox=new QVBox(wid);
contextList=new KListView(lbox);
contextList->setRootIsDecorated(true);
contextList->addColumn(i18n("Syntax structure"));
contextList->setSorting(-1);
QHBox *bbox=new QHBox(lbox);
QPushButton *addContext=new QPushButton(i18n("New Context"),bbox);
QPushButton *addItem=new QPushButton(i18n("New Item"),bbox);
QVGroupBox *opt = new QVGroupBox( i18n("Options"), wid);
stack=new QWidgetStack(opt);
initContextOptions(contextOptions=new QVBox(stack));
stack->addWidget(contextOptions,HlEContext);
initItemOptions(itemOptions=new QVBox(stack));
stack->addWidget(itemOptions,HlEItem);
stack->raiseWidget(HlEContext);
setMainWidget(wid);
if (data!=0) loadFromDocument(data);
else newDocument();
- connect(contextList,SIGNAL(currentChanged( QListViewItem*)),this,SLOT(currentSelectionChanged ( QListViewItem * )));
+ connect(contextList,SIGNAL(currentChanged(QListViewItem*)),this,SLOT(currentSelectionChanged(QListViewItem*)));
connect(addContext,SIGNAL(clicked()),this,SLOT(contextAddNew()));
connect(addItem,SIGNAL(clicked()),this,SLOT(ItemAddNew()));
}
void HlEditDialog::newDocument()
{
KStandardDirs *dirs = KGlobal::dirs();
QStringList list=dirs->findAllResources("data","kate/syntax/syntax.template",false,true);
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
{
HlData data("","",*it);
loadFromDocument(&data);
return;
}
KMessageBox::error(this,i18n("Can't find template file"));
}
void HlEditDialog::initContextOptions(QVBox *co)
{
if( co!=0)
{
QHBox *tmp = new QHBox(co);
(void) new QLabel(i18n("Description:"),tmp);
ContextDescr=new QLineEdit(tmp);
tmp= new QHBox(co);
(void) new QLabel(i18n("Attribute:"),tmp);
ContextAttribute=new QComboBox(tmp);
tmp= new QHBox(co);
(void) new QLabel(i18n("LineEnd:"),tmp);
ContextLineEnd = new QComboBox(tmp);
connect(ContextDescr,SIGNAL(textChanged(const QString&)),this,SLOT(contextDescrChanged(const QString&)));
connect(ContextLineEnd,SIGNAL(activated(int)),this,SLOT(contextLineEndChanged(int)));
connect(ContextAttribute,SIGNAL(activated(int)),this,SLOT(contextAttributeChanged(int)));
}
else
kdDebug(13010)<<"initContextOptions: Widget is 0"<<endl;
}
void HlEditDialog::insertTranslationList(QString tag, QString trans,int length)
{
ItemInfo data(trans,length);
id2tag.insert(transTableCnt,tag);
id2info.insert(transTableCnt,data);
tag2id.insert(tag,transTableCnt);
transTableCnt++;
}
void HlEditDialog::initItemOptions(QVBox *co)
{
if (co!=0)
{
QHBox *tmp = new QHBox(co);
(void) new QLabel(i18n("Type:"),tmp);
ItemType = new QComboBox(tmp);
tmp= new QHBox(co);
(void) new QLabel(i18n("Parameter:"),tmp);
ItemParameter= new QLineEdit(tmp);
tmp= new QHBox(co);
(void) new QLabel(i18n("Attribute:"),tmp);
ItemAttribute= new QComboBox(tmp);
(void) new QLabel(i18n("Context switch:"),tmp);
ItemContext = new QComboBox(tmp);
co->setSpacing(15);
QPushButton *delItem=new QPushButton(i18n("Delete this item"),co);
/* init translation lists */
insertTranslationList("CharDetect","CharDetect",1);
insertTranslationList("2CharDetect","2CharDetect",2);
insertTranslationList("RangeDetect","RangeDetect",2);
insertTranslationList("StringDetect","StringDetect",-1);
insertTranslationList("AnyChar","AnyChar",-1);
insertTranslationList("RegExpr","RegExpr",-1);
insertTranslationList("Int","Int",0);
insertTranslationList("Float","Float",0);
insertTranslationList("keyword","keyword",0);
insertTranslationList("dataType","dataType",0);
ItemType->clear();
for (int i=0; i<transTableCnt; i++) ItemType->insertItem(id2info[i].trans_i18n);
connect(ItemType,SIGNAL(activated(int)),this,SLOT(ItemTypeChanged(int)));
connect(ItemParameter,SIGNAL(textChanged(const QString&)),this,SLOT(ItemParameterChanged(const QString&)));
connect(ItemAttribute,SIGNAL(activated(int)),this,SLOT(ItemAttributeChanged(int)));
connect(ItemContext,SIGNAL(activated(int)),this,SLOT(ItemContextChanged(int)));
}
else
kdDebug(13010)<<"initItemOptions: Widget is 0"<<endl;
}
void HlEditDialog::loadFromDocument(HlData *hl)
{
struct syntaxContextData *data;
QListViewItem *last=0,*lastsub=0;
HlManager::self()->syntax->setIdentifier(hl->identifier);
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index f05e21a..0c742d7 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -75,193 +75,193 @@
#include "../view/kateview.h"
#include "katebuffer.h"
#include "katetextline.h"
#include "katecmd.h"
KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text)
: action(a), cursor(cursor), len(len), text(text) {
}
KateActionGroup::KateActionGroup(PointStruc &aStart, int type)
: start(aStart), action(0L), undoType(type) {
}
KateActionGroup::~KateActionGroup() {
KateAction *current, *next;
current = action;
while (current) {
next = current->next;
delete current;
current = next;
}
}
void KateActionGroup::insertAction(KateAction *a) {
a->next = action;
action = a;
}
const char * KateActionGroup::typeName(int type)
{
// return a short text description of the given undo group type suitable for a menu
// not the lack of i18n's, the caller is expected to handle translation
switch (type) {
case ugPaste : return "Paste Text";
case ugDelBlock : return "Selection Overwrite";
case ugIndent : return "Indent";
case ugUnindent : return "Unindent";
case ugComment : return "Comment";
case ugUncomment : return "Uncomment";
case ugReplace : return "Text Replace";
case ugSpell : return "Spell Check";
case ugInsChar : return "Typing";
case ugDelChar : return "Delete Text";
case ugInsLine : return "New Line";
case ugDelLine : return "Delete Line";
}
return "";
}
const int KateDocument::maxAttribs = 32;
QStringList KateDocument::searchForList = QStringList();
QStringList KateDocument::replaceWithList = QStringList();
uint KateDocument::uniqueID = 0;
QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0;
KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView,
QWidget *parentWidget, const char *widgetName,
QObject *, const char *)
: Kate::Document (),
myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()),
myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI),
hlManager(HlManager::self ())
{
d(this)->hlSetByUser = false;
PreHighlightedTill=0;
RequestPreHighlightTill=0;
m_bSingleViewMode=bSingleViewMode;
m_bBrowserView = bBrowserView;
m_url = QString::null;
// NOTE: QFont::CharSet doesn't provide all the charsets KDE supports
// (esp. it doesn't distinguish between UTF-8 and iso10646-1)
myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name());
maxLength = -1;
setFont (KGlobalSettings::generalFont());
myDocID = uniqueID;
uniqueID++;
myDocName = QString ("");
fileInfo = new QFileInfo ();
myCmd = new KateCmd (this);
- connect(this,SIGNAL(modifiedChanged ()),this,SLOT(slotModChanged ()));
+ connect(this,SIGNAL(modifiedChanged()),this,SLOT(slotModChanged()));
buffer = new KWBuffer;
connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged()));
// connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long)));
colors[0] = KGlobalSettings::baseColor();
colors[1] = KGlobalSettings::highlightColor();
m_attribs = new Attribute[maxAttribs];
m_highlight = 0L;
tabChars = 8;
m_singleSelection = false;
newDocGeometry = false;
readOnly = false;
newDoc = false;
modified = false;
undoList.setAutoDelete(true);
undoState = 0;
undoSteps = 50;
pseudoModal = 0L;
clear();
setHighlight(0); //calls updateFontData()
// if the user changes the highlight with the dialog, notify the doc
connect(hlManager,SIGNAL(changed()),SLOT(hlChanged()));
newDocGeometry = false;
readConfig();
setReadOnly(false);
}
void KateDocument::setDontChangeHlOnSave()
{
d(this)->hlSetByUser = true;
}
void KateDocument::setFont (QFont font)
{
kdDebug()<<"Kate:: setFont"<<endl;
int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
myFont = font;
myFontBold = QFont (font);
myFontBold.setBold (true);
myFontItalic = QFont (font);
myFontItalic.setItalic (true);
myFontBI = QFont (font);
myFontBI.setBold (true);
myFontBI.setItalic (true);
myFontMetrics = CachedFontMetrics (myFont);
myFontMetricsBold = CachedFontMetrics (myFontBold);
myFontMetricsItalic = CachedFontMetrics (myFontItalic);
myFontMetricsBI = CachedFontMetrics (myFontBI);
int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
updateFontData();
updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
}
long KateDocument::needPreHighlight(long till)
{
int max=numLines()-1;
if (till>max)
{
till=max;
}
if (PreHighlightedTill>=till) return -1;
long tmp=RequestPreHighlightTill;
if (RequestPreHighlightTill<till)
{
RequestPreHighlightTill=till;
if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight()));
}
return RequestPreHighlightTill;
}
void KateDocument::doPreHighlight()
{
int from = PreHighlightedTill;
int till = PreHighlightedTill+200;
int max = numLines()-1;
if (till > max)
diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
index a85fb87..8e68262 100644
--- a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
@@ -442,130 +442,130 @@ EditConfigTab::EditConfigTab(QWidget *parent, KateView *view)
encoding->insertStringList (KGlobal::charsets()->availableEncodingNames());
encoding->setCurrentItem (KGlobal::charsets()->availableEncodingNames().findIndex(view->doc()->encoding()));
#endif
leLayout->addStretch();
// What is this? help
QWhatsThis::add(opt[0], i18n("Word wrap is a feature that causes the editor to automatically start a new line of text and move (wrap) the cursor to the beginning of that new line. KateView will automatically start a new line of text when the current line reaches the length specified by the Wrap Words At: option.<p><b>NOTE:<b> Word Wrap will not change existing lines or wrap them for easy reading as in some applications."));
QWhatsThis::add(e1, i18n("If the Word Wrap option is selected this entry determines the length (in characters) at which the editor will automatically start a new line."));
QWhatsThis::add(opt[1], i18n("KateView will replace any tabs with the number of spaces indicated in the Tab Width: entry."));
QWhatsThis::add(e2, i18n("If the Replace Tabs By Spaces option is selected this entry determines the number of spaces with which the editor will automatically replace tabs."));
QWhatsThis::add(opt[2], i18n("KateView will automatically eliminate extra spaces at the ends of lines of text."));
QWhatsThis::add(opt[3], i18n("When the user types a left bracket ([,(, or {) KateView automatically enters the right bracket (}, ), or ]) to the right of the cursor."));
QWhatsThis::add(opt[4], i18n("Checking this will cause sequences of similar actions to be undone at once."));
QWhatsThis::add(opt[5], i18n("The editor will display a symbol to indicate the presence of a tab in the text."));
QWhatsThis::add(opt[6], i18n("Not yet implemented."));
QWhatsThis::add(opt[7], i18n("If this is selected, the insertion cursor will be moved to the first/last line when pressing the page up/down buttons.<p>If not selected, it will remain at it's relative position in the visible text."));
QWhatsThis::add(e3, i18n("Sets the number of undo/redo steps to record. More steps uses more memory."));
QWhatsThis::add(opt[8], i18n("When on, moving the insertion cursor using the <b>Left</b> and <b>Right</b> keys will go on to previous/next line at beginning/end of the line, similar to most editors.<p>When off, the insertion cursor cannot be moved left of the line start, but it can be moved off the line end, which can be very handy for programmers."));
}
void EditConfigTab::getData(KateView *view)
{
int configFlags, z;
configFlags = view->config();
for (z = 1; z < numFlags; z++) {
configFlags &= ~flags[z];
if (opt[z]->isChecked()) configFlags |= flags[z];
}
view->setConfig(configFlags);
view->setEncoding (encoding->currentText());
view->doc()->setWordWrapAt(e1->value());
view->doc()->setWordWrap (opt[0]->isChecked());
view->setTabWidth(e2->value());
view->setUndoSteps(e3->value());
}
ColorConfig::ColorConfig( QWidget *parent, char *name )
: QWidget( parent, name )
{
QGridLayout *glay = new QGridLayout( this, 6, 2, 0, KDialog::spacingHint());
glay->setColStretch(1,1);
glay->setRowStretch(5,1);
QLabel *label;
label = new QLabel( i18n("Background:"), this);
label->setAlignment( AlignRight|AlignVCenter );
m_back = new KColorButton( this );
glay->addWidget( label, 0, 0 );
glay->addWidget( m_back, 0, 1 );
label = new QLabel( i18n("Selected:"), this);
label->setAlignment( AlignRight|AlignVCenter );
m_selected = new KColorButton( this );
glay->addWidget( label, 2, 0 );
glay->addWidget( m_selected, 2, 1 );
// QWhatsThis help
QWhatsThis::add(m_back, i18n("Sets the background color of the editing area"));
QWhatsThis::add(m_selected, i18n("Sets the background color of the selection. To set the text color for selected text, use the &quot;<b>Configure Highlighting</b>&quot; dialog."));
}
ColorConfig::~ColorConfig()
{
}
void ColorConfig::setColors(QColor *colors)
{
m_back->setColor( colors[0] );
m_selected->setColor( colors[1] );
}
void ColorConfig::getColors(QColor *colors)
{
colors[0] = m_back->color();
colors[1] = m_selected->color();
}
FontConfig::FontConfig( QWidget *parent, char *name )
: QWidget( parent, name )
{
// sizemanagment
QGridLayout *grid = new QGridLayout( this, 1, 1 );
// QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" );
// QString styleStr = cfg. readEntry ( "FontStyle", "Regular" );
// int size = cfg. readNumEntry ( "FontSize", 10 );
// OFontSelector *m_fontselect;
m_fontselect = new Opie::OFontSelector ( false, this, "FontTab" );
// m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
// QWhatsThis::add( m_fontselect,
// tr( "Select the desired name, style and size of the default font applications will use." ) );
- connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
- this, SLOT( slotFontSelected( const QFont & )));
+ connect( m_fontselect, SIGNAL( fontSelected(const QFont&)),
+ this, SLOT( slotFontSelected(const QFont&)));
grid->addWidget( m_fontselect, 0, 0);
// #if 0
// m_fontchooser = new KFontChooser ( this );
// m_fontchooser->enableColumn(KFontChooser::StyleList, false);
// grid->addWidget( m_fontchooser, 0, 0);
-// connect (m_fontchooser, SIGNAL (fontSelected( const QFont & )), this, SLOT (slotFontSelected( const QFont & )));
+// connect (m_fontchooser, SIGNAL (fontSelected(const QFont&)), this, SLOT (slotFontSelected(const QFont&)));
// #endif
}
FontConfig::~FontConfig()
{
}
void FontConfig::setFont ( const QFont &font )
{
//#if 0
m_fontselect->setFont (font);
myFont = font;
//#endif
}
void FontConfig::slotFontSelected( const QFont &font )
{
myFont = font;
}
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 19a0127..32c1eab 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -1,141 +1,141 @@
/***************************************************************************
tinykate.cpp
Tiny KATE mainwindow
-------------------
begin : November 2002
copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
***************************************************************************/
/***************************************************************************
* *
* This program is free softwaSre; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation. *
* ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
* *
***************************************************************************/
#include <qaction.h>
#include <qtoolbutton.h>
#include <qmenubar.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <opie2/ofiledialog.h>
#include "tinykate.h"
#include <katedocument.h>
#include <kglobal.h>
TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
QMainWindow( parent, name, f )
{
shutDown=false;
nextUnnamed=0;
currentView=0;
viewCount=0;
setCaption(tr("TinyKATE"));
KGlobal::setAppName("TinyKATE");
QMenuBar *mb = new QMenuBar( this );
mb->setMargin( 0 );
tabwidget=new OTabWidget(this);
setCentralWidget(tabwidget);
- connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *)));
+ connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*)));
//FILE ACTIONS
QPopupMenu *popup = new QPopupMenu( this );
// Action for creating a new document
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
a->addTo( popup );
connect(a, SIGNAL(activated()), this, SLOT(slotNew()));
// Action for opening an exisiting document
a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
// Action for saving document
a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotSave()));
// Action for saving document to a new name
a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));
// Action for closing the currently active document
a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 );
a->addTo(popup);
connect(a, SIGNAL(activated()), this, SLOT(slotClose()));
mb->insertItem(tr("File"),popup);
//EDIT ACTIONS
// Action for cutting text
editCut = new QToolButton( 0 );
editCut->setAutoRaise( true );
editCut->setIconSet( Resource::loadPixmap( "cut" ) );
// Action for Copying text
editCopy = new QToolButton( 0 );
editCopy->setAutoRaise( true );
editCopy->setIconSet( Resource::loadPixmap( "copy" ) );
// Action for pasting text
editPaste = new QToolButton( 0 );
editPaste->setAutoRaise( true );
editPaste->setIconSet( Resource::loadPixmap( "paste" ) );
// Action for finding / replacing text
editFindReplace = new QToolButton( 0 );
editFindReplace->setAutoRaise( true );
editFindReplace->setIconSet( Resource::loadPixmap("find") );
// Action for undo
editUndo = new QToolButton( 0 );
editUndo->setAutoRaise( true );
editUndo->setIconSet( Resource::loadPixmap( "undo" ) );
// Action for redo
editRedo = new QToolButton( 0 );
editRedo->setAutoRaise( true );
editRedo->setIconSet( Resource::loadPixmap( "redo" ) );
//VIEW ACITONS
popup = new QPopupMenu( this );
viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
viewIncFontSizes->addTo( popup );
viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
viewDecFontSizes->addTo( popup );
mb->insertItem(tr("View"),popup);
popup = new QPopupMenu( this );
mb->insertItem(tr("Utils"),popup);
mb->insertItem( editCut );
mb->insertItem( editCopy );
mb->insertItem( editPaste );
mb->insertItem( editFindReplace );
mb->insertItem( editUndo );
mb->insertItem( editRedo );
//Highlight management
hlmenu=new QPopupMenu(this);
HlManager *hlm=HlManager::self();
for (int i=0;i<hlm->highlights();i++)
{
hlmenu->insertItem(hlm->hlName(i),i);
}
popup->insertItem(tr("Highlighting"),hlmenu);
diff --git a/noncore/apps/zsafe/scqtfiledlg.cpp b/noncore/apps/zsafe/scqtfiledlg.cpp
index dd72fdf..52b8d0d 100644
--- a/noncore/apps/zsafe/scqtfiledlg.cpp
+++ b/noncore/apps/zsafe/scqtfiledlg.cpp
@@ -102,155 +102,155 @@ ScQtFileDlg::ScQtFileDlg( QWidget* parent, const char* name, bool modal, WFlags
resize( 196, 279 );
if (!name)
setCaption( tr( "FileDlg" ) );
else
setCaption(name);
ScQtFileDlgLayout = new QVBoxLayout( this );
ScQtFileDlgLayout->setSpacing( 6 );
ScQtFileDlgLayout->setMargin( 11 );
Layout5 = new QVBoxLayout;
Layout5->setSpacing( 6 );
Layout5->setMargin( 0 );
Layout4 = new QVBoxLayout;
Layout4->setSpacing( 6 );
Layout4->setMargin( 0 );
Layout3 = new QHBoxLayout;
Layout3->setSpacing( 6 );
Layout3->setMargin( 0 );
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( 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( 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!" );
}
void ScQtFileDlg::slotDirComboBoxChanged( int )
{
qWarning( "ScQtFileDlg::slotDirComboBoxChanged( int ): Not implemented yet!" );
}
void ScQtFileDlg::slotDoubleClicked(QListViewItem *)
{
qWarning( "ScQtFileDlg::slotDoubleClicked(QListViewItem *): Not implemented yet!" );
}
void ScQtFileDlg::slotFileTextChanged( const QString & )
{
qWarning( "ScQtFileDlg::slotFileTextChanged( const QString & ): Not implemented yet!" );
}
void ScQtFileDlg::slotMkDir()
{
qWarning( "ScQtFileDlg::slotMkDir(): Not implemented yet!" );
}
void ScQtFileDlg::slotOK()
{
qWarning( "ScQtFileDlg::slotOK(): Not implemented yet!" );
}
void ScQtFileDlg::slotSelectionChanged(QListViewItem *)
{
qWarning( "ScQtFileDlg::slotSelectionChanged(QListViewItem *): Not implemented yet!" );
}
void ScQtFileDlg::slotTypeComboBoxChanged( int )
{
qWarning( "ScQtFileDlg::slotTypeComboBoxChanged( int ): Not implemented yet!" );
}
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index a3e805e..a3467e5 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -597,198 +597,198 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) );
cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) );
menu->insertItem( tr("&Category"), cat );
QPopupMenu *it = new QPopupMenu( this );
it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) );
it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) );
it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) );
it->insertSeparator();
it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) );
it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) );
it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) );
it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) );
menu->insertItem( tr("&Entry"), it );
QPopupMenu *help = new QPopupMenu( this );
help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) );
menu->insertItem( tr("&Help"), help );
// toolbar icons
New = new QToolButton( menu, "New" );
New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
New->setMouseTracking( TRUE );
New->setText( tr( "" ) );
New->setPixmap( new_img );
QToolTip::add( New, tr( "New entry" ) );
Edit = new QToolButton( menu, "Edit" );
Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
Edit->setText( tr( "" ) );
Edit->setPixmap( edit_img );
QToolTip::add( Edit, tr( "Edit category or entry" ) );
Delete = new QToolButton( menu, "Delete" );
Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
Delete->setText( tr( "" ) );
Delete->setPixmap( trash_img );
QToolTip::add( Delete, tr( "Delete category or entry" ) );
Find = new QToolButton( menu, "Find" );
Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
Find->setText( tr( "" ) );
Find->setPixmap( find_img );
QToolTip::add( Find, tr( "Find entry" ) );
/*
QBoxLayout * h = new QHBoxLayout( this );
h->addWidget (menu);
h->addWidget (New);
h->addWidget (Edit);
h->addWidget (Delete);
h->addWidget (Find);
*/
ListView = new ZListView( this, "ListView" );
ListView->addColumn( tr( "Name" ) );
ListView->addColumn( tr( "Field 2" ) );
ListView->addColumn( tr( "Field 3" ) );
ListView->addColumn( tr( "Comment" ) );
ListView->addColumn( tr( "Field 4" ) );
ListView->addColumn( tr( "Field 5" ) );
ListView->setAllColumnsShowFocus(TRUE);
#ifdef DESKTOP
ListView->setResizePolicy(QScrollView::AutoOneFit);
// ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
#else
ListView->setResizePolicy(QScrollView::AutoOneFit);
// ListView->setGeometry( QRect( 0, 22,
// this->width(), this->height() - 30 ) );
// ListView->setMaximumSize( QSize( 440, 290 ) );
#endif
ListView->setVScrollBarMode( QListView::Auto );
QBoxLayout * l = new QVBoxLayout( this );
l->addWidget (menu);
l->addWidget (ListView);
#ifndef DESKTOP
// start a timer (100 ms) to load the default document
docuTimer.start( 100, true );
connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) );
raiseFlag = true;
connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) );
#else
// open the default document
openDocument(filename);
#endif
// signals and slots connections for QTollButton
connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) );
connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) );
connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) );
connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) );
// signals and slots connections for QListView
- connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ),
- this, SLOT( listViewSelected( QListViewItem* ) ) );
- connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ),
- this, SLOT( showInfo( QListViewItem* ) ) );
- connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ),
- this, SLOT( showInfo( QListViewItem* ) ) );
+ connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ),
+ this, SLOT( listViewSelected(QListViewItem*) ) );
+ connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ),
+ this, SLOT( showInfo(QListViewItem*) ) );
+ connect( ListView, SIGNAL( returnPressed(QListViewItem*) ),
+ this, SLOT( showInfo(QListViewItem*) ) );
}
const QColor *ZSafe::evenRowColor = &Qt::white;
// const QColor *ZSafe::oddRowColor = &Qt::lightGray;
const QColor *ZSafe::oddRowColor = new QColor(216,240,255);
/*
* Destroys the object and frees any allocated resources
*/
ZSafe::~ZSafe()
{
// no need to delete child widgets, Qt does it all for us
quitMe();
}
// load the default document
void ZSafe::slotLoadDocu()
{
openDocument (filename);
}
void ZSafe::deletePwd()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to delete?"),
tr("&Delete"), tr("D&on't Delete"),
0 // Enter == button 0
) ) { // Escape == button 2
case 0: // Delete clicked, Alt-S or Enter pressed.
// Delete
modified = true;
selectedItem->parent()->takeItem(selectedItem);
selectedItem = NULL;
break;
case 1: // Don't delete
break;
}
}
else
{
delCategory();
}
}
void ZSafe::editPwd()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
// open the 'New Entry' dialog
NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE);
#ifdef WIN32
dialog->setCaption ("Qt " + tr("Edit Entry"));
dialog->setGeometry(200, 250, 220, 310 );
#endif
// set the labels
dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
// set the fields
dialog->NameField->setText(selectedItem->text (0));
dialog->UsernameField->setText(selectedItem->text (1));
dialog->PasswordField->setText(selectedItem->text (2));
QString comment = selectedItem->text (3);
comment.replace (QRegExp("<br>"), "\n");
dialog->Field5->setText(selectedItem->text (4));
dialog->Field6->setText(selectedItem->text (5));
dialog->CommentField->insertLine(comment);
dialog->CommentField->setCursorPosition(0,0);
DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
#ifdef DESKTOP
result = Accepted;
#endif
if (result == Accepted)
{
modified = true;
// edit the selected item
QString name = dialog->NameField->text();
selectedItem->setText (0, tr (name));
QString user = dialog->UsernameField->text();
selectedItem->setText (1, tr (user));
QString pwd = dialog->PasswordField->text();
@@ -2486,194 +2486,194 @@ int ZSafe::saveFinalize(void)
Krc2* krc2 = new Krc2();
/* Tack on the PKCS 5 padding
* How it works is we fill up the last n bytes with the value n
*
* So, if we have, say, 13 bytes, 8 of which are used, we have 5 left
* over, leaving us 3 short, so we fill it in with 3's.
*
* If we come out even, we fill it with 8 8s
*
* um, except that in this instance we are using 4 shorts instead of 8 bytes.
* so, half everything
*/
for (count1 = bufferIndex; count1 < 4; count1++) {
plaintext[count1] = (4 - bufferIndex);
}
krc2->rc2_encrypt (plaintext);
for (count1 = 0; count1 < 4; count1++) {
ciphertext[count1] = iv[count1] ^ plaintext[count1];
if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA;
if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA;
}
fclose (fd);
free(buffer);
return retval;
}
void ZSafe::quitMe ()
{
qWarning ("QUIT...");
if (modified)
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to save\nbefore exiting?"),
tr("&Save"),
tr("S&ave with\nnew\npassword"),
tr("&Don't Save"),
0 // Enter == button 0
) )
{ // Escape == button 2
case 0: // Save clicked, Alt-S or Enter pressed.
// save
modified = false;
saveDocument(filename, FALSE);
exitZs (1);
break;
case 1: //
// Save with new password
modified = false;
saveDocument(filename, TRUE);
exitZs (1);
break;
case 2: // Don't Save clicked or Alt-D pressed
// don't save but exitZs
exitZs (1);
break;
}
}
exitZs (1);
}
void ZSafe::categoryFieldActivated( const QString& category)
{
if (categoryDialog)
setCategoryDialogFields(categoryDialog, category);
}
void ZSafe::addCategory()
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return;
}
else
{
// open the 'Category' dialog
bool initIcons = false;
// open the 'Category' dialog
CategoryDialog *dialog;
if (categoryDialog)
{
dialog = categoryDialog;
}
else
{
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
#ifdef WIN32
categoryDialog->setCaption ("Qt " + tr("Category"));
#endif
dialog = categoryDialog;
connect( dialog->CategoryField,
- SIGNAL( activated ( const QString &)),
- this, SLOT( categoryFieldActivated( const QString & ) ) );
+ SIGNAL( activated(const QString&)),
+ this, SLOT( categoryFieldActivated(const QString&) ) );
initIcons = true;
}
#ifdef DESKTOP
#ifndef WIN32
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
int n = 1;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
QStringList::Iterator it = list.begin();
QString categ;
QString firstCategory;
dialog->CategoryField->clear(); // remove all items
while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
{
#ifdef DESKTOP
#ifndef WIN32
categ = cat->section ("-field1", 0, 0);
#else
int pos = cat->find ("-field1");
categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
categ = *cat;
#endif
if (!categ.isEmpty())
{
dialog->CategoryField->insertItem (categ, -1);
if (firstCategory.isEmpty())
firstCategory = categ;
}
}
++it;
}
if (firstCategory.isEmpty())
setCategoryDialogFields(dialog);
else
setCategoryDialogFields(dialog, firstCategory);
// CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE);
if (initIcons)
{
Wait waitDialog(this, tr("Wait dialog"));
waitDialog.waitLabel->setText(tr("Gathering icons..."));
waitDialog.show();
qApp->processEvents();
#ifdef DESKTOP
QDir d(iconPath);
#else
QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
d.setFilter( QDir::Files);
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
dialog->IconField->insertItem("predefined");
while ( (fi=it.current()) ) { // for each file...
@@ -2893,194 +2893,194 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment")));
dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4")));
dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5")));
QString icon;
Category *cat= categories.find (category);
if (cat)
{
icon = cat->getIconName();
}
else
icon = conf->readEntry(APP_KEY+category);
#ifdef DESKTOP
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;
}
}
}
void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
{
QString app_key = APP_KEY;
#ifndef DESKTOP
conf->setGroup ("fieldDefs");
#else
#ifndef WIN32
app_key += "/fieldDefs/";
#endif
#endif
QString category = dialog->CategoryField->currentText();
// #ifndef WIN32
conf->writeEntry(app_key+category+"-field1", dialog->Field1->text());
conf->writeEntry(app_key+category+"-field2", dialog->Field2->text());
conf->writeEntry(app_key+category+"-field3", dialog->Field3->text());
conf->writeEntry(app_key+category+"-field4", dialog->Field4->text());
conf->writeEntry(app_key+category+"-field5", dialog->Field5->text());
conf->writeEntry(app_key+category+"-field6", dialog->Field6->text());
// #endif
saveConf();
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
}
void ZSafe::editCategory()
{
if (!selectedItem)
return;
if (isCategory(selectedItem))
{
QString category = selectedItem->text(0);
bool initIcons = false;
// open the 'Category' dialog
CategoryDialog *dialog;
if (categoryDialog)
{
dialog = categoryDialog;
}
else
{
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
#ifdef WIN32
categoryDialog->setCaption ("Qt " + tr("Category"));
#endif
dialog = categoryDialog;
connect( dialog->CategoryField,
- SIGNAL( activated ( const QString &)),
- this, SLOT( categoryFieldActivated( const QString & ) ) );
+ SIGNAL( activated(const QString&)),
+ this, SLOT( categoryFieldActivated(const QString&) ) );
initIcons = true;
}
setCategoryDialogFields(dialog);
#ifdef DESKTOP
#ifndef WIN32
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
int n = 1;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
QStringList::Iterator it = list.begin();
QString categ;
dialog->CategoryField->clear(); // remove all items
int i=0;
bool foundCategory = false;
while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
{
#ifdef DESKTOP
#ifndef WIN32
categ = cat->section ("-field1", 0, 0);
#else
int pos = cat->find ("-field1");
categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
categ = *cat;
#endif
if (!categ.isEmpty())
{
dialog->CategoryField->insertItem (categ, i);
if (category.compare(categ) == 0)
{
dialog->CategoryField->setCurrentItem(i);
foundCategory = true;
}
i++;
}
}
++it;
}
if (!foundCategory)
{
dialog->CategoryField->insertItem (category, i);
dialog->CategoryField->setCurrentItem(i);
}
QString icon;
Category *cat= categories.find (selectedItem->text(0));
if (cat)
{
icon = cat->getIconName();
}
if (initIcons)
{
Wait waitDialog(this, tr("Wait dialog"));
waitDialog.waitLabel->setText(tr("Gathering icons..."));
waitDialog.show();
qApp->processEvents();
#ifdef DESKTOP
QDir d(iconPath);