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,245 +1,245 @@
/***************************************************************************
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");
}
else if( !fi->isReadable() ) {
pm = Resource::loadPixmap( "locked" );
}
else { //everything else goes by mimetype
MimeType mt(fi->filePath());
pm=mt.pixmap(); //sets the correct pixmap for mimetype
if(pm.isNull()) {
pm = unknownXpm;
}
}
if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
// qDebug(" overlay link image");
pm= Resource::loadPixmap( "advancedfm/symlink" );
// pm= Resource::loadPixmap( "folder" );
// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
// QPainter painter( &pm );
// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
// pm.setMask( pm.createHeuristicMask( FALSE ) );
}
item->setPixmap( 0,pm);
}
isDir=FALSE;
++it;
}
if( path.find("dev",0,TRUE) != -1) {
struct stat buf;
dev_t devT;
DIR *dir;
struct dirent *mydirent;
if((dir = opendir( path.latin1())) != NULL)
while ((mydirent = readdir(dir)) != NULL) {
lstat( mydirent->d_name, &buf);
// qDebug(mydirent->d_name);
fileL.sprintf("%s", mydirent->d_name);
devT = buf.st_dev;
fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
fileDate.sprintf("%s", ctime( &buf.st_mtime));
if( fileL.find(".") == -1 ) {
item= new QListViewItem( thisView, fileL, fileS, fileDate);
pm = unknownXpm;
item->setPixmap( 0,pm);
}
}
closedir(dir);
}
thisView->setSorting( 3,FALSE);
fillCombo( (const QString &) path );
}
void AdvancedFm::rePopulate() {
populateView();
setOtherTabCurrent();
populateView();
// int tmpTab = whichTab;
// // qDebug("%d", tmpTab);
// for(int i =1; i < 3; i++) {
// TabWidget->setCurrentWidget(i - 1);
// populateView();
// }
// TabWidget->setCurrentWidget( tmpTab - 1);
}
void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
//qWarning("listclicked");
if(selectedItem) {
QString strItem=selectedItem->text(0);
// qWarning(strItem);
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
bool isDirectory = false;
QString strItem2;
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
strItem2 = dealWithSymName((const QString&)strItem);
if(QDir(strItem2).exists() )
strItem = strItem2;
}
if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
if(QDir(strItem).exists())
isDirectory = true;
}
if( isDirectory ) {
CurrentDir()->cd( strItem, TRUE);
populateView();
CurrentView()->ensureItemVisible( CurrentView()->firstChild());
}
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
@@ -64,223 +64,223 @@ void AdvancedFm::init() {
cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
cfButton->setAutoRaise( true );
menuBar->insertItem( cfButton );
sdButton = new QToolButton( 0, "SDButton");
sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard"));
sdButton->setAutoRaise( true );
menuBar->insertItem( sdButton );
docButton = new QToolButton( 0,"docsButton");
docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
docButton->setAutoRaise( true );
menuBar->insertItem( docButton );
homeButton = new QToolButton( 0, "homeButton");
homeButton->setPixmap(Resource::loadPixmap("home"));
homeButton->setAutoRaise( true );
menuBar->insertItem( homeButton );
fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() ));
fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
fileMenu->insertSeparator();
fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() ));
fileMenu->insertSeparator();
fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() ));
fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() ));
fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
fileMenu->insertSeparator();
fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() ));
fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
fileMenu->setCheckable(TRUE);
viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab()));
viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab()));
// viewMenu->insertSeparator();
// viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
viewMenu->setCheckable(true);
viewMenu->setItemChecked( viewMenu->idAt(0), true);
viewMenu->setItemChecked( viewMenu->idAt(1), false);
s_addBookmark = tr("Bookmark Directory");
s_removeBookmark = tr("Remove Current Directory from Bookmarks");
// menuButton->insertItem("");
// customDirMenu->insertItem(tr("Add This Directory"));
// customDirMenu->insertItem(tr("Remove This Directory"));
// customDirMenu->insertSeparator();
menuButton = new MenuButton( lineBox );
menuButton->setUseLabel(false);
menuButton->setMaximumWidth( 20 );
menuButton->insertItem( s_addBookmark);
menuButton->insertItem( s_removeBookmark);
menuButton->insertSeparator();
menuButton->setFocusPolicy(NoFocus);
customDirsToMenu();
currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" );
currentPathCombo->setEditable(TRUE);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
currentPathCombo->setFocusPolicy(NoFocus);
layout->addWidget( lineBox );
TabWidget = new OSplitter( Horizontal, this, "TabWidget" );
// TabWidget = new QTabWidget( this, "TabWidget" );
layout->addWidget( TabWidget, 4 );
tab = new QWidget( TabWidget, "tab" );
tabLayout = new QGridLayout( tab );
tabLayout->setSpacing( 2);
tabLayout->setMargin( 2);
Local_View = new QListView( tab, "Local_View" );
Local_View->addColumn( tr("File"),130);
Local_View->addColumn( tr("Size"),-1);
Local_View->setColumnAlignment(1,QListView::AlignRight);
Local_View->addColumn( tr("Date"),-1);
Local_View->setColumnAlignment(2,QListView::AlignRight);
Local_View->setAllColumnsShowFocus(TRUE);
Local_View->setMultiSelection( TRUE );
Local_View->setSelectionMode(QListView::Extended);
Local_View->setFocusPolicy(StrongFocus);
Local_View->installEventFilter( this );
QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
tabLayout->addWidget( Local_View, 0, 0 );
TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1"));
// TabWidget->insertTab( tab, tr("1"));
tab_2 = new QWidget( TabWidget, "tab_2" );
tabLayout_2 = new QGridLayout( tab_2 );
tabLayout_2->setSpacing( 2);
tabLayout_2->setMargin( 2);
Remote_View = new QListView( tab_2, "Remote_View" );
Remote_View->addColumn( tr("File"),130);
Remote_View->addColumn( tr("Size"),-1);
Remote_View->setColumnAlignment(1,QListView::AlignRight);
Remote_View->addColumn( tr("Date"),-1);
Remote_View->setColumnAlignment(2,QListView::AlignRight);
Remote_View->setAllColumnsShowFocus(TRUE);
Remote_View->setMultiSelection( TRUE );
Remote_View->setSelectionMode(QListView::Extended);
Remote_View->setFocusPolicy(StrongFocus);
Remote_View->installEventFilter( this );
QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
tabLayout_2->addWidget( Remote_View, 0, 0 );
TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
TabWidget->setSizeChange( 370 );
// TabWidget->insertTab( tab_2, tr( "2"));
/* tab_3 = new QWidget( TabWidget, "tab_3" );
tabLayout_3 = new QGridLayout( tab_3 );
tabLayout_3->setSpacing( 2);
tabLayout_3->setMargin( 2);
// OFileDialog fileDialog;
// fileDialog;
// fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy
// fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow");
// OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/");
QListView *fileTree;
fileTree = new QListView( tab_3, "tree" );
tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
TabWidget->insertTab( tab_3, tr( "Remote" ) );
*/
///////////////
if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
zaurusDevice=TRUE;
else
zaurusDevice=FALSE;
if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
qDebug("not have sd");
sdButton->hide();
}
if( !StorageInfo::hasCf() ) {
qDebug("not have cf");
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
@@ -492,345 +492,345 @@ bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
if ( err != 0 ) {
QMessageBox::message("AdvancedFm",
tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
return false;
}
return true;
}
bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
if(QFileInfo(src).isDir()) {
if( copyDirectory( src, dest )) {
setOtherTabCurrent();
populateView();
return true;
}
else
return false;
}
bool success = true;
struct stat status;
QFile srcFile(src);
QFile destFile(dest);
int err=0;
int read_fd=0;
int write_fd=0;
struct stat stat_buf;
off_t offset = 0;
if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
// qWarning("open failed");
return success = false;
}
read_fd = srcFile.handle();
if(read_fd != -1) {
fstat (read_fd, &stat_buf);
if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
// qWarning("destfile open failed");
return success = false;
}
write_fd = destFile.handle();
if(write_fd != -1) {
err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
if( err == -1) {
QString msg;
switch(err) {
case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
case EINVAL: msg = "Descriptor is not valid or locked. ";
case ENOMEM: msg = "Insufficient memory to read from in_fd.";
case EIO: msg = "Unspecified error while reading from in_fd.";
};
success = false;
// qWarning(msg);
}
} else {
success = false;
}
} else {
success = false;
}
srcFile.close();
destFile.close();
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ) {
chmod( (const char *) dest, status.st_mode );
}
return success;
}
void AdvancedFm::runCommand() {
if( !CurrentView()->currentItem()) return;
QDir *thisDir = CurrentDir();
QString curFile;
curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
//QString command;
if( fileDlg->result() == 1 ) {
// qDebug(fileDlg->LineEdit1->text());
QStringList command;
command << "/bin/sh";
command << "-c";
command << fileDlg->LineEdit1->text();
Output *outDlg;
outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
QPEApplication::execDialog( outDlg );
qApp->processEvents();
}
}
void AdvancedFm::runCommandStd() {
if( !CurrentView()->currentItem()) return;
QString curFile;
QDir *thisDir = CurrentDir();
QListView *thisView = CurrentView();
if( thisView->currentItem())
curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
qApp->processEvents();
startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
}
}
void AdvancedFm::fileStatus() {
if( !CurrentView()->currentItem()) return;
QString curFile;
curFile = CurrentView()->currentItem()->text(0);
QStringList command;
command << "/bin/sh";
command << "-c";
command << "stat -l "+ curFile;
Output *outDlg;
outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
QPEApplication::execDialog( outDlg );
qApp->processEvents();
}
void AdvancedFm::mkDir() {
makeDir();
}
void AdvancedFm::rn() {
renameIt();
}
void AdvancedFm::del() {
doDelete();
}
void AdvancedFm::mkSym() {
QString cmd;
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
QDir *thisDir = CurrentDir();
QDir * thatDir = OtherDir();
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString destName = thatDir->canonicalPath()+"/"+(*it);
if(destName.right(1) == "/") {
destName = destName.left( destName.length() -1);
}
QString curFile = thisDir->canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") {
curFile = curFile.left( curFile.length() -1);
}
cmd = "ln -s "+curFile+" "+destName;
// qDebug(cmd);
startProcess( (const QString)cmd );
}
rePopulate();
setOtherTabCurrent();
}
}
void AdvancedFm::doBeam() {
Ir ir;
if(!ir.supported()) {
} else {
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString curFile = (*it);
QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
if( curFilePath.right(1) == "/") {
curFilePath = curFilePath.left( curFilePath.length() -1);
}
Ir *file = new Ir(this, "IR");
- connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
+ 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();
}
void AdvancedFm::renameIt() {
if( !CurrentView()->currentItem()) return;
QListView *thisView = CurrentView();
oldName = thisView->currentItem()->text(0);
doRename( thisView );
}
void AdvancedFm::okRename() {
if( !CurrentView()->currentItem()) return;
QString newName = renameBox->text();
cancelRename();
QListView * view = CurrentView();
QString path = CurrentDir()->canonicalPath() + "/";
oldName = path + oldName;
newName = path + newName;
if( rename( oldName.latin1(), newName.latin1())== -1)
QMessageBox::message(tr("Note"),tr("Could not rename"));
else
oldName = "";
view->takeItem( view->currentItem() );
delete view->currentItem();
rePopulate();
}
void AdvancedFm::openSearch() {
QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
}
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 7dc2416..0bba1d8 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,276 +1,276 @@
/****************************************************************************
** outputEdit.cpp
**
** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
****************************************************************************/
#include "output.h"
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
#include <qfile.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <errno.h>
/* XPM */
static char * filesave_xpm[] = {
"16 16 78 1",
" c None",
". c #343434",
"+ c #A0A0A0",
"@ c #565656",
"# c #9E9E9E",
"$ c #525252",
"% c #929292",
"& c #676767",
"* c #848484",
"= c #666666",
"- c #D8D8D8",
"; c #FFFFFF",
"> c #DBDBDB",
", c #636363",
"' c #989898",
") c #2D2D2D",
"! c #909090",
"~ c #AEAEAE",
"{ c #EAEAEA",
"] c #575757",
"^ c #585858",
"/ c #8A8A8A",
"( c #828282",
"_ c #6F6F6F",
": c #C9C9C9",
"< c #050505",
"[ c #292929",
"} c #777777",
"| c #616161",
"1 c #3A3A3A",
"2 c #BEBEBE",
"3 c #2C2C2C",
"4 c #7C7C7C",
"5 c #F6F6F6",
"6 c #FCFCFC",
"7 c #6B6B6B",
"8 c #959595",
"9 c #4F4F4F",
"0 c #808080",
"a c #767676",
"b c #818181",
"c c #B8B8B8",
"d c #FBFBFB",
"e c #F9F9F9",
"f c #CCCCCC",
"g c #030303",
"h c #737373",
"i c #7A7A7A",
"j c #7E7E7E",
"k c #6A6A6A",
"l c #FAFAFA",
"m c #505050",
"n c #9D9D9D",
"o c #333333",
"p c #7B7B7B",
"q c #787878",
"r c #696969",
"s c #494949",
"t c #555555",
"u c #949494",
"v c #E6E6E6",
"w c #424242",
"x c #515151",
"y c #535353",
"z c #3E3E3E",
"A c #D4D4D4",
"B c #0C0C0C",
"C c #353535",
"D c #474747",
"E c #ECECEC",
"F c #919191",
"G c #7D7D7D",
"H c #000000",
"I c #404040",
"J c #858585",
"K c #323232",
"L c #D0D0D0",
"M c #1C1C1C",
" ...+ ",
" @#$%&..+ ",
" .*=-;;>,..+ ",
" ')!~;;;;;;{]..",
" ^/(-;;;;;;;_:<",
" [}|;;;;;;;{12$",
" #34-55;;;;678$+",
" 90ab=c;dd;e1fg ",
" [ahij((kbl0mn$ ",
" op^q^^7r&]s/$+ ",
"@btu;vbwxy]zAB ",
"CzDEvEv;;DssF$ ",
"G.H{E{E{IxsJ$+ ",
" +...vEKxzLM ",
" +...z]n$ ",
" +... "};
Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
: QDialog( parent, name, modal, fl )
{
QStringList cmmds;
// cmmds=QStringList::split( " ", commands, false);
cmmds=commands;
// qDebug("count %d", cmmds.count());
if ( !name )
setName( tr("Output"));
resize( 196, 269 );
setCaption( name );
OutputLayout = new QGridLayout( this );
OutputLayout->setSpacing( 2);
OutputLayout->setMargin( 2);
QPushButton *docButton;
docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
docButton->setFixedSize( QSize( 20, 20 ) );
connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
// docButton->setFlat(TRUE);
OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
proc = new OProcess();
- connect(proc, SIGNAL(processExited(OProcess *)),
+ connect(proc, SIGNAL(processExited(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,436 +1,436 @@
/*
                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() )
{
amount *= -1;
}
stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount );
( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount );
}
// set sort order
bool bOk=false;
for(int i=0; i<_cbSortType->count(); i++) {
if( _cbSortType->text(i)==info->getSortOrder() ) {
_cbSortType->setCurrentItem(i);
slotSortChanged( info->getSortOrder() );
bOk=true;
break;
}
}
if( !bOk ) {
_cbSortType->setCurrentItem(0);
slotSortChanged( _cbSortType->currentText() );
}
// calc running balance
adjustBalance();
}
// --- adjustBalance ----------------------------------------------------------
void Checkbook::adjustBalance()
{
// update running balance in register
QString sRunning;
float bal=info->startingBalance();
for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) {
TranInfo *tran=item->getTranInfo();
bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee();
sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal );
item->setText( COL_BAL, sRunning);
}
}
// --- resort -----------------------------------------------------------------
void Checkbook::resort()
{
tranTable->setSorting(_sortCol);
tranTable->sort();
tranTable->setSorting(-1);
}
// --- accept -----------------------------------------------------------------
void Checkbook::accept()
{
info->setName( nameEdit->text() );
info->setType( typeList->currentText() );
info->setBank( bankEdit->text() );
info->setAccount( acctNumEdit->text() );
info->setPin( pinNumEdit->text() );
bool ok;
info->setStartingBalance( balanceEdit->text().toFloat( &ok ) );
info->setNotes( notesEdit->text() );
QDialog::accept();
}
// --- slotPasswordClicked ----------------------------------------------------
void Checkbook::slotPasswordClicked()
{
if ( info->password().isNull() && passwordCB->isChecked() )
{
Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
if ( pw->exec() != QDialog::Accepted )
{
passwordCB->setChecked( FALSE );
delete pw;
return;
}
info->setPassword( pw->password );
delete pw;
pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) );
if ( pw->exec() != QDialog::Accepted || pw->password != info->password() )
{
passwordCB->setChecked( FALSE );
info->setPassword( QString::null );
}
delete pw;
}
else if ( !info->password().isNull() && !passwordCB->isChecked() )
{
Password *pw = new Password( this, tr( "Enter password" ),
tr( "Please enter your password to confirm removal of password protection:" ) );
if ( pw->exec() == QDialog::Accepted && pw->password == info->password() )
{
info->setPassword( QString::null );
delete pw;
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,264 +1,264 @@
/*
                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)
{
// get column def
ColumnDef *pDef=this->at(iColumn);
// create map of entries
if( !_typeTable->childCount() ) return;
ColMap **colMap=new (ColMap *)[_typeTable->childCount()];
QListViewItem *cur=_typeTable->firstChild();
ColList lst;
for(int i=0; i<_typeTable->childCount(); i++) {
colMap[i]=new ColMap(cur->text(iColumn), cur);
lst.append( &(colMap[i]->getValue()) );
cur=cur->nextSibling();
}
// fix empty entries
int i=0;
for(QString *ptr=lst.first(); ptr; ptr=lst.next()) {
*ptr=ptr->stripWhiteSpace();
if( ptr->isEmpty() ) {
i++;
if( i==1 ) *ptr=pDef->getNewValue();
else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i);
}
}
// fix dups
lst.sort();
QString repl;
for(uint iCur=0; iCur<lst.count()-1; iCur++) {
QString *current=lst.at(iCur);
for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) {
if( *current!=*lst.at(iNext) ) continue;
for(int i=2; ; i++) {
repl.sprintf("%s %d", (const char *)*current, i);
bool bDup=false;
uint iChk=iNext+1;
while( iChk<lst.count() ) {
QString *chk=lst.at(iChk);
if( !chk->startsWith(*current) ) break;
if( *chk==repl ) {
bDup=true;
break;
}
iChk++;
}
if( !bDup ) {
*lst.at(iNext)=repl;
break;
}
}
}
}
lst.sort();
// copy back clean up col map
for(int i=0; i<_typeTable->childCount(); i++) {
colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue());
delete colMap[i];
}
delete colMap;
}
void ListEdit::fixTypes()
{
int i;
ColumnDef *pDef;
for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
if( pDef->hasFlag(ColumnDef::typeUnique) )
fixTypes(i);
}
_typeTable->sort();
}
// --- storeInList ------------------------------------------------------------
void ListEdit::storeInList(QStringList &lst)
{
// delete old content
lst.clear();
// add new one
fixTypes();
QListViewItem *itm=_typeTable->firstChild();
while( itm ) {
int i=0;
QString sAdd;
ColumnDef *pDef;
for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) {
if( i>=1 ) sAdd+=";";
sAdd += itm->text(i);
}
lst.append( sAdd );
itm=itm->nextSibling();
}
}
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
@@ -1,358 +1,358 @@
/*
                This file is part of the OPIE Project
=.
             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This file is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "mainwindow.h"
#include "cbinfo.h"
#include "configuration.h"
#include "password.h"
#include "checkbook.h"
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemessagebox.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qmenubar.h>
#include <qaction.h>
#include <qdir.h>
#include <qwhatsthis.h>
MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ )
: QMainWindow( parent, name, WStyle_ContextHelp )
{
setCaption( tr( "Checkbook" ) );
cbDir = Global::applicationFileName( "checkbook", "" );
lockIcon = Resource::loadPixmap( "locked" );
// Load configuration options
Config config( "checkbook" );
_cfg.readConfig( config );
// Build menu and tool bars
setToolBarsMovable( FALSE );
QToolBar *bar = new QToolBar( this );
bar->setHorizontalStretchable( TRUE );
QMenuBar *mb = new QMenuBar( bar );
mb->setMargin( 0 );
QPopupMenu *popup = new QPopupMenu( this );
bar = new QToolBar( this );
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) );
connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) );
a->addTo( popup );
a->addTo( bar );
actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
0, this, 0 );
actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) );
connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
actionOpen->addTo( popup );
actionOpen->addTo( bar );
actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
0, this, 0 );
actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
actionDelete->addTo( popup );
actionDelete->addTo( bar );
popup->insertSeparator();
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this app." ) );
connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
a->addTo( popup );
a->addTo( bar );
mb->insertItem( tr( "Checkbook" ), popup );
// Load Checkbook selection list
checkbooks = new CBInfoList();
QDir checkdir( cbDir );
if (checkdir.exists() == true)
{
QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
QDir::Time );
CBInfo *cb = 0x0;
QString filename;
for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ )
{
filename = cbDir;
filename.append( (*it) );
cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename );
checkbooks->inSort( cb );
}
}
// Build Checkbook selection list control
cbList = 0x0;
buildList();
// open last book?
if( _cfg.isOpenLastBook() ) {
this->show();
this->showMaximized();
QListViewItem *itm=cbList->firstChild();
while( itm ) {
if( itm->text(posName)==_cfg.getLastBook() ) {
openBook( itm );
break;
}
itm=itm->nextSibling();
}
}
}
// --- ~MainWindow ------------------------------------------------------------
MainWindow::~MainWindow()
{
writeConfig();
}
// --- buildList --------------------------------------------------------------
void MainWindow::buildList()
{
if ( cbList )
delete cbList;
cbList = new QListView( this );
QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
if ( _cfg.getShowLocks() )
{
cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 );
posName = 1;
}
else
{
posName = 0;
}
cbList->addColumn( tr( "Checkbook Name" ) );
if ( _cfg.getShowBalances() )
{
int colnum = cbList->addColumn( tr( "Balance" ) );
cbList->setColumnAlignment( colnum, Qt::AlignRight );
}
cbList->setAllColumnsShowFocus( TRUE );
cbList->setSorting( posName );
QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
- connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
+ 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 )
{
QString newname = cb->name();
if ( currname != newname )
{
// Update name if changed
if( curritem ) {
curritem->setText( posName, newname );
cbList->sort();
}
_cfg.setLastBook( newname );
// Remove old file
QFile f( tempFilename );
if ( f.exists() )
f.remove();
// Get new filename
buildFilename( newname );
cb->setFilename( tempFilename );
}
cb->write();
// Update lock if changed
if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock )
{
if ( !cb->password().isNull() )
curritem->setPixmap( 0, lockIcon );
else
curritem->setPixmap( 0, nullIcon );
}
// Update balance if changed
if ( _cfg.getShowBalances() && cb->balance() != currbalance )
{
QString tempstr;
tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() );
curritem->setText( posName + 1, tempstr );
}
// write config, if needed
if( _cfg.isDirty() ) {
Config config("checkbook");
_cfg.writeConfig( config );
}
}
delete currcb;
}
// --- slotDelete -------------------------------------------------------------
void MainWindow::slotDelete()
{
QString currname = cbList->currentItem()->text( posName );
if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) )
{
buildFilename( currname );
QFile f( tempFilename );
if ( f.exists() )
{
f.remove();
}
delete cbList->currentItem();
}
}
// --- slotConfigure ----------------------------------------------------------
void MainWindow::slotConfigure()
{
Configuration *cfgdlg = new Configuration( this, _cfg );
if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted )
{
// read data from config dialog & save it
cfgdlg->saveConfig( _cfg );
writeConfig();
buildList();
}
delete cfgdlg;
}
// --- writeConfig --------------------------------------------------------------
void MainWindow::writeConfig()
{
Config config("checkbook");
_cfg.writeConfig( config );
}
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
@@ -1,337 +1,337 @@
/*
                This file is part of the OPIE Project
=.
             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This file is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "transaction.h"
#include "traninfo.h"
#include "cfg.h"
#include "checkbook.h"
#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();
CategoryList *pCatList=_pCfg->getCategoryList();
for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) {
if( !pCat->isIncome() )
catList->insertItem( pCat->getName() );
}
catList->setCurrentItem(0);
typeList->clear();
typeList->insertItem( tr( "Debit Charge" ) );
typeList->insertItem( tr( "Written Check" ) );
typeList->insertItem( tr( "Transfer" ) );
typeList->insertItem( tr( "Credit Card" ) );
}
void Transaction::slotDepositClicked()
{
catList->clear();
CategoryList *pCatList=_pCfg->getCategoryList();
for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) {
if( pCat->isIncome() )
catList->insertItem( pCat->getName() );
}
catList->setCurrentItem( 0 );
typeList->clear();
typeList->insertItem( tr( "Written Check" ) );
typeList->insertItem( tr( "Automatic Payment" ) );
typeList->insertItem( tr( "Transfer" ) );
typeList->insertItem( tr( "Cash" ) );
}
// --- slotDateChanged --------------------------------------------------------
void Transaction::slotDateChanged( int y, int m, int d )
{
QDate date;
date.setYMD( y, m, d );
dateBtn->setText( TimeString::shortDate( date ) );
}
// --- slotActivated ----------------------------------------------------------
// Search for the most recent transaction with this description/payee and
// fill amount etc here, as long the new flag is set
void Transaction::slotActivated(const QString &arg )
{
if( !_bNew ) return;
TranInfoList *pTl=((Checkbook *)parentWidget())->getTranList();
if( pTl ) {
TranInfo *pTi=pTl->findMostRecentByDesc( arg );
if( pTi ) {
initFromInfo( pTi, true );
amtEdit->setFocus();
amtEdit->setSelection(0, amtEdit->text().length() );
amtEdit->setCursorPosition(0);
}
}
}
// slotNotNew -----------------------------------------------------------------
void Transaction::slotNotNew()
{
qDebug("Not new");
_bNew=false;
}
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,189 +1,189 @@
/***************************************************************************
* *
* 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);
}
void MainWindow::stopTimer( QListViewItem* )
{
popupTimer->stop();
}
void MainWindow::saveConfFile()
{
if (!_fileItem) return;
_fileItem->save();
}
void MainWindow::revertConfFile()
{
if (!_item) return;
_item->revert();
}
void MainWindow::removeConfFile()
{
if (!_item) return;
_item->remove();
}
void MainWindow::showPopup()
{
qDebug("showPopup");
if (!_item) return;
popupActionRevert->setEnabled(_item->revertable());
popupActionSave->setEnabled(_item->isChanged());
if (_fileItem)
{
popupActionSave->setEnabled(_fileItem->isChanged());
popupMenuFile->popup( QCursor::pos() );
}else if(_currentItem)
{
popupMenuEntry->popup( QCursor::pos() );
}
}
diff --git a/noncore/apps/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
@@ -17,199 +17,199 @@
#include "odict.h"
#include "configdlg.h"
#include "dingwidget.h"
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qvbox.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qaction.h>
#include <qtextbrowser.h>
#include <qcombobox.h>
#include <qpe/resource.h>
#include <qpe/config.h>
ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl )
{
activated_name = QString::null;
vbox = new QVBox( this );
setCaption( tr( "Opie-Dictionary" ) );
setupMenus();
QHBox *hbox = new QHBox( vbox );
QLabel* query_label = new QLabel( tr( "Query:" ) , hbox );
query_label->show();
query_le = new QLineEdit( hbox );
query_co = new QComboBox( hbox );
connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) );
ok_button = new QPushButton( tr( "&Ok" ), hbox );
connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) );
top_name = new QLabel( vbox );
top_name->setAlignment( AlignHCenter );
browser_top = new QTextBrowser( vbox );
bottom_name = new QLabel( vbox );
bottom_name->setAlignment( AlignHCenter );
browser_bottom = new QTextBrowser( vbox );
ding = new DingWidget();
loadConfig();
setCentralWidget( vbox );
}
void ODict::loadConfig()
{
/*
* the name of the last used dictionary
*/
QString lastname;
Config cfg ( "odict" );
cfg.setGroup( "generalsettings" );
casesens = cfg.readEntry( "casesens" ).toInt();
QString lastDict = cfg.readEntry( "lastdict" );
int i = 0, e = 0;
QStringList groupListCfg = cfg.groupList().grep( "Method_" );
query_co->clear();
for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
{
QString name;
cfg.setGroup( *it );
name = cfg.readEntry( "Name" );
query_co->insertItem( name );
/*
* this check is to look up what dictionary has been used the
* last time
*/
if ( lastDict == name )
{
e = i;
lastname = name;
}
i++;
}
/*
* now set the two names of the dictionary and the correct QComboBox-Entry
*/
lookupLanguageNames( lastname );
ding->loadDict( lastname );
ding->loadValues();
query_co->setCurrentItem( e );
top_name->setText( top_name_content );
bottom_name->setText( bottom_name_content );
}
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
@@ -1,299 +1,299 @@
/****************************************************************************
**
** Created: Sat Jul 20 08:10:53 2002
** by: L.J. Potter <ljp@llornkcor.com>
** copyright : (C) 2002 by ljp
email : ljp@llornkcor.com
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "bartender.h"
#include "showdrinks.h"
#include "inputDialog.h"
#include "searchresults.h"
#include "bac.h"
#include <qpe/qpetoolbar.h>
#include <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;
while ( !t.eof()) {
s = t.readLine();
if(s.find( myDrink, 0, TRUE) != -1) {
for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
s2 = t.readLine();
if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
// qDebug(s2);
showDrinks->MultiLineEdit1->append(s2);
}
if( dbFile.atEnd() ) break;
}
}
}
QPEApplication::execDialog( showDrinks );
if(showDrinks ->result() ==0) {
doEdit();
}
delete showDrinks;
}
void Bartender::askSearch() {
switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+
"\nor alcohol ?"
,tr("Drink Name"),tr("Alcohol"),0,0,1) ) {
case 0:
doSearchByName();
break;
case 1:
doSearchByDrink();
break;
};
}
/* search by name */
void Bartender::doSearchByName() {
// if( DrinkView->currentItem() == NULL) return;
QStringList searchList;
QString searchForDrinkName;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
searchForDrinkName = fileDlg->LineEdit1->text();
QListViewItemIterator it( DrinkView );
for ( ; it.current(); ++it ) {
if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) {
// qDebug( it.current()->text(0));
searchList.append(it.current()->text(0));
}
}
if(searchList.count() >0)
showSearchResult(searchList);
else
QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName);
}//end Inputdialog
delete fileDlg;
}
void Bartender::doSearchByDrink() {
// if( DrinkView->currentItem() == NULL) return;
QStringList searchList;
QString searchForDrinkName, lastDrinkName, tempName;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
searchForDrinkName = fileDlg->LineEdit1->text();
dbFile.at(0);
QTextStream t( &dbFile);
QString s, s2;
while ( !t.eof()) {
s = t.readLine();
if(s.find("#",0,TRUE) != -1) {
lastDrinkName=s.right(s.length()-2);
// qDebug("last drink name "+lastDrinkName);
}
else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) {
// qDebug("appending "+lastDrinkName);
searchList.append( lastDrinkName);
tempName=lastDrinkName;
}
// if( dbFile.atEnd() ) break;
} //oef
if(searchList.count() >0)
showSearchResult(searchList);
else
QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName);
}
delete fileDlg;
}
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,190 +1,190 @@
#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:
parity = 1;
break;
case IOLayerBase::NonePar:
parity = 0;
break;
}
switch( m_base->speed() ) {
case IOLayerBase::Baud_115200:
speed = 115200;
break;
case IOLayerBase::Baud_57600:
speed = 57600;
break;
case IOLayerBase::Baud_38400:
speed = 38400;
break;
case IOLayerBase::Baud_19200:
speed = 19200;
break;
default:
case IOLayerBase::Baud_9600:
speed = 9600;
break;
}
prof.writeEntry("Flow", flow);
prof.writeEntry("Parity", parity);
prof.writeEntry("Speed", speed);
prof.writeEntry("Mac", m_mac->text() );
}
void BTConfigWidget::slotMacRadio( bool on ) {
if ( on ) {
m_devRadio->setChecked( false );
m_deviceCmb->setEnabled( false );
m_mac->setEnabled( true );
} else {
m_devRadio->setChecked( true );
}
}
void BTConfigWidget::slotDevRadio( bool on ) {
if ( on ) {
m_macRadio->setChecked( false );
m_deviceCmb->setEnabled( true );
m_mac->setEnabled( false );
} else {
m_macRadio->setChecked( true );
}
}
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,206 +1,206 @@
#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;
/* we need to switch it */
switch( col ) {
default:
case Profile::White:
/* color is black */
co = Qt::white;
break;
case Profile::Black:
co = Qt::black;
break;
case Profile::Green:
qWarning("Foreground green");
co = Qt::green;
break;
case Profile::Orange:
qWarning("Foreground orange");
co.setRgb( 231, 184, 98 );
break;
}
return co;
}
QColor EmulationHandler::backColor(int col ) {
QColor co;
/* we need to switch it */
switch( col ) {
default:
case Profile::White:
/* color is white */
co = Qt::black;
break;
case Profile::Black:
co = Qt::white;
break;
case Profile::Green:
qWarning("Background black");
co = Qt::black;
break;
case Profile::Orange:
qWarning("Background black");
co = Qt::black;
break;
}
return co;
}
QPushButton* EmulationHandler::cornerButton() {
return m_teWid->cornerButton();
}
Script *EmulationHandler::script() {
return m_script;
}
bool EmulationHandler::isRecording() {
return (m_script != 0);
}
void EmulationHandler::startRecording() {
if (!isRecording())
m_script = new Script();
}
void EmulationHandler::clearScript() {
if (isRecording()) {
delete m_script;
m_script = 0;
}
}
void EmulationHandler::runScript(const Script *script) {
emit send(script->script());
}
void EmulationHandler::copy() {
m_teWid->emitSelection();
}
void EmulationHandler::paste() {
m_teWid->pasteClipboard();
}
void EmulationHandler::setWrap(int columns) {
m_teWid->setWrapAt(columns);
}
diff --git a/noncore/apps/opie-console/emulation_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
@@ -1,312 +1,312 @@
/* -------------------------------------------------------------------------- */
/* */
/* [emulation_layer.cpp] Terminal Emulation Decoder */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* 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())
{ // A block of text
// Note that the text is proper unicode.
// We should do a conversion here, but since this
// routine will never be used, we simply emit plain ascii.
sendString( ev->text().ascii() ); //,ev->text().length());
}
else if (ev->ascii()>0)
{
QByteArray c = QByteArray( 1 );
c.at( 0 ) = ev->ascii();
// ibot: qbytearray is emited not char*
emit sndBlock( (QByteArray) c );
}
}
// Unblocking, Byte to Unicode translation --------------------------------- --
/*
We are doing code conversion from locale to unicode first.
*/
void EmulationLayer::onRcvBlock(const QByteArray &s )
{
bulkStart();
bulk_incnt += 1;
for (int i = 0; i < s.size(); i++)
{
//TODO: ibot: maybe decoding qbytearray to unicode in io_layer?
QString result = decoder->toUnicode(&s[i],1);
int reslen = result.length();
for (int j = 0; j < reslen; j++)
onRcvChar(result[j].unicode());
if (s[i] == '\n') bulkNewline();
}
bulkEnd();
}
// Selection --------------------------------------------------------------- --
void EmulationLayer::onSelectionBegin(const int x, const int y) {
if (!connected) return;
scr->setSelBeginXY(x,y);
showBulk();
}
void EmulationLayer::onSelectionExtend(const int x, const int y) {
if (!connected) return;
scr->setSelExtentXY(x,y);
showBulk();
}
void EmulationLayer::setSelection(const BOOL preserve_line_breaks) {
if (!connected) return;
QString t = scr->getSelText(preserve_line_breaks);
if (!t.isNull()) gui->setSelection(t);
}
void EmulationLayer::clearSelection() {
if (!connected) return;
scr->clearSelection();
showBulk();
}
// Refreshing -------------------------------------------------------------- --
#define BULK_TIMEOUT 20
/*!
called when \n comes in. Evtl. triggers showBulk at endBulk
*/
void EmulationLayer::bulkNewline()
{
bulk_nlcnt += 1;
bulk_incnt = 0; // reset bulk counter since `nl' rule applies
}
/*!
*/
void EmulationLayer::showBulk()
{
bulk_nlcnt = 0; // reset bulk newline counter
bulk_incnt = 0; // reset bulk counter
if (connected)
{
QArray<Character> image = scr->getCookedImage(); // get the image
gui->setImage(image,
scr->getLines(),
scr->getColumns()); // actual refresh
delete image;
//FIXME: check that we do not trigger other draw event here.
gui->setScroll(scr->getHistCursor(),scr->getHistLines());
}
}
diff --git a/noncore/apps/opie-console/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
@@ -71,356 +71,356 @@ void FunctionKeyboard::load (const Profile& prof) {
/* load all the keys to the keyboard */
for (ushort i = 0; i <= numRows - 1; i++)
for (ushort j = 0; j <= numCols - 1; j++) {
QString h = "r" + QString::number(i) + "c" + QString::number(j);
QString values = prof.readEntry("keb_" + h);
if (!values.isEmpty()) {
QStringList l = QStringList::split(QChar('|'), values, TRUE);
keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
// load pixmap if used
if (!l[1].isEmpty()) {
keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
}
}
}
if (keys.isEmpty()) loadDefaults();
hide();
show();
}
void FunctionKeyboard::paintEvent(QPaintEvent *e) {
QPainter p(this);
p.setClipRect(e->rect());
p.fillRect(0, 0, width(), height(), QColor(255,255,255));
p.setPen(QColor(0,0,0));
/* those decimals do count! becomes short if use plain int */
for (double i = 0; i <= width(); i += keyWidth) {
p.drawLine((int)i, 0, (int)i, height());
}
// sometimes the last line doesnt get drawn
p.drawLine(width() -1, 0, width() -1, height());
for (int i = 0; i <= height(); i += keyHeight) {
p.drawLine(0, i, width(), i);
}
for (uint r = 0; r < numRows; r++) {
for (uint c = 0; c < numCols; c++) {
QString handle = "r" + QString::number(r) + "c" + QString::number(c);
if (keys.contains(handle)) {
if (keys[handle].pixFile.isEmpty())
p.drawText( c * keyWidth + 1, r * keyHeight + 1,
keyWidth, keyHeight,
Qt::AlignHCenter | Qt::AlignVCenter,
keys[handle].label
);
else {
ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
p.drawPixmap(centerX, centerY, *keys[handle].pix);
}
}
}
}
}
void FunctionKeyboard::paintKey(uint row, uint col) {
QPainter p(this);
p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
(pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
QString handle ("r" + QString::number(row) + "c" + QString::number(col));
if (keys[handle].pixFile.isEmpty())
p.drawText(
col * keyWidth + 1, row * keyHeight + 1,
keyWidth, keyHeight,
Qt::AlignHCenter | Qt::AlignVCenter,
keys[handle].label
);
else {
ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
p.drawPixmap(centerX, centerY, *keys[handle].pix);
}
if (col == numCols - 1) {
// sometimes it doesnt draw the last line
p.drawLine((col+1) * keyWidth -1, row * keyHeight,
(col+1) * keyWidth -1, (row + 1) * keyHeight
);
}
}
void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
pressedRow = e->y() / keyHeight;
pressedCol = (int) (e->x() / keyWidth);
paintKey(pressedRow, pressedCol);
// emit that sucker!
FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
emit keyPressed(k, pressedRow, pressedCol, 1);
}
void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
if (pressedRow != -1 && pressedRow != -1) {
int row = pressedRow; pressedRow = -1;
int col = pressedCol; pressedCol = -1;
paintKey(row, col);
FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
emit keyPressed(k, row, col, 0);
}
}
void FunctionKeyboard::resizeEvent(QResizeEvent*) {
/* set he default font height/width */
QFontMetrics fm=fontMetrics();
keyHeight = fm.lineSpacing() + 2;
keyWidth = (double)width()/numCols;
}
QSize FunctionKeyboard::sizeHint() const {
return QSize(width(), keyHeight * numRows + 1);
}
void FunctionKeyboard::loadDefaults() {
numRows = DEFAULT_ROWS;
numCols = DEFAULT_COLS;
keyWidth = (double)width()/numCols; // have to reset this thing too
keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space));
keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0));
keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0));
keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff));
keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
keys.insert( "r1c11", FKey ("F12", 0, 4155, 0));
}
/* FunctionKeyboardConfig {{{1 */
FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
: ProfileDialogKeyWidget(name, parent, na),
selectedRow(0), selectedCol(0)
{
qWarning("FunctionKeyboardConfig");
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);
// why tf does the text get erased unless i do this?
m_labels->changeItem(m_labels->text(0), 0);
kb->keys[selectedHandle].pixFile = "";
delete kb->keys[selectedHandle].pix;
} else {
// is a pixmap
m_labels->setEditable(false);
kb->keys[selectedHandle].pixFile = m_labels->currentText();
kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) );
}
kb->paintKey(selectedRow, selectedCol);
}
void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
kb->keys[selectedHandle].label = label;
kb->paintKey(selectedRow, selectedCol);
}
void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) {
kb->keys[selectedHandle].qcode = qcode.toUInt();
}
void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) {
kb->keys[selectedHandle].unicode = uni.toUInt();
}
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
@@ -21,424 +21,424 @@
#include "transferdialog.h"
#include "function_keyboard.h"
#include "emulation_handler.h"
#include "script.h"
MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
KeyTrans::loadAll();
for (int i = 0; i < KeyTrans::count(); i++ ) {
KeyTrans* s = KeyTrans::find(i );
assert( s );
}
m_factory = new MetaFactory();
Default def(m_factory);
m_sessions.setAutoDelete( TRUE );
m_curSession = 0;
m_manager = new ProfileManager( m_factory );
m_manager->load();
m_scriptsData.setAutoDelete(TRUE);
initUI();
populateProfiles();
populateScripts();
}
void MainWindow::initUI() {
setToolBarsMovable( FALSE );
/* tool bar for the menu */
m_tool = new QToolBar( this );
m_tool->setHorizontalStretchable( TRUE );
m_bar = new QMenuBar( m_tool );
m_console = new QPopupMenu( this );
m_scripts = new QPopupMenu( this );
m_sessionsPop= new QPopupMenu( this );
m_scriptsPop = new QPopupMenu( this );
/* add a toolbar for icons */
m_icons = new QToolBar(this);
/*
* the settings action
*/
m_setProfiles = new QAction(tr("Configure Profiles"),
Resource::loadPixmap( "SettingsIcon" ),
QString::null, 0, this, 0);
m_setProfiles->addTo( m_console );
connect( m_setProfiles, SIGNAL(activated() ),
this, SLOT(slotConfigure() ) );
m_console->insertSeparator();
/*
* new Action for new sessions
*/
QAction* newCon = new QAction(tr("New Profile"),
Resource::loadPixmap( "new" ),
QString::null, 0, this, 0);
newCon->addTo( m_console );
connect( newCon, SIGNAL(activated() ),
this, SLOT(slotNew() ) );
m_console->insertSeparator();
QAction *saveCon = new QAction( tr("Save Profile" ),
Resource::loadPixmap( "save" ), QString::null,
0, this, 0 );
saveCon->addTo( m_console );
connect( saveCon, SIGNAL(activated() ),
this, SLOT(slotSaveSession() ) );
m_console->insertSeparator();
/*
* connect action
*/
m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
QString::null, 0, this, 0 );
m_connect->addTo( m_console );
connect(m_connect, SIGNAL(activated() ),
this, SLOT(slotConnect() ) );
/*
* disconnect action
*/
m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
QString::null, 0, this, 0 );
m_disconnect->addTo( m_console );
connect(m_disconnect, SIGNAL(activated() ),
this, SLOT(slotDisconnect() ) );
m_console->insertSeparator();
m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
m_quickLaunch->addTo( m_icons );
connect( m_quickLaunch, SIGNAL( activated() ),
this, SLOT( slotQuickLaunch() ) );
QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
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);
populateScripts();
}
}
}
void MainWindow::slotRunScript(int id) {
if (currentSession()) {
int index = m_scriptsPop->indexOf(id);
DocLnk *lnk = m_scriptsData.at(index);
QString filePath = lnk->file();
Script script(filePath);
currentSession()->emulationHandler()->runScript(&script);
}
}
void MainWindow::slotConnect() {
if ( currentSession() ) {
bool ret = currentSession()->layer()->open();
if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
QObject::tr("Failed"),
QObject::tr("Connecting failed for this session."));
else {
m_connect->setEnabled( false );
m_disconnect->setEnabled( true );
// if it does not support file transfer, disable the menu entry
if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
m_transfer->setEnabled( false );
} else {
m_transfer->setEnabled( true );
}
m_recordScript->setEnabled( true );
m_scripts->setItemEnabled(m_runScript_id, true);
}
}
}
void MainWindow::slotDisconnect() {
if ( currentSession() ) {
currentSession()->layer()->close();
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
m_transfer->setEnabled( false );
m_recordScript->setEnabled( false);
m_saveScript->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
}
}
void MainWindow::slotTerminate() {
if ( currentSession() )
currentSession()->layer()->close();
slotClose();
/* FIXME move to the next session */
}
void MainWindow::slotQuickLaunch() {
Profile prof = manager()->profile( "default" );
if ( prof.name() == "default" ) {
create( prof );
} else {
Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
newProf.setAutoConnect( true );
create( newProf );
slotSaveSession();
}
}
void MainWindow::slotConfigure() {
ConfigDialog conf( manager()->all(), factory() );
int ret = QPEApplication::execDialog( &conf );
if ( QDialog::Accepted == ret ) {
manager()->setProfiles( conf.list() );
manager()->save();
populateProfiles();
}
}
/*
* we will remove
* this window from the tabwidget
* remove it from the list
* delete it
* and set the currentSession()
*/
void MainWindow::slotClose() {
if (!currentSession() )
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
@@ -1,241 +1,241 @@
#include <qlayout.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qcheckbox.h>
#include <qscrollview.h>
#include "metafactory.h"
#include "profileeditordialog.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
for (int i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
}
}
};
}
ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
const Profile& prof )
: QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
{
initUI();
// Apply current profile
// plugin_plugin->load(profile);
// ... (reset profile name line edit etc.)
}
ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
: QDialog(0, 0, TRUE), m_fact( fact )
{
// Default profile
m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102);
initUI();
// Apply current profile
// plugin_plugin->load(profile);
}
Profile ProfileEditorDialog::profile() const
{
return m_prof;
}
void ProfileEditorDialog::initUI()
{
m_con = m_term = m_key = 0l;
QVBoxLayout *mainLayout = new QVBoxLayout( this );
tabWidget = new OTabWidget( this );
tabWidget->setTabStyle(OTabWidget::TextTab);
mainLayout->add(tabWidget);
/* base tabs */
tabprof = new QWidget(this);
m_tabTerm = new QWidget(this);
m_tabCon = new QWidget(this);
m_tabKey = new QWidget(this);
m_svCon = new QScrollView( m_tabCon );
m_svCon->setResizePolicy( QScrollView::AutoOneFit );
//m_svCon->setHScrollBarMode( QScrollView::AlwaysOff );
m_svCon->setFrameShape( QFrame::NoFrame );
m_svTerm = new QScrollView( m_tabTerm );
m_svTerm->setResizePolicy( QScrollView::AutoOneFit );
//m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff );
m_svTerm->setFrameShape( QFrame::NoFrame );
/* base layout for tabs */
m_layCon = new QHBoxLayout( m_tabCon , 2 );
m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
m_layKey = new QHBoxLayout( m_tabKey, 2 );
m_layCon->addWidget( m_svCon );
m_layTerm->addWidget( m_svTerm );
// profile tab
QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
m_name = new QLineEdit(tabprof);
QLabel *con = new QLabel(tr("Connection"), tabprof );
QLabel *term = new QLabel(tr("Terminal"), tabprof );
m_conCmb = new QComboBox( tabprof );
m_termCmb = new QComboBox( tabprof );
m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof);
// layouting
QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
vbox3->add(name);
vbox3->add(m_name);
vbox3->add(con );
vbox3->add(m_conCmb );
vbox3->add(term );
vbox3->add(m_termCmb );
vbox3->add(m_autoConnect);
vbox3->addStretch(1);
m_showconntab = 0;
tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys"));
tabWidget->setCurrentTab( tabprof );
// fill the comboboxes
QStringList list = m_fact->connectionWidgets();
QStringList::Iterator it;
for (it =list.begin(); it != list.end(); ++it ) {
m_conCmb->insertItem( (*it) );
}
list = m_fact->terminalWidgets();
for (it =list.begin(); it != list.end(); ++it ) {
m_termCmb->insertItem( (*it) );
}
// load profile values
m_name->setText(m_prof.name());
slotKeyActivated( "Default Keyboard" );
setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
slotTermActivated( m_fact->external(m_prof.terminalName() ) );
m_autoConnect->setChecked(m_prof.autoConnect());
// signal and slots
- connect(m_conCmb, SIGNAL(activated(const QString& ) ),
+ 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 );
if (m_key) {
m_key->load(m_prof);
m_layKey->addWidget(m_key);
}
}
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
@@ -1,275 +1,275 @@
#include <qlayout.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qprogressbar.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <opie2/ofiledialog.h>
#include "metafactory.h"
#include "mainwindow.h"
#include "transferdialog.h"
TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *)
: QDialog(parent, 0l, false), m_win(mainwindow)
{
m_lay = 0l;
m_recvlay = 0l;
QVBoxLayout *vbox, *vbox2;
QHBoxLayout *hbox, *hbox2, *hbox3;
QLabel *file, *mode, *progress, *status;
QButtonGroup *group;
QRadioButton *mode_send, *mode_receive;
m_autocleanup = 0;
m_running = true;
group = new QButtonGroup(QObject::tr("Transfer mode"), this);
mode_send = new QRadioButton(QObject::tr("Send"), group);
mode_receive = new QRadioButton(QObject::tr("Receive"), group);
group->insert(mode_send, id_send);
group->insert(mode_receive, id_receive);
vbox2 = new QVBoxLayout(group, 2);
vbox2->addSpacing(10);
hbox3 = new QHBoxLayout(vbox2, 2);
hbox3->add(mode_send);
hbox3->add(mode_receive);
mode_send->setChecked(true);
m_transfermode = id_send;
file = new QLabel(QObject::tr("Send file"), this);
mode = new QLabel(QObject::tr("Transfer protocol"), this);
progress = new QLabel(QObject::tr("Progress"), this);
status = new QLabel(QObject::tr("Status"), this);
statusbar = new QLabel(QObject::tr("Ready"), this);
statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
protocol = new QComboBox(this);
QStringList list = m_win->factory()->fileTransferLayers();
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
protocol->insertItem((*it));
filename = new QLineEdit(this);
progressbar = new QProgressBar(this);
progressbar->setProgress(0);
selector = new QPushButton("...", this);
ok = new QPushButton(QObject::tr("Start transfer"), this);
cancel = new QPushButton(QObject::tr("Cancel"), this);
vbox = new QVBoxLayout(this, 2);
vbox->add(group);
vbox->add(file);
hbox = new QHBoxLayout(vbox, 0);
hbox->add(filename);
hbox->add(selector);
vbox->add(mode);
vbox->add(protocol);
vbox->add(progress);
vbox->add(progressbar);
vbox->add(status);
vbox->add(statusbar);
vbox->addStretch(1);
hbox2 = new QHBoxLayout(vbox, 2);
hbox2->add(ok);
hbox2->add(cancel);
setCaption(QObject::tr("File transfer"));
show();
connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int)));
}
TransferDialog::~TransferDialog()
{
}
void TransferDialog::slotFilename()
{
QString f;
f = Opie::OFileDialog::getOpenFileName(0);
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()
{
progressbar->setProgress(100);
QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent."));
ok->setEnabled(true);
progressbar->setProgress(0);
statusbar->setText(QObject::tr("Ready"));
m_autocleanup = 1;
}
void TransferDialog::slotReceived(const QString& )
{
progressbar->setProgress(100);
QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received."));
//QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file));
ok->setEnabled(true);
progressbar->setProgress(0);
statusbar->setText(QObject::tr("Ready"));
m_autocleanup = 1;
}
void TransferDialog::slotMode(int id)
{
if(id == id_send)
{
selector->setEnabled(true);
filename->setEnabled(true);
}
else
{
selector->setEnabled(false);
filename->setEnabled(false);
}
m_transfermode = id;
}
bool TransferDialog::isRunning()
{
return m_running;
}
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index e759249..b0d589e 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -140,855 +140,855 @@ void QTReaderApp::listBkmkFiles()
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
while ( (fi=it.current()) ) { // for each file...
bkmkselector->insertItem(fi->fileName());
cnt++;
//qDebug( "%10li %s", fi->size(), fi->fileName().data() );
++it; // goto next list element
}
#else /* USEQPE */
int cnt = 0;
DIR *d;
d = opendir((const char *)Global::applicationFileName(APPDIR,""));
while(1)
{
struct dirent* de;
struct stat buf;
de = readdir(d);
if (de == NULL) break;
if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
{
bkmkselector->insertItem(de->d_name);
cnt++;
}
}
closedir(d);
#endif
if (cnt > 0)
{
//tjw menu->hide();
editorStack->raiseWidget( bkmkselector );
hidetoolbars();
m_nBkmkAction = cRmBkmkFile;
}
else
QMessageBox::information(this, PROGNAME, "No bookmark files");
}
void QTReaderApp::hidetoolbars()
{
menubar->hide();
if (fileBar != NULL) fileBar->hide();
if (viewBar != NULL) viewBar->hide();
if (navBar != NULL) navBar->hide();
if (markBar != NULL) markBar->hide();
if (m_fontVisible) m_fontBar->hide();
if (regVisible)
{
#ifdef USEQPE
Global::hideInputMethod();
#endif
regBar->hide();
}
if (searchVisible)
{
#ifdef USEQPE
Global::hideInputMethod();
#endif
searchBar->hide();
}
}
QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
: QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false),
fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL)
{
m_url_clipboard = false;
m_url_localfile = false;
m_url_globalfile = false;
ftime(&m_lastkeytime);
//// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
//// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
m_bcloseDisabled = true;
m_disableesckey = false;
pBkmklist = NULL;
pOpenlist = NULL;
// doc = 0;
m_fBkmksChanged = false;
QString lang = getenv( "LANG" );
QString rot = getenv( "QWS_DISPLAY" );
/*
int m_rot = 0;
if (rot.contains("Rot90"))
{
m_rot = 90;
}
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 );
m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 );
connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) );
m_back_action->addTo( navigation );
m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 );
connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) );
m_home_action->addTo( navigation );
m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 );
connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) );
m_forward_action->addTo( navigation );
/*
a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
a->addTo( file );
a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
a->addTo( file );
*/
// file->insertSeparator();
#ifdef _SCROLLPIPE
QActionGroup* ag = new QActionGroup(this);
ag->setExclusive(false);
spacemenu = new QPopupMenu(this);
file->insertItem( tr( "Scrolling" ), spacemenu );
a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) );
a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true );
connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) );
a->setOn(reader->m_pauseAfterEachPara);
ag->addTo(spacemenu);
// file->insertSeparator();
#endif
/*
a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
a->addTo( file );
*/
/*
a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( fileBar );
a->addTo( edit );
*/
// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 );
m_fullscreen = false;
m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true );
connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
m_actFullscreen->setOn(m_fullscreen);
m_actFullscreen->addTo( view );
view->insertSeparator();
m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this);
connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) );
m_zoomin_action->addTo( view );
m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this);
connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) );
m_zoomout_action->addTo( view );
view->insertSeparator();
m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this);
connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) );
m_setfont_action->addTo( view );
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);
addfilebar(config, "Close", m_close_action);
addfilebar(config, "Info", m_info_action);
addfilebar(config, "Two/One Touch", m_touch_action);
addfilebar(config, "Find", m_find_action);
if (navBar != NULL)
{
if ((navBar == fileBar) && (fileBar == menubar))
{
m_scrollButton->removeFrom( navbar() );
m_start_action->removeFrom( navbar() );
m_end_action->removeFrom( navbar() );
m_jump_action->removeFrom( navbar() );
m_pageline_action->removeFrom( navbar() );
m_pageup_action->removeFrom( navbar() );
m_pagedn_action->removeFrom( navbar() );
m_back_action->removeFrom( navbar() );
m_home_action->removeFrom( navbar() );
m_forward_action->removeFrom( navbar() );
}
else if (navBar != fileBar)
{
navBar->clear();
}
}
addnavbar(config, "Scroll", m_scrollButton);
addnavbar(config, "Goto Start", m_start_action);
addnavbar(config, "Goto End", m_end_action);
addnavbar(config, "Jump", m_jump_action);
addnavbar(config, "Page/Line Scroll", m_pageline_action);
addnavbar(config, "Page Up", m_pageup_action);
addnavbar(config, "Page Down", m_pagedn_action);
addnavbar(config, "Back", m_back_action);
addnavbar(config, "Home", m_home_action);
addnavbar(config, "Forward", m_forward_action);
if (viewBar != NULL)
{
if ((viewBar == fileBar) && (fileBar == menubar))
{
m_actFullscreen->removeFrom( filebar() );
m_zoomin_action->removeFrom( viewbar() );
m_zoomout_action->removeFrom( viewbar() );
m_setfont_action->removeFrom( viewbar() );
m_setenc_action->removeFrom( viewbar() );
m_setmono_action->removeFrom( viewbar() );
}
else if (viewBar != fileBar)
{
viewBar->clear();
}
}
addviewbar(config, "Fullscreen", m_actFullscreen);
addviewbar(config, "Zoom In", m_zoomin_action);
addviewbar(config, "Zoom Out", m_zoomout_action);
addviewbar(config, "Set Font", m_setfont_action);
addviewbar(config, "Encoding Select", m_setenc_action);
addviewbar(config, "Ideogram Mode", m_setmono_action);
if (markBar != NULL)
{
if ((markBar == fileBar) && (fileBar == menubar))
{
m_mark_action->removeFrom( markbar() );
m_annotate_action->removeFrom( markbar());
m_goto_action->removeFrom( markbar() );
m_delete_action->removeFrom( markbar() );
m_autogen_action->removeFrom( markbar() );
m_clear_action->removeFrom( markbar() );
m_save_action->removeFrom( markbar() );
m_tidy_action->removeFrom( markbar() );
m_startBlock_action->removeFrom( markbar() );
m_endBlock_action->removeFrom( markbar() );
}
else if (markBar != fileBar)
{
markBar->clear();
}
}
addmarkbar(config, "Mark", m_mark_action);
addmarkbar(config, "Annotate", m_annotate_action);
addmarkbar(config, "Goto", m_goto_action);
addmarkbar(config, "Delete", m_delete_action);
addmarkbar(config, "Autogen", m_autogen_action);
addmarkbar(config, "Clear", m_clear_action);
addmarkbar(config, "Save", m_save_action);
addmarkbar(config, "Tidy", m_tidy_action);
addmarkbar(config, "Start Block", m_startBlock_action);
addmarkbar(config, "Copy Block", m_endBlock_action);
if (checkbar(config, "Annotation indicator"))
{
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,266 +1,266 @@
/****************************************************************************
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)
{
if (selectedItem == NULL) return;
QString strItem=selectedItem->text(0);
//// qDebug("%s", (const char*)strItem);
QString strSize=selectedItem->text(1);
strSize.stripWhiteSpace();
bool ok;
QFileInfo fi(strItem);
while (fi.isSymLink()) fi.setFile(fi.readLink());
if (fi.isDir())
{
strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
if(QDir(strItem).exists())
{
currentDir.cd(strItem, TRUE);
populateList();
}
} else
{
QListViewItem *selectedItem = ListView->selectedItem();
if (selectedItem == NULL)
{
filename = "";
}
else
{
filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0));
}
OnOK();
}
chdir(strItem.latin1());
//
}
// you may want to switch these 2 functions. I like single clicks
void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
{
}
QString fileBrowser::getCurrentFile()
{
return filename;
}
void fileBrowser::OnOK()
{
accept();
}
void fileBrowser::OnRoot()
{
currentDir.cd("/", TRUE);
populateList();
chdir("/");
}
void fileBrowser::OnCancel()
{
reject();
}
void fileBrowser::setHidden(bool _hidden)
{
if (_hidden)
filterspec = QDir::All | QDir::Hidden;
else
filterspec = QDir::All;
populateList();
}
void fileBrowser::onReturn()
{
QListViewItem *selectedItem = ListView->selectedItem();
if (selectedItem == NULL)
{
filename = m_filename->text();
}
else
{
filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text());
}
OnOK();
}
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,238 +1,238 @@
/***************************************************************************
* *
* 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;
newCell->row=row;
newCell->alignment=(Qt::AlignmentFlags)alignment;
newSheet->data.append(newCell);
}
listSheets.append(newSheet);
if (i==0)
{
sheet->setName(newSheet->name);
sheet->setSheetData(&newSheet->data);
}
}
}
int MainWindow::saveCurrentFile(bool ask)
{
if (ask)
{
int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
if (result!=QMessageBox::Yes) return result;
}
if (!currentDoc->isValid())
{
TextDialog dialogText(this);
if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel;
currentDoc->setName(dialogText.getValue());
currentDoc->setFile(QString::null);
currentDoc->setLinkFile(QString::null);
}
documentSave(currentDoc);
return QMessageBox::Yes;
}
void MainWindow::selectorFileNew(const DocLnk &lnkDoc)
{
selectorHide();
if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
if (currentDoc) delete currentDoc;
currentDoc = new DocLnk(lnkDoc);
editData->clear();
listSheets.clear();
comboSheets->clear();
typeSheet *newSheet=createNewSheet();
newSheet->data.setAutoDelete(TRUE);
sheet->setName(newSheet->name);
sheet->setSheetData(&newSheet->data);
for (int i=1; i<DEFAULT_NUM_SHEETS; ++i)
createNewSheet();
documentModified=FALSE;
}
void MainWindow::closeEvent(QCloseEvent *e)
{
if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore();
else e->accept();
}
void MainWindow::selectorFileOpen(const DocLnk &lnkDoc)
{
selectorHide();
if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
if (currentDoc) delete currentDoc;
currentDoc = new DocLnk();
listSheets.clear();
comboSheets->clear();
documentOpen(lnkDoc);
documentModified=FALSE;
}
void MainWindow::selectorShow()
{
sheet->hide();
setCentralWidget(fileSelector);
fileSelector->show();
fileSelector->reread();
}
void MainWindow::selectorHide()
{
fileSelector->hide();
setCentralWidget(sheet);
sheet->show();
}
void MainWindow::slotFileNew()
{
selectorFileNew(DocLnk());
}
@@ -391,445 +391,445 @@ void MainWindow::initMenu()
editCut->addTo(menuEdit);
editCopy->addTo(menuEdit);
editPaste->addTo(menuEdit);
editPasteContents->addTo(menuEdit);
editClear->addTo(menuEdit);
menu->insertItem(tr("&Edit"), menuEdit);
menuInsert=new QPopupMenu;
menu->insertItem(tr("&Insert"), menuInsert);
menuFormat=new QPopupMenu;
formatCells->addTo(menuFormat);
menu->insertItem(tr("&Format"), menuFormat);
menuData=new QPopupMenu;
dataSort->addTo(menuData);
dataFindReplace->addTo(menuData);
menu->insertItem(tr("&Data"), menuData);
// menuHelp=new QPopupMenu;
// helpGeneral->addTo(menuHelp);
// helpAbout->addTo(menuHelp);
// menu->insertItem(tr("&Help"), menuHelp);
submenuRow=new QPopupMenu;
rowHeight->addTo(submenuRow);
rowAdjust->addTo(submenuRow);
rowShow->addTo(submenuRow);
rowHide->addTo(submenuRow);
menuFormat->insertItem(tr("&Row"), submenuRow);
submenuCol=new QPopupMenu;
colWidth->addTo(submenuCol);
colAdjust->addTo(submenuCol);
colShow->addTo(submenuCol);
colHide->addTo(submenuCol);
menuFormat->insertItem(tr("Colum&n"), submenuCol);
submenuSheet=new QPopupMenu;
sheetRename->addTo(submenuSheet);
sheetRemove->addTo(submenuSheet);
menuFormat->insertItem(tr("&Sheet"), submenuSheet);
submenuFunc=new QPopupMenu;
menuInsert->insertItem(tr("&Function"), submenuFunc);
submenuFuncStd=new QPopupMenu;
funcPlus->addTo(submenuFuncStd);
funcMinus->addTo(submenuFuncStd);
funcCross->addTo(submenuFuncStd);
funcDivide->addTo(submenuFuncStd);
submenuFunc->insertItem(tr("&Simple"), submenuFuncStd);
submenuFuncStandard=new QPopupMenu;
addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard);
addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard);
addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard);
addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard);
addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard);
addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard);
addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard);
addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard);
submenuFuncStandard->insertSeparator();
addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard);
addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard);
addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard);
addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard);
addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard);
addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard);
submenuFuncStandard->insertSeparator();
addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard);
addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard);
addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard);
addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard);
addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard);
submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard);
submenuFuncLogic=new QPopupMenu;
addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic);
addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic);
addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic);
submenuFuncLogic->insertSeparator();
addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic);
addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic);
addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic);
addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic);
addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic);
addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic);
addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic);
addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic);
submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic);
submenuFuncTrig=new QPopupMenu;
addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig);
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)
{
QAction *action=new QAction(text, menuText, 0, this);
action->setToolTip(tip);
connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
action->addTo(w);
}
void MainWindow::slotFormatCells()
{
CellFormat dialogCellFormat(this);
QPEApplication::showDialog( &dialogCellFormat );
dialogCellFormat.exec(sheet);
}
void MainWindow::slotEditPaste()
{
sheet->editPaste();
}
void MainWindow::slotEditPasteContents()
{
sheet->editPaste(TRUE);
}
void MainWindow::slotRowHeight()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
NumberDialog dialogNumber(this);
if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted)
{
int newHeight=dialogNumber.getValue(), row;
for (row=row1; row<=row2; ++row)
sheet->setRowHeight(row, newHeight);
}
}
void MainWindow::slotRowAdjust()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int row=row1; row<=row2; ++row)
sheet->adjustRow(row);
}
void MainWindow::slotRowShow()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int row=row1; row<=row2; ++row)
sheet->showRow(row);
}
void MainWindow::slotRowHide()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int row=row1; row<=row2; ++row)
sheet->hideRow(row);
}
void MainWindow::slotColumnWidth()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
NumberDialog dialogNumber(this);
if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted)
{
int newWidth=dialogNumber.getValue(), col;
for (col=col1; col<=col2; ++col)
sheet->setColumnWidth(col, newWidth);
}
}
void MainWindow::slotColumnAdjust()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int col=col1; col<=col2; ++col)
sheet->adjustColumn(col);
}
void MainWindow::slotColumnShow()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int col=col1; col<=col2; ++col)
sheet->showColumn(col);
}
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,239 +1,239 @@
/***************************************************************************
* *
* 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();
}
}
QString Sheet::getParameter(const QString &parameters, int paramNo, bool giveError, const QString funcName)
{
QString params(parameters);
int position;
for (int i=0; i<paramNo; ++i)
{
position=params.find(',');
if (position<0)
{
if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\''));
//printf("params:%s\r\n",parameters.ascii());
return QString(NULL);
}
params=params.mid(position+1);
}
position=params.find(',');
if (position<0) return params;
return params.left(position);
}
bool Sheet::findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2)
{
int row, col;
if (!findRowColumn(variable1, row1, col1, FALSE) || !findRowColumn(variable2, row2, col2, FALSE)) return FALSE;
if (*row1>*row2)
{
row=*row1;
*row1=*row2;
*row2=row;
}
if (*col1>*col2)
{
col=*col1;
*col1=*col2;
*col2=col;
}
return TRUE;
}
bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError)
{
int position=variable.find(QRegExp("\\d"));
if (position<1)
{
if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\''));
return FALSE;
}
*row=variable.mid(position).toInt()-1;
*col=getHeaderColumn(variable.left(position))-1;
return TRUE;
}
QString Sheet::calculateVariable(const QString &variable)
{
bool ok;
printf("calculateVariable=%s,len=%d\r\n",variable.ascii(),variable.length());
if(variable.left(1)=="\"") return QString(variable.mid(1,variable.length()-2));
double tempResult=variable.toDouble(&ok);
if (ok)
{
if(tempResult!=0.0)
{
return QString::number(tempResult);
}
else
{
if(variable!="0" || variable!="0.0") return QString(variable); // hereis a string variable
return QString::number(tempResult);
};
};
int row, col;
if(findRowColumn(variable, &row, &col, FALSE)) return dataParser(variable, text(row,col));
//return (findRowColumn(variable, &row, &col, TRUE) ? dataParser(variable, text(row, col)) : 0);
return QString(variable);
}
double Sheet::BesselI0(double x)
{
//Returns the modi ed Bessel function I0(x) for any real x.
double ax,ans;
double y;
if ((ax=fabs(x)) < 3.75)
{
y=x/3.75;
y*=y;
ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
}else
{
y=3.75/ax;
ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1 +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2 +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1 +y*0.392377e-2))))))));
}
return ans;
};
double Sheet::BesselI1(double x)
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
@@ -1,470 +1,470 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** Licensees holding valid Qtopia Developer license may use this
** file in accordance with the Qtopia Developer License Agreement
** provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
** PURPOSE.
**
** email sales@trolltech.com for information about Qtopia License
** Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "mainwindow.h"
#include <qpe/fileselector.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
#include <qpe/fontdatabase.h>
//#include "qspellchecker.h"
#include "qtextedit.h"
#include <qaction.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qtabwidget.h>
#include <qapplication.h>
#include <qfontdatabase.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qfileinfo.h>
#include <qfile.h>
#include <qfiledialog.h>
#include <qprinter.h>
#include <qpaintdevicemetrics.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qcolordialog.h>
#include <qpainter.h>
#include <qstyle.h>
class ButtonMenu : public QToolButton
{
Q_OBJECT
public:
ButtonMenu( QWidget *parent, const char *name=0 )
: QToolButton( parent, name ), current(0)
{
setPopup( new QPopupMenu( this ) );
setPopupDelay( 1 );
connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) );
}
int insertItem(const QIconSet &icon, const QString &text, int id ) {
if ( !popup()->count() ) {
setIconSet( icon );
current = id;
}
return popup()->insertItem( icon, text, id );
}
void setCurrentItem( int id ) {
if ( id != current ) {
current = id;
setIconSet( *popup()->iconSet( id ) );
}
}
virtual QSize sizeHint() const {
return QToolButton::sizeHint() + QSize( 4, 0 );
}
signals:
void activated( int id );
protected slots:
void selected( int id ) {
current = id;
setIconSet( *popup()->iconSet( id ) );
emit activated( id );
}
protected:
virtual void drawButtonLabel( QPainter *p ) {
p->translate( -4, 0 );
QToolButton::drawButtonLabel( p );
p->translate( 4, 0 );
}
private:
int current;
};
//===========================================================================
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl )
: QMainWindow( parent, name, fl ),
doc( 0 )
{
setRightJustification(TRUE);
editorStack = new QWidgetStack( this );
fileSelector = new FileSelector( "text/html",
editorStack, "fileselector" );
fileSelector->setCloseVisible( FALSE );
editorStack->addWidget( fileSelector, 0 );
editor = new Qt3::QTextEdit( editorStack );
editor->setTextFormat( Qt::RichText );
editorStack->addWidget( editor, 1 );
setupActions();
QObject::connect( fileSelector, SIGNAL(closeMe()),
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,
Qt3::QStyleSheetItem::ListCircle );
else if ( i == 3 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListSquare );
else if ( i == 4 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListDecimal );
else if ( i == 5 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListLowerAlpha );
else if ( i == 6 )
currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem,
Qt3::QStyleSheetItem::ListUpperAlpha );
currentEditor()->viewport()->setFocus();
}
void MainWindow::textAlign( int a )
{
if ( !currentEditor() )
return;
editor->setAlignment( a );
}
void MainWindow::fontChanged( const QFont &f )
{
comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) );
updateFontSizeCombo( f );
comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
actionTextBold->setOn( f.bold() );
actionTextItalic->setOn( f.italic() );
actionTextUnderline->setOn( f.underline() );
}
void MainWindow::colorChanged( const QColor & )
{
}
void MainWindow::alignmentChanged( int a )
{
if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) {
alignMenu->setCurrentItem(AlignLeft);
} else if ( ( a & AlignCenter ) ) {
alignMenu->setCurrentItem(AlignCenter);
} else if ( ( a & AlignRight ) ) {
alignMenu->setCurrentItem(AlignRight);
} else if ( ( a & Qt3::AlignJustify ) ) {
alignMenu->setCurrentItem(Qt3::AlignJustify);
}
}
void MainWindow::editorChanged( QWidget * )
{
if ( !currentEditor() )
return;
fontChanged( currentEditor()->font() );
colorChanged( currentEditor()->color() );
alignmentChanged( currentEditor()->alignment() );
}
void MainWindow::fileOpen()
{
save();
editorStack->raiseWidget( fileSelector );
fileSelector->reread();
hideEditTools();
fileSelector->setNewVisible( TRUE );
clear();
updateCaption();
}
void MainWindow::fileRevert()
{
qDebug( "QMainWindow::fileRevert needs to be done" );
}
void MainWindow::fileNew()
{
editor->setTextFormat( Qt::RichText );
save();
newFile(DocLnk());
}
void MainWindow::insertTable()
{
qDebug( "MainWindow::insertTable() needs to be done" );
}
void MainWindow::newFile( const DocLnk &dl )
{
DocLnk nf = dl;
nf.setType( "text/html" );
clear();
editorStack->raiseWidget( editor );
editor->viewport()->setFocus();
doc = new DocLnk( nf );
updateCaption();
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
@@ -488,386 +488,386 @@ static bool block_set_alignment = FALSE;
\value MoveHome Moves the cursor to the beginning of the document
\value MoveEnd Moves the cursor to the end of the document
\value MovePgUp Moves the cursor one page up
\value MovePgDown Moves the cursor one page down
*/
/*!
\property QTextEdit::overwriteMode
\brief the text edit's overwrite mode
If FALSE (the default) characters entered by the user are inserted
with any characters to the right being moved out of the way.
If TRUE, the editor is in overwrite mode, i.e. characters entered by
the user overwrite any characters to the right of the cursor position.
*/
/*! \fn void QTextEdit::setCurrentFont( const QFont &f )
Sets the font of the current format to \a f.
\sa font() setPointSize() setFamily()
*/
/*!
\property QTextEdit::undoDepth
\brief the depth of the undo history
The maximum number of steps in the undo/redo history.
The default is 100.
\sa undo() redo()
*/
/*! \fn void QTextEdit::undoAvailable( bool yes )
This signal is emitted when the availability of undo changes. If \a
yes is TRUE, then undo() will work until undoAvailable( FALSE ) is
next emitted.
\sa undo() undoDepth()
*/
/*! \fn void QTextEdit::modificationChanged( bool m )
This signal is emitted when the modification of the document
changed. If \a m is TRUE, the document was modified, otherwise the
modification state has been reset to unmodified.
\sa modified
*/
/*! \fn void QTextEdit::redoAvailable( bool yes )
This signal is emitted when the availability of redo changes. If \a
yes is TRUE, then redo() will work until redoAvailable( FALSE ) is
next emitted.
\sa redo() undoDepth()
*/
/*! \fn void QTextEdit::currentFontChanged( const QFont &f )
This signal is emitted if the font of the current format has changed.
The new font is \a f.
\sa setCurrentFont()
*/
/*! \fn void QTextEdit::currentColorChanged( const QColor &c )
This signal is emitted if the color of the current format has changed.
The new color is \a c.
\sa setColor()
*/
/*! \fn void QTextEdit::currentVerticalAlignmentChanged( VerticalAlignment a )
This signal is emitted if the vertical alignment of the current
format has changed.
The new vertical alignment is \a a.
\sa setVerticalAlignment()
*/
/*! \fn void QTextEdit::currentAlignmentChanged( int a )
This signal is emitted if the alignment of the current paragraph
has changed.
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 */
void QTextEdit::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
{
paintDocument( TRUE, p, cx, cy, cw, ch );
int v;
p->setPen( foregroundColor() );
if ( document()->isPageBreakEnabled() && ( v = document()->flow()->pageSize() ) > 0 ) {
int l = int(cy / v) * v;
while ( l < cy + ch ) {
p->drawLine( cx, l, cx + cw - 1, l );
l += v;
}
}
}
/*! \reimp */
void QTextEdit::drawContents( QPainter * )
{
}
/*! \reimp */
bool QTextEdit::event( QEvent *e )
{
if ( e->type() == QEvent::AccelOverride && !isReadOnly() ) {
QKeyEvent* ke = (QKeyEvent*) e;
if ( ke->state() == NoButton || ke->state() == Keypad ) {
if ( ke->key() < Key_Escape ) {
ke->accept();
} else {
switch ( ke->key() ) {
case Key_Return:
case Key_Enter:
case Key_Delete:
case Key_Home:
case Key_End:
case Key_Backspace:
ke->accept();
default:
break;
}
}
} else if ( ke->state() & ControlButton ) {
switch ( ke->key() ) {
// Those are too frequently used for application functionality
/* case Key_A:
case Key_B:
case Key_D:
case Key_E:
case Key_F:
case Key_H:
case Key_I:
case Key_K:
case Key_N:
case Key_P:
case Key_T:
*/
case Key_C:
case Key_V:
case Key_X:
case Key_Y:
case Key_Z:
case Key_Left:
case Key_Right:
case Key_Up:
case Key_Down:
case Key_Home:
case Key_End:
case Key_Tab:
#if defined (Q_WS_WIN)
case Key_Insert:
case Key_Delete:
#endif
ke->accept();
default:
break;
}
} else {
switch ( ke->key() ) {
#if defined (Q_WS_WIN)
case Key_Insert:
ke->accept();
#endif
default:
break;
}
}
}
if ( e->type() == QEvent::Show ) {
if ( d->ensureCursorVisibleInShowEvent ) {
sync();
ensureCursorVisible();
d->ensureCursorVisibleInShowEvent = FALSE;
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,446 +1,446 @@
#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 ) );
//set the account description
accountdescription->setText ( account->getAccountDescription ( accountid ) );
if ( preferences->getPreference ( 4 ) == 1 )
{
// get currency code for this account then iterate through the currency box
// to find the one we want
int count = currencybox->currencybox->count();
QString code = account->getCurrencyCode ( accountid );
for ( int counter = 0; count - 1; counter++ )
{
if ( QString::compare ( currencybox->currencybox->text ( counter ), code ) == 0 )
{
currencybox->currencybox->setCurrentItem ( counter );
break;
}
}
}
else
currencybox->setEnabled ( FALSE );
//execute the dialog box
int response = editaccountwindow->exec();
if ( response == 1 )
{
account->updateAccount ( accountname->text(), accountdescription->text(), currencybox->currencybox->currentText(), accountid );
account->displayAccounts ( listview );
// Try and select the same account that was just edited
QListViewItemIterator it ( listview );
for ( ; it.current(); ++it )
{
if ( it.current()->text ( 0 ) == accountname->text() )
{
listview->setSelected ( it.current(), TRUE );
return;
}
}
maintabs->setTabEnabled ( tab2, FALSE );
}
}
}
void AccountDisplay::setAccountExpanded ( QListViewItem *item )
{
int accountid = item->text ( getIDColumn() ).toInt();
account->setAccountExpanded ( 1, accountid );
}
void AccountDisplay::setAccountCollapsed ( QListViewItem *item )
{
int accountid = item->text ( getIDColumn() ).toInt();
account->setAccountExpanded ( 0, accountid );
}
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,274 +1,274 @@
#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 )
{
QString flag = "/opt/QtPalmtop/pics/flags/";
flag.append ( budget->getCurrency ( (*it).toInt() ) );
flag.append ( ".png" );
budgetbox->insertItem ( QPixmap ( flag ), budget->getBudgetName ( (*it).toInt() ) );
}
setCurrentBudget ( 0 );
}
else
checkBudgets();
}
void BudgetDisplay::setCurrentBudget ( int index )
{
currentbudget = ( ids->operator[] ( index ).toInt() );
displayLineItems();
}
void BudgetDisplay::setCurrentView ( int index )
{
displayLineItems();
}
void BudgetDisplay::showCalendar ()
{
// create new calendar object and show it
DatePicker *dp = new DatePicker ( QDate ( year, month, day ) );
dp->daylabel->hide();
dp->daybox->hide();
if ( budgetview->currentItem() == 1 )
{
dp->monthlabel->hide();
dp->monthbox->hide();
}
dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
int response = dp->exec();
if ( response == 1 )
{
// Set date integers
year = dp->getYear();
if ( budgetview->currentItem() == 0 )
month = dp->getMonth();
else
month = newDate.month();
datelabel = preferences->getDate ( year, month );
displayLineItems();
}
}
void BudgetDisplay::newLineItem ()
{
//construct and format the new line item window
constructLineItemWindow ();
int response = newlineitem->exec();
if ( response == 1 )
{
float amount;
if ( lineitemtime->currentItem() == 0 )
amount = lineitemamount->text().toFloat();
else if ( lineitemtime->currentItem() == 1 )
amount = lineitemamount->text().toFloat() * 12;
else
amount = lineitemamount->text().toFloat() * 52;
int lineitemadded = budget->addLineItem ( currentbudget, lineitemname->text(), amount, lineitemtime->currentItem() );
transaction->clearBudgetIDs ( currentbudget, lineitemadded );
displayLineItems();
}
checkBudgets();
}
void BudgetDisplay::constructLineItemWindow ()
{
//construct and format the new budget window
newlineitem = new QDialog ( this, 0, TRUE );
newlineitem->setCaption ( "Line Item" );
QLabel *namelabel = new QLabel ( "Line Item Name", newlineitem );
lineitemname = new QLineEdit ( newlineitem );
QLabel *budgetamountlabel = new QLabel ( "Budget Amount", newlineitem );
lineitemamount = new QLineEdit ( newlineitem );
QLabel *lineitemtimelabel = new QLabel ( "Per:", newlineitem );
lineitemtime = new QComboBox ( newlineitem );
lineitemtime->insertItem ( "Year" ); // type 0
lineitemtime->insertItem ( "Month" ); // type 1
lineitemtime->insertItem ( "Week" ); // type 2
QBoxLayout *layout = new QVBoxLayout ( newlineitem, 2, 2 );
layout->addWidget ( namelabel );
layout->addWidget ( lineitemname );
layout->addWidget ( budgetamountlabel );
layout->addWidget ( lineitemamount );
layout->addWidget ( lineitemtimelabel );
layout->addWidget ( lineitemtime );
}
void BudgetDisplay::deleteLineItem ()
{
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,206 +1,206 @@
#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 ()
{
return accountdescription;
}
void NewAccount::setDescription ( QString description )
{
accountdescription = description;
}
void NewAccount::addAccountDescription ()
{
// Function for adding or editing an account 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 ( accountdescription != "(NULL)" )
enter->setText ( accountdescription );
if ( description->exec () == QDialog::Accepted )
accountdescription = enter->text ();
}
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,274 +1,274 @@
#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();
for ( counter = 0; ( items - 1 ); counter++ )
{
if ( name == transactionname->text ( counter ) )
{
return counter;
break;
}
}
return 0;
}
void NewTransaction::setCurrentBudget ( int index )
{
if ( index != 0 )
{
currentbudget = budgetidslist->operator[] ( index - 1 ).toInt();
lineitemslist = budget->getLineItems ( currentbudget );
lineitemidslist = budget->getLineItemIDs ( currentbudget );
lineitemlabel->setEnabled ( TRUE );
lineitembox->setEnabled ( TRUE );
lineitembox->clear();
lineitembox->insertStringList ( lineitemslist );
setCurrentLineItem ( 0 );
}
else
{
lineitembox->clear();
lineitemlabel->setEnabled ( FALSE );
lineitembox->setEnabled ( FALSE );
currentlineitem = -1;
currentbudget = -1;
}
}
void NewTransaction::setCurrentLineItem ( int index )
{
currentlineitem = ( lineitemidslist.operator[] ( index ).toInt() );
}
int NewTransaction::getCurrentBudget ()
{
return currentbudget;
}
int NewTransaction::getBudgetIndex ( int budgetid )
{
currentbudget = budgetid;
const QString budget = QString::number ( budgetid );
return budgetidslist->findIndex ( budget );
}
int NewTransaction::getLineItemIndex ( int lineitemid )
{
currentlineitem = lineitemid;
const QString lineitem = QString::number ( lineitemid );
return lineitemidslist.findIndex ( lineitem );
}
void NewTransaction::setLineItems ()
{
lineitemslist = budget->getLineItems ( currentbudget );
lineitemidslist = budget->getLineItemIDs ( currentbudget );
lineitemlabel->setEnabled ( TRUE );
lineitembox->setEnabled ( TRUE );
lineitembox->clear();
lineitembox->insertStringList ( lineitemslist );
}
int NewTransaction::getCurrentLineItem ()
{
return currentlineitem;
}
void NewTransaction::setComboBoxes ( int budgetid, int lineitemid )
{
const QString budgetname = QString::number ( budgetid );
budgetbox->setCurrentItem ( ( budgetidslist->findIndex ( budgetname ) ) );
currentbudget = budgetidslist->operator[] ( budgetbox->currentItem() - 1 ).toInt();
lineitemslist = budget->getLineItems ( currentbudget );
lineitemidslist = budget->getLineItemIDs ( currentbudget );
lineitemlabel->setEnabled ( TRUE );
lineitembox->setEnabled ( TRUE );
lineitembox->clear();
lineitembox->insertStringList ( lineitemslist );
const QString lineitem = QString::number ( lineitemid );
lineitembox->setCurrentItem ( lineitemidslist.findIndex ( lineitem ) );
currentlineitem = ( lineitemidslist.operator[] ( lineitembox->currentItem() ).toInt() );
}
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,402 +1,402 @@
#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 );
transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 5 ) ); // normal transaction amount width
transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual );
}
else
{
transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 6 ) ); // extended transaction date width
transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual );
transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 7 ) ); // extended transaction name width
transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual );
transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 8 ) ); // extended transaction amount width
transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual );
transactiondisplay->listview->setColumnWidth ( 4, preferences->getColumnPreference ( 9 ) ); // transaction account width
transactiondisplay->listview->setColumnWidthMode ( 4, QListView::Manual );
}
// pull the column sorting preference from the preferences table, and configure the listview accordingly
int column = 0;
int direction = 0;
preferences->getSortingPreference ( 2, &column, &direction );
transactiondisplay->listview->setSorting ( column, direction );
// show the window
transactiondisplay->show();
// hide the account display and define accountid
accountdisplay->hide();
// hide the budget display
budgetdisplay->hide();
}
else if ( maintabs->currentPageIndex() == 0 )
{
disableOneTouchViewing();
// clear the account display selection
accountdisplay->listview->clearSelection();
// resize the account display columns
accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) );
accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) );
// set sorting preference on account display columns
int column = 0;
int direction = 0;
preferences->getSortingPreference ( 1, &column, &direction );
accountdisplay->listview->setSorting ( column, direction );
// display the accounts
if ( account->getNumberOfAccounts() != 0 )
account->displayAccounts ( accountdisplay->listview );
maintabs->setTabEnabled ( tab_2, FALSE );
// set the toggle button
accountdisplay->setToggleButton ();
// show the account display
accountdisplay->show();
// hide the transaction display
transactiondisplay->hide();
// hide the budget display
budgetdisplay->hide();
enableOneTouchViewing ();
}
else
{
budgetdisplay->displayLineItems();
budgetdisplay->show();
transactiondisplay->hide();
accountdisplay->hide();
}
}
void QashMoney::setTransactionTab ()
{
if ( accountdisplay->listview->selectedItem() == 0 )
maintabs->setTabEnabled ( tab_2, FALSE );
else
maintabs->setTabEnabled ( tab_2, TRUE );
}
void QashMoney::displayDatePreferencesDialog ()
{
// this shows a dialog to set preferences for formatting the date
DatePreferences *pd = new DatePreferences ( this );
pd->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 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,408 +1,408 @@
#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 )
{
newtransaction->setLineItems ();
newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) );
}
else
{
newtransaction->lineitemlabel->setEnabled ( FALSE );
newtransaction->lineitembox->setEnabled ( FALSE );
}
}
else
{
newtransaction->lineitemlabel->setEnabled ( FALSE );
newtransaction->lineitembox->setEnabled ( FALSE );
}
// check cleared checkbox if necessary
if ( transaction->getCleared ( transactionid ) == 1 )
newtransaction->clearedcheckbox->setChecked ( TRUE );
// check deposit box if necessary
if ( transaction->getAmount ( transactionid ).toFloat() > 0 )
newtransaction->depositbox->setChecked ( TRUE );
if ( newtransaction->exec () == QDialog::Accepted )
{
if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
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() );
// update the transaction
transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(),
newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(),
amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
updateAndDisplay ( transaction->getAccountID ( transactionid ) );
}
}
void TransactionDisplay::updateAndDisplay ( int id )
{
// 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 ( id );
if ( account->getParentAccountID ( id ) != -1 )
account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
// format then reset the account balance
redisplayAccountBalance ();
}
void TransactionDisplay::checkListViewDelete ()
{
if ( listview->selectedItem() == 0 )
QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete.");
else
deleteTransaction ();
}
void TransactionDisplay::deleteTransaction ()
{
int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
if ( transactionid > 0 ) // takes care of deleting transactions
{
// check if we are viewing child transactions through a parent
// in that case we will have to update balances for the parent
// which is represented by accountid and the child account
// which will be represented by childaccountid
int childaccountid = -1;
if ( listview->columns() == 5 )
childaccountid = transaction->getAccountID ( transactionid );
transaction->deleteTransaction ( transactionid );
listview->clear();
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
@@ -1,357 +1,357 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/* local includes */
#include "tableviewer.h"
#include "ui/tvbrowseview.h"
#include "ui/tvfilterview.h"
#include "ui/tvlistview.h"
#include "ui/tveditview.h"
#include "ui/tvkeyedit.h"
#include "db/datacache.h"
/* QPE includes */
#include <qpe/fileselector.h>
#include <qpe/resource.h>
#include <qpe/qpetoolbar.h>
/* QTE includes */
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qapplication.h>
#include <qwidgetstack.h>
#include <qlayout.h>
#include <qbuffer.h>
/*!
\class TableViewerWindow
\brief The main window widget of the application
This is the main widget of the table viewer application.
It is the co-ordination point.
*/
/*!
Constructs a new TableViewerWindow
*/
TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f)
: QMainWindow(parent, name, f)
{
setCaption(tr("Table Viewer"));
/* Build data */
ds = new DBStore();
doc.setType("text/x-xml-tableviewer");
doc.setName("table");
dirty = FALSE;
ts.current_column = 0;
ts.kRep = ds->getKeys();
/* build menus */
menu = new QMenuBar(this, 0);
QPopupMenu *file_menu = new QPopupMenu;
file_menu->insertItem("New", this, SLOT(newDocument()));
file_menu->insertItem("Open", this, SLOT(selectDocument()));
file_menu->insertSeparator();
file_menu->insertItem("Properties");
/* later will want to set this up to clean up first via this, SLOT(quit) */
menu->insertItem("Document", file_menu);
QPopupMenu *edit_menu = new QPopupMenu;
edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot()));
edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot()));
edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot()));
menu->insertItem("Edit", edit_menu);
QPopupMenu *view_menu = new QPopupMenu;
view_menu->insertItem("Browse View", this, SLOT(browseViewSlot()));
view_menu->insertItem("List View", this, SLOT(listViewSlot()));
menu->insertItem("View", view_menu);
QVBoxLayout *main_layout = new QVBoxLayout;
/* Build tool bar */
navigation = new QToolBar(this, "navigation");
QToolButton *newItemButton = new QToolButton(
QIconSet(Resource::loadPixmap("new")), "New Item", QString::null,
this, SLOT(newItemSlot()), navigation, "New Item");
QToolButton *editItemButton = new QToolButton(
QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null,
this, SLOT(editItemSlot()), navigation, "Edit Item");
QToolButton *deleteItemButton = new QToolButton(
QIconSet(Resource::loadPixmap("trash")), "Delete Item",
QString::null, this,
SLOT(deleteItemSlot()), navigation, "Delete Item");
navigation->addSeparator();
QToolButton *firstItemButton = new QToolButton(
QIconSet(Resource::loadPixmap("fastback")), "First Item",
QString::null, this,
SLOT(firstItem()), navigation, "First Item");
QToolButton *previousItemButton = new QToolButton(
QIconSet(Resource::loadPixmap("back")), "Previous Item",
QString::null, this,
SLOT(previousItem()), navigation, "Previous Item");
QToolButton *nextItemButton = new QToolButton(
QIconSet(Resource::loadPixmap("forward")), "Next Item",
QString::null, this,
SLOT(nextItem()), navigation, "Next Item");
QToolButton *lastItemButton = new QToolButton(
QIconSet(Resource::loadPixmap("fastforward")), "Last Item",
QString::null, this,
SLOT(lastItem()), navigation, "Last Item");
navigation->addSeparator();
QToolButton *browseButton = new QToolButton(
QIconSet(Resource::loadPixmap("day")), "View Single Item",
QString::null, this,
SLOT(browseViewSlot()), navigation, "View Single Item");
QToolButton *listButton = new QToolButton(
QIconSet(Resource::loadPixmap("month")), "View Multiple Items",
QString::null, this,
SLOT(listViewSlot()), navigation, "View Multiple Items");
setToolBarsMovable(FALSE);
setToolBarsMovable(FALSE);
setToolBarsMovable(FALSE);
/* Build widgets */
browseView = new TVBrowseView(&ts, this, 0);
listView = new TVListView(&ts, this, 0);
filterView = new TVFilterView(&ts, this, 0);
fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer",
this, "fileselector");
fileSelector->setNewVisible(FALSE);
fileSelector->setCloseVisible(FALSE);
cw = new QWidgetStack(this, 0);
cw->addWidget(listView, ListState);
cw->addWidget(browseView, BrowseState);
cw->addWidget(filterView, FilterState);
cw->addWidget(fileSelector, FileState);
current_view = FileState;
cw->raiseWidget(current_view);
fileSelector->reread();
- connect(browseView, SIGNAL(searchOnKey(int, TVVariant)),
- this, SLOT(searchOnKey(int, TVVariant)));
+ connect(browseView, SIGNAL(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);
/* set up new table state and ensure sub widgets have a reference */
ts.current_column = 0;
ts.kRep = ds->getKeys();
browseView->rebuildKeys();
listView->rebuildKeys();
filterView->rebuildKeys();
ds->first();
/* set up the list view */
listView->clearItems();
do {
d = ds->getCurrentData();
if(d)
listView->addItem(d);
} while(ds->next());
/* Set up browse view, Will be based of structure of listView */
listView->first();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
listView->rebuildData();
QString scratch = "Table Viewer";/* later take from constant */
scratch += " - ";
scratch += ds->getName();
setCaption(tr(scratch));
dirty = FALSE;
} else {
qWarning(tr("could not load Document"));
}
dev->close();
}
/*!
Moves to the first item of the current table
*/
void TableViewerWindow::firstItem()
{
listView->first();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Moves to the lat item of the current table
*/
void TableViewerWindow::lastItem()
{
listView->last();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Moves to the next item of the current table
*/
void TableViewerWindow::nextItem()
{
listView->next();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Moves to the previous item of the current table
*/
void TableViewerWindow::previousItem()
{
listView->previous();
ts.current_elem = listView->getCurrentData();
browseView->rebuildData();
}
/*!
Raises the List View. This is a mode change for the application.
*/
void TableViewerWindow::listViewSlot()
{
if(current_view == FilterState)
applyFilter();
current_view = ListState;
cw->raiseWidget(current_view);
}
void TableViewerWindow::applyFilter()
{
DataElem *d;
listView->clearItems();
ds->first();
do {
d = ds->getCurrentData();
if(d)
if(filterView->passesFilter(d))
listView->addItem(d);
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,210 +1,210 @@
/**********************************************************************
** 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) {
/* pm */
h = h + 12;
}
/* hour now ranges 1->24 */
if (h == 12)
h = 0;
if (h == 24)
h = 12;
if(QTime::isValid(h, m, s))
return QTime(h, m, s);
return QTime(0, 0, 0);
}
void TimeEdit::setTime(QTime t)
{
int h = t.hour();
secondKey->setValue(t.second());
minuteKey->setValue(t.minute());
/* h 0..23 */
if (h > 11) {
h -= 12;
ampm->setCurrentItem(1);
} else {
ampm->setCurrentItem(0);
}
if (h == 0) h = 12;
hourKey->setValue(h);
}
QSizePolicy TimeEdit::sizePolicy() const
{
QSizePolicy sp;
sp.setHorData(QSizePolicy::Preferred);
sp.setVerData(QSizePolicy::Fixed);
return sp;
}
void TimeEdit::clear()
{
secondKey->setValue(0);
minuteKey->setValue(0);
hourKey->setValue(12);
ampm->setCurrentItem(0);
}
void TimeEdit::subValueChanged()
{
emit valueChanged(time());
}
IntEdit::IntEdit( QWidget *parent, const char *name, WFlags f )
: QSpinBox(INT_MIN, INT_MAX, 1, parent, name)
{
setValue(0);
}
IntEdit::~IntEdit() {}
int IntEdit::value()
{
return cleanText().toInt();
}
void IntEdit::clear()
{
setValue(0);
}
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,284 +1,284 @@
/**********************************************************************
** 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
return do_filter;
*/
if (terms.isEmpty())
return false;
return true;
}
/* SLOTS */
void TVFilterView::newTerm()
{
if (!ts) return;
FilterTerm *term = new FilterTerm;
current = term;
term->view = 0;
updateTerm();
display->setSelected(term->view, true);
terms.append(term);
keyEntry->setEnabled(true);
keyNameCombo->setEnabled(true);
}
void TVFilterView::updateTerm()
{
FilterTerm *term;
/* Read the widget values (keyname, compare type, value)
* and build the lists */
if (!ts) return;
if (!current) return;
QString keyString;
QString cmpString;
QString vString;
term = current;
/* create new list item, set initial values, enable widgets */
term->keyIndex = keyIds[keyNameCombo->currentItem()];
keyEntry->setKey(term->keyIndex); /* so the next two items make sense */
term->ct = keyEntry->getCompareType(),
term->value = keyEntry->getCompareValue();
keyString = keyNameCombo->currentText();
switch(term->ct) {
case ct_less:
cmpString = " less than ";
break;
case ct_more:
cmpString = " more than ";
break;
case ct_equal:
cmpString = " equal to ";
break;
case ct_contains:
cmpString = " containing ";
break;
case ct_startswith:
cmpString = " starting with ";
break;
case ct_endswith:
cmpString = " ending with ";
break;
default:
cmpString = " ERROR ";
}
vString = term->value.toString();
/* remove old view */
if (term->view)
delete(term->view);
term->view = new QListViewItem(display, 0, keyString, cmpString, vString);
display->setSelected(term->view, true);
}
/* deletes current term */
void TVFilterView::deleteTerm()
{
if(!current) return;
if (current->view)
delete(current->view);
terms.removeRef(current);
current = terms.first();
if(terms.isEmpty()) {
keyEntry->setEnabled(false);
keyNameCombo->setEnabled(false);
}
}
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
@@ -1,300 +1,300 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "tvlistview.h"
#include "../db/common.h"
#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(
((TVListViewItem *)i)->getDataElem(),
best_so_far->getDataElem(), value, keyId))
best_so_far = (TVListViewItem *)i;
} else {
if (DataElem::closer(
((TVListViewItem *)i)->getDataElem(),
NULL, value, keyId))
best_so_far = (TVListViewItem *)i;
}
i = i->itemBelow();
}
if (best_so_far) {
/* set best_so_far to current element */
delete it;
it = new QListViewItemIterator(best_so_far);
}
}
void TVListView::rebuildKeys()
{
int i;
if(!ts) return;
if(!ts->kRep) return;
i = listViewDisplay->columns();
while(i > 0)
listViewDisplay->removeColumn(--i);
KeyListIterator kit(*ts->kRep);
i = 0;
while(kit.current()) {
if(!kit.current()->delFlag()) {
listViewDisplay->addColumn(kit.current()->name());
keyIds.insert(i, kit.currentKey());
++i;
}
++kit;
}
}
void TVListView::setSorting(int column)
{
/* Without table state can't do anything */
if (ts == 0)
return;
if (keyIds[column] != ts->current_column) {
ts->current_column = keyIds[column];
}
}
void TVListView::rebuildData() {
int i;
QMap<int, int>::Iterator kit;
/* Need to set sort order */
if(!ts)
return;
/* revers lookup the column */
i = -1;
for(kit = keyIds.begin(); kit != keyIds.end(); ++kit) {
if (kit.data() == ts->current_column) {
i = kit.key();
break;
}
}
if (i == -1)
return;
listViewDisplay->setSorting(i);
listViewDisplay->sort();
/* reset current element */
listViewDisplay->setCurrentItem(it->current());
listViewDisplay->setSelected(it->current(), true);
listViewDisplay->ensureItemVisible(it->current());
}
void TVListView::reset()
{
int i;
listViewDisplay->clear();
i = listViewDisplay->columns();
while (i > 0)
listViewDisplay->removeColumn(--i);
keyIds.clear();
}
void TVListView::setCurrent(QListViewItem *i)
{
/* cast */
TVListViewItem *t = (TVListViewItem *)i;
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,481 +1,481 @@
/***************************************************************************
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 );
hbox1->layout()->setMargin(5);
QVBox *vbox1=new QVBox(hbox1);
// grid->addMultiCellWidget(vbox1,0,0,0,1);
QVGroupBox *vbox2 = new QVGroupBox( i18n("Item Style"), page2 );
// grid->addWidget(vbox2,1,0);
QVGroupBox *vbox3 = new QVGroupBox( i18n("Highlight Auto Select"), hbox1 );
//grid->addWidget(vbox3,1,1);
QLabel *label = new QLabel( i18n("Highlight:"), vbox1 );
hlCombo = new QComboBox( false, vbox1 );
QHBox *modHl = new QHBox(vbox1);
// connect(new QPushButton(i18n("New"),modHl),SIGNAL(clicked()),this,SLOT(hlNew()));
// connect(new QPushButton(i18n("Edit"),modHl),SIGNAL(clicked()),this,SLOT(hlEdit()));
connect( hlCombo, SIGNAL(activated(int)),
this, SLOT(hlChanged(int)) );
for( int i = 0; i < hlManager->highlights(); i++) {
hlCombo->insertItem(hlManager->hlName(i));
}
hlCombo->setCurrentItem(hlNumber);
label = new QLabel( i18n("Item:"), vbox2 );
itemCombo = new QComboBox( false, vbox2 );
connect( itemCombo, SIGNAL(activated(int)), this, SLOT(itemChanged(int)) );
label = new QLabel( i18n("File Extensions:"), vbox3 );
wildcards = new QLineEdit( vbox3 );
label = new QLabel( i18n("Mime Types:"), vbox3 );
mimetypes = new QLineEdit( vbox3 );
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);
data=HlManager::self()->syntax->getGroupInfo("highlighting","context");
int i=0;
if (data)
{
while (HlManager::self()->syntax->nextGroup(data)) //<context tags>
{
kdDebug(13010)<< "Adding context to list"<<endl;
last= new QListViewItem(contextList,last,
HlManager::self()->syntax->groupData(data,QString("name")),
QString("%1").arg(i),
HlManager::self()->syntax->groupData(data,QString("attribute")),
HlManager::self()->syntax->groupData(data,QString("lineEndContext")));
i++;
lastsub=0;
while (HlManager::self()->syntax->nextItem(data))
{
kdDebug(13010)<< "Adding item to list"<<endl;
lastsub=addContextItem(last,lastsub,data);
}
}
if (data) HlManager::self()->syntax->freeGroupInfo(data);
}
ContextAttribute->clear();
ItemAttribute->clear();
data=HlManager::self()->syntax->getGroupInfo("highlighting","itemData");
while (HlManager::self()->syntax->nextGroup(data))
{
ContextAttribute->insertItem(HlManager::self()->syntax->groupData(data,QString("name")));
ItemAttribute->insertItem(HlManager::self()->syntax->groupData(data,QString("name")));
}
if (data) HlManager::self()->syntax->freeGroupInfo(data);
}
QListViewItem *HlEditDialog::addContextItem(QListViewItem *_parent,QListViewItem *prev,struct syntaxContextData *data)
{
kdDebug(13010)<<HlManager::self()->syntax->groupItemData(data,QString("name")) << endl;
QString dataname=HlManager::self()->syntax->groupItemData(data,QString(""));
QString attr=(HlManager::self()->syntax->groupItemData(data,QString("attribute")));
QString context=(HlManager::self()->syntax->groupItemData(data,QString("context")));
char chr;
if (! HlManager::self()->syntax->groupItemData(data,QString("char")).isEmpty())
chr= (HlManager::self()->syntax->groupItemData(data,QString("char")).latin1())[0];
else
chr=0;
QString stringdata=HlManager::self()->syntax->groupItemData(data,QString("String"));
char chr1;
if (! HlManager::self()->syntax->groupItemData(data,QString("char1")).isEmpty())
chr1= (HlManager::self()->syntax->groupItemData(data,QString("char1")).latin1())[0];
else
chr1=0;
bool insensitive=(HlManager::self()->syntax->groupItemData(data,QString("insensitive"))==QString("TRUE"));
QString param("");
if ((dataname=="keyword") || (dataname=="dataType")) param=dataname;
else if (dataname=="CharDetect") param=chr;
else if ((dataname=="2CharDetect") || (dataname=="RangeDetect")) param=QString("%1%2").arg(chr).arg(chr1);
else if ((dataname=="StringDetect") || (dataname=="AnyChar") || (dataname=="RegExpr")) param=stringdata;
else kdDebug(13010)<<"***********************************"<<endl<<"Unknown entry for Context:"<<dataname<<endl;
kdDebug(13010)<<dataname << endl;
return new QListViewItem(_parent,prev,i18n(dataname.latin1())+" "+param,dataname,param,attr,context);
}
void HlEditDialog::currentSelectionChanged ( QListViewItem *it)
{
kdDebug(13010)<<"Update data view"<<endl<<"Depth:"<<it->depth()<<endl;
currentItem=it;
if (it->depth()==0) showContext();
else showItem();
}
/****************************************************************************/
/* CONTEXTS */
/****************************************************************************/
void HlEditDialog::showContext()
{
stack->raiseWidget(HlEContext);
ContextDescr->setText(currentItem->text(0));
ContextAttribute->setCurrentItem(currentItem->text(2).toInt());
ContextLineEnd->clear();
for (QListViewItem *it=contextList->firstChild();it;it=it->nextSibling())
ContextLineEnd->insertItem(it->text(0));
ContextLineEnd->setCurrentItem(currentItem->text(3).toInt());
// ContextAttribute->setText(currentItem->text(1));
// ContextLineEnd->setText(currentItem->text(2));
}
void HlEditDialog::contextDescrChanged(const QString& name)
{
if (currentItem)
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
@@ -1,363 +1,363 @@
/***************************************************************************
katedocument.cpp - description
-------------------
begin : Mon Jan 15 2001
copyright : (C) 2001 by Christoph "Crossfire" Cullmann
(C) 2002 by Joseph Wenninger
email : crossfire@babylon2k.de
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. *
* *
***************************************************************************/
/*
Copyright (C) 1998, 1999 Jochen Wilhelmy
digisnap@cs.tu-berlin.de
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "katedocument.h"
#include <qfileinfo.h>
#include <qdatetime.h>
#include <kmessagebox.h>
#include <qpe/config.h>
#include <qstring.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <qtimer.h>
#include <qobject.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <qfont.h>
#include <qpainter.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <kglobal.h>
//#include <kcharsets.h>
#include <kdebug.h>
//#include <kinstance.h>
#include <kglobalsettings.h>
//#include <kaction.h>
//#include <kstdaction.h>
#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)
{
till = max;
}
PreHighlightedTill = till;
updateLines(from,till);
emit preHighlightChanged(PreHighlightedTill);
if (PreHighlightedTill<RequestPreHighlightTill)
QTimer::singleShot(10,this,SLOT(doPreHighlight()));
}
KateDocument::~KateDocument()
{
m_highlight->release();
writeConfig();
if ( !m_bSingleViewMode )
{
m_views.setAutoDelete( true );
m_views.clear();
m_views.setAutoDelete( false );
}
delete_d(this);
}
void KateDocument::openURL(const QString &filename)
{
m_file=filename;
fileInfo->setFile (m_file);
setMTime();
if (!fileInfo->exists() || !fileInfo->isReadable())
{
qDebug("File doesn't exit or couldn't be read");
return ;
}
buffer->clear();
#warning fixme
// buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding));
qDebug("Telling buffer to open file");
buffer->insertFile(0, m_file, QTextCodec::codecForLocale());
setMTime();
if (myWordWrap)
wrapText (myWordWrapAt);
int hl = hlManager->wildcardFind( m_file );
setHighlight(hl);
updateLines();
updateViews();
emit fileNameChanged();
return ;
}
bool KateDocument::saveFile()
{
QFile f( m_file );
if ( !f.open( IO_WriteOnly ) )
return false; // Error
QTextStream stream(&f);
stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers
#warning fixme
// stream.setCodec(KGlobal::charsets()->codecForName(myEncoding));
stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec
int maxLine = numLines();
int line = 0;
while(true)
{
stream << getTextLine(line)->getString();
line++;
if (line >= maxLine) break;
if (eolMode == KateDocument::eolUnix) stream << "\n";
else if (eolMode == KateDocument::eolDos) stream << "\r\n";
else if (eolMode == KateDocument::eolMacintosh) stream << '\r';
};
f.close();
fileInfo->setFile (m_file);
setMTime();
if (!(d(this)->hlSetByUser))
{
int hl = hlManager->wildcardFind( m_file );
setHighlight(hl);
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
@@ -346,226 +346,226 @@ void SelectConfigTab::getData(KateView *view) {
if (opt[z]->isChecked()) configFlags |= flags[z]; // set flag if checked
}
view->setConfig(configFlags);
}
const int EditConfigTab::flags[] = {KateView::cfWordWrap, KateView::cfReplaceTabs, KateView::cfRemoveSpaces,
KateView::cfAutoBrackets, KateView::cfGroupUndo, KateView::cfShowTabs, KateView::cfSmartHome,
KateView::cfPageUDMovesCursor, KateView::cfWrapCursor};
EditConfigTab::EditConfigTab(QWidget *parent, KateView *view)
: QWidget(parent, 0L) {
QHBoxLayout *mainLayout;
QVBoxLayout *cbLayout, *leLayout;
int configFlags;
mainLayout = new QHBoxLayout(this, 0, KDialog::spacingHint() );
// checkboxes
cbLayout = new QVBoxLayout( mainLayout );
configFlags = view->config();
opt[0] = new QCheckBox(i18n("&Word wrap"), this);
cbLayout->addWidget(opt[0], 0, AlignLeft);
opt[0]->setChecked(view->doc()->wordWrap());
opt[1] = new QCheckBox(i18n("Replace &tabs with spaces"), this);
cbLayout->addWidget(opt[1], 0, AlignLeft);
opt[1]->setChecked(configFlags & flags[1]);
opt[2] = new QCheckBox(i18n("&Remove trailing spaces"), this);
cbLayout->addWidget(opt[2], 0, AlignLeft);
opt[2]->setChecked(configFlags & flags[2]);
opt[3] = new QCheckBox(i18n("&Auto brackets"), this);
cbLayout->addWidget(opt[3], 0, AlignLeft);
opt[3]->setChecked(configFlags & flags[3]);
opt[4] = new QCheckBox(i18n("Group &undos"), this);
cbLayout->addWidget(opt[4], 0, AlignLeft);
opt[4]->setChecked(configFlags & flags[4]);
opt[5] = new QCheckBox(i18n("&Show tabs"), this);
cbLayout->addWidget(opt[5], 0, AlignLeft);
opt[5]->setChecked(configFlags & flags[5]);
opt[6] = new QCheckBox(i18n("Smart &home"), this);
cbLayout->addWidget(opt[6], 0, AlignLeft);
opt[6]->setChecked(configFlags & flags[6]);
opt[7] = new QCheckBox(i18n("&Page up/down moves cursor"), this);
cbLayout->addWidget(opt[7], 0, AlignLeft);
opt[7]->setChecked(configFlags & flags[7]);
opt[8] = new QCheckBox(i18n("Wrap &cursor"), this);
cbLayout->addWidget(opt[8], 0, AlignLeft);
opt[8]->setChecked(configFlags & flags[8]);
cbLayout->addStretch();
// edit lines
leLayout = new QVBoxLayout();
mainLayout->addLayout(leLayout,10);
e1 = new QSpinBox(this);
e1->setMinValue(20);
e1->setMaxValue( 200);
e1->setValue((int)(view->doc()->wordWrapAt()));
#warning fixme e1->setLabel(i18n("Wrap Words At:"));
e2 = new QSpinBox(this);
e2->setMinValue(1);
e2->setMaxValue(16);
e2->setValue((int)view->tabWidth());
#warning fixme e2->setLabel(i18n("Tab/Indent Width:"));
e3 = new QSpinBox(this);
e3->setMinValue(5);
e3->setMaxValue( 30000);
#warning fixme e3->setLabel(i18n("Undo steps:"));
e3->setValue((int)view->undoSteps());
leLayout->addWidget(e1, 0, AlignLeft);
leLayout->addWidget(e2, 0, AlignLeft);
leLayout->addWidget(e3, 0, AlignLeft);
QVBox *box = new QVBox (this);
leLayout->addWidget (box, 0, AlignLeft);
new QLabel (i18n("Encoding:"), box);
encoding = new QComboBox(box);
#warning fixme
#if 0
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,237 +1,237 @@
/***************************************************************************
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);
utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
utilSettings->addTo( popup);
if( qApp->argc() > 1) open(qApp->argv()[1]);
else slotNew();
}
TinyKate::~TinyKate( )
{
qWarning("TinyKate destructor\n");
shutDown=true;
while (currentView!=0) {
slotClose();
}
if( KGlobal::config() != 0 ) {
qWarning("deleting KateConfig object..\n");
delete KGlobal::config();
}
}
void TinyKate::slotOpen( )
{
QString filename = Opie::OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
QString::null);
if (!filename.isEmpty()) {
open(filename);
}
}
void TinyKate::open(const QString & filename)
{
KateDocument *kd= new KateDocument(false, false, this,0,this);
KTextEditor::View *kv;
QFileInfo fi(filename);
QString filenamed = fi.fileName();
tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
qDebug(filename);
kd->setDocName( filenamed);
kd->open( filename );
viewCount++;
}
void TinyKate::setDocument(const QString& fileref)
{
open( fileref );
}
void TinyKate::slotCurrentChanged( QWidget * view)
{
if (currentView) {
disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
}
currentView=(KTextEditor::View*)view;
connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy()));
connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut()));
connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste()));
connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo()));
connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo()));
connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
}
void TinyKate::slotNew( )
{
KateDocument *kd= new KateDocument(false, false, this,0,this);
KTextEditor::View *kv;
tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),
"tinykate/tinykate",
tr("Unnamed %1").arg(nextUnnamed++));
viewCount++;
}
void TinyKate::slotClose( )
{
if (currentView==0) return;
KTextEditor::View *dv=currentView;
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
@@ -6,251 +6,251 @@
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "scqtfiledlg.h"
#include <qcombobox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qtoolbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
static const char* const image0_data[] = {
"24 16 3 1",
". c None",
"# c #000040",
"a c #808080",
"........................",
"........................",
".................####...",
".................####...",
".......##........#aa#...",
"......###........#aa#...",
".....####........#aa#...",
"....##############aa#...",
"...###aaaaaaaaaaaaaa#...",
"..####aaaaaaaaaaaaaa#...",
"...###aaaaaaaaaaaaaa#...",
"....#################...",
".....####...............",
"......###...............",
".......##...............",
"........................"};
static const char* const image1_data[] = {
"24 16 4 1",
". c None",
"a c #008080",
"b c #808080",
"# c #ff0000",
"........................",
"........................",
"...####..........####...",
"...#####........#####...",
"....######.....#####a...",
".....######...#####ba...",
".....aa###########bba...",
"....aaaaa#######aabba...",
"...aaabbb######bbbbba...",
"..aaaabb########bbbba...",
"...aaa############bba...",
"....a######aaa#####aa...",
"....######.....######...",
"...#####a........####...",
"...####aa.........###...",
"........................"};
static const char* const image2_data[] = {
"17 15 4 1",
"# c #000000",
". c #dcdcdc",
"a c #ffff00",
"b c #ffffff",
".................",
"............#....",
".................",
"............#....",
".........#.....#.",
"....####..#.#.#..",
"...#abab#..#.#...",
"..##########..#.#",
"..#babababab##...",
"..#ababababa#.#..",
"..#babababab#..#.",
"..#ababababa#....",
"..#babababab#....",
"..#ababababa#....",
"..###########...."};
/*
* Constructs a ScQtFileDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
ScQtFileDlg::ScQtFileDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
QPixmap image0( ( const char** ) image0_data );
QPixmap image1( ( const char** ) image1_data );
QPixmap image2( ( const char** ) image2_data );
if ( !name )
setName( "ScQtFileDlg" );
resize( 196, 279 );
if (!name)
setCaption( tr( "FileDlg" ) );
else
setCaption(name);
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
@@ -501,390 +501,390 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
// QString d1("Documents/application");
// #else
QString d1(QDir::homeDirPath() + "/Documents/application");
// #endif
QDir pd1(d1);
if (!pd1.exists())
{
QDir pd1("Documents");
if (!pd1.mkdir("application", FALSE))
{
QMessageBox::critical( 0, tr("ZSafe"),
#ifdef JPATCH_HDE
tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit."));
#else
tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1));
#endif
exitZs (1);
}
}
QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
QDir pd2(d2);
if (!pd2.exists())
{
QDir pd2(QDir::homeDirPath() + "Documents/application");
if (!pd2.mkdir("zsafe", FALSE))
{
QMessageBox::critical( 0, tr("ZSafe"),
#ifdef JPATCH_HDE
tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit."));
#else
tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2));
#endif
exitZs (1);
}
}
// set the default filename
filename=d2 + "/passwords.zsf";
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
}
//if (filename == "INVALIDPWD")
//filename = "";
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
#ifdef WIN32
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
selectedItem = NULL;
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
lastSearchedName = "";
lastSearchedUsername = "";
lastSearchedComment = "";
infoForm = new InfoForm();
categoryDialog = NULL;
// add a menu bar
QMenuBar *menu = new QMenuBar( this );
// add file menu
// QPopupMenu *file = new QPopupMenu( this );
file = new QPopupMenu( this );
// #ifdef DESKTOP
file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) );
file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) );
file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) );
file->insertSeparator();
// #endif
file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) );
file->insertItem( save_img, tr("S&ave document with new Password"), this,
SLOT(saveDocumentWithPwd()) );
file->insertSeparator();
file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) );
file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) );
file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) );
file->insertSeparator();
file->insertItem( expand_img, tr("&Open entries expanded"), this,
SLOT(setExpandFlag()), 0, 'o');
file->setItemChecked('o', expandTree);
file->insertSeparator();
file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) );
menu->insertItem( tr("&File"), file );
QPopupMenu *cat = new QPopupMenu( this );
cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) );
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();
selectedItem->setText (2, tr (pwd));
QString comment = dialog->CommentField->text();
comment.replace (QRegExp("\n"), "<br>");
selectedItem->setText (3, tr (comment));
QString f5 = dialog->Field5->text();
selectedItem->setText (4, tr (f5));
QString f6 = dialog->Field6->text();
selectedItem->setText (5, tr (f6));
}
delete dialog;
}
else
{
editCategory();
}
}
void ZSafe::newPwd()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
selectedItem = selectedItem->parent();
if (isCategory(selectedItem))
{
QString cat = selectedItem->text(0);
// open the 'New Entry' dialog
NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE);
#ifdef WIN32
dialog->setCaption ("Qt " + tr("New 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")));
retype:
DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
#ifdef DESKTOP
result = Accepted;
#endif
if (result == Accepted)
{
QString name = dialog->NameField->text();
if (cat == name)
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("Entry name must be different\nfrom the category name.") );
goto retype; // it's not a good programming style :-)
}
modified = true;
// add the new item
QListViewItem *i = new ShadedListItem (0, selectedItem);
i->setOpen (TRUE);
i->setText (0, tr (name));
QString user = dialog->UsernameField->text();
i->setText (1, tr (user));
QString pwd = dialog->PasswordField->text();
i->setText (2, tr (pwd));
QString comment = dialog->CommentField->text();
comment.replace (QRegExp("\n"), "<br>");
i->setText (3, tr (comment));
QString f5 = dialog->Field5->text();
i->setText (4, tr (f5));
QString f6 = dialog->Field6->text();
i->setText (5, tr (f6));
}
delete dialog;
}
}
void ZSafe::findPwd()
{
// open the 'Search' dialog
SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
#ifdef WIN32
dialog->setCaption ("Qt " + tr("Search"));
#endif
#ifdef DESKTOP
#endif
if (lastSearchedName)
@@ -2390,386 +2390,386 @@ int ZSafe::saveInit(const char *_filename, const char *password)
val = creat (_filename, (S_IRUSR | S_IWUSR));
if (val == -1)
return PWERR_OPEN;
else
close(val);
}
*/
QFileInfo f (_filename);
save_buffer_length = f.size();
save_buffer_length = ((save_buffer_length / 1024)+1) * 1024;
fd = fopen (_filename, "wb");
if (fd == NULL)
return PWERR_OPEN;
buffer = (char*)malloc(save_buffer_length);
/* make the key ready */
for (j = 0; password[j] != '\0'; j++) {
key[j] = password[j];
}
keylength = j;
krc2->rc2_expandkey (key, keylength, 128);
/* First, we make the IV */
for (count2 = 0; count2 < 4; count2++) {
iv[count2] = rand ();
putc ((unsigned char) (iv[count2] >> 8), fd);
putc ((unsigned char) (iv[count2] & 0xff), fd);
}
bufferIndex = 0;
return PWERR_GOOD;
}
int ZSafe::saveEntry(char *entry[FIELD_SIZE])
{
char *text1;
int count2, count3;
unsigned short ciphertext[4];
Krc2* krc2 = new Krc2();
buffer = (char*)memset(buffer, '\0', save_buffer_length);
for (count2 = 0; count2 < FIELD_SIZE; count2++) {
text1 = entry[count2];
if (strlen (text1) == 0) {
strncat(buffer, " ", strlen(" "));
} else {
strncat(buffer, text1, strlen(text1));
}
/* Use 255 as the marker. \n is too tough to test for */
buffer[strlen (buffer)] = 255;
} /*for (count2 = 0; count2 < 5; count2++)*/
count2 = 0;
/* I'm using CBC mode and encrypting the data straight from top down.
* At the bottom, encrypted, I will append an MD5 hash of the file, eventually.
* PKCS 5 padding (explained at the code section
*/
while (count2 < (int)strlen (buffer)) {
#ifndef WORDS_BIGENDIAN
plaintext[bufferIndex] = buffer[count2 + 1] << 8;
plaintext[bufferIndex] += buffer[count2] & 0xff;
#endif
#ifdef WORDS_BIGENDIAN
plaintext[bufferIndex] = buffer[count2] << 8;
plaintext[bufferIndex] += buffer[count2 + 1] & 0xff;
#endif
bufferIndex++;
if (bufferIndex == 4) {
krc2->rc2_encrypt (plaintext);
for (count3 = 0; count3 < 4; count3++) {
ciphertext[count3] = iv[count3] ^ plaintext[count3];
/* Now store the ciphertext as the iv */
iv[count3] = plaintext[count3];
/* reset the buffer index */
bufferIndex = 0;
if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA;
if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA;
} /*for (count3 = 0; count3 < 5; count3++)*/
} /*if (bufferIndex == 5)*/
/* increment a short, not a byte */
count2 += 2;
} /*while (count2 < strlen (buffer))*/
int ret = PWERR_GOOD;
return ret;
}
int ZSafe::saveFinalize(void)
{
int count1, retval = PWERR_GOOD;
unsigned short ciphertext[4];
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...
QString fileName = fi->fileName();
if(fileName.right(4) == ".png"){
fileName = fileName.mid(0,fileName.length()-4);
#ifdef DESKTOP
QPixmap imageOfFile;
imageOfFile.load(iconPath + fi->fileName());
#else
QPixmap imageOfFile(Resource::loadPixmap(fileName));
#endif
QImage foo = imageOfFile.convertToImage();
foo = foo.smoothScale(16,16);
imageOfFile.convertFromImage(foo);
dialog->IconField->insertItem(imageOfFile,fileName);
}
++it;
}
waitDialog.hide();
}
#ifndef WIN32
dialog->show();
#endif
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString category;
QString icon;
QString fullIconPath;
QPixmap *pix;
if (result == Accepted)
{
modified = true;
category = dialog->CategoryField->currentText();
icon = dialog->IconField->currentText()+".png";
qWarning (category);
QListViewItem *li = new ShadedListItem( 1, ListView );
Category *c1 = new Category();
c1->setCategoryName(category);
// if (!icon.isEmpty() && !icon.isNull())
if (icon != "predefined.png")
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
// pix->resize(14, 14);
if (pix)
{
// save the full pixmap name into the config file
// #ifndef WIN32
conf->writeEntry(APP_KEY+category, icon);
// #endif
saveConf();
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIcon (*pix);
c1->setIconName(icon);
}
else
{
QPixmap folder( ( const char** ) general_data );
c1->setIcon (folder);
}
}
else
{
c1->setIcon (*getPredefinedIcon(category));
}
c1->setListItem (li);
c1->initListItem();
categories.insert (c1->getCategoryName(), c1);
saveCategoryDialogFields(dialog);
}
else
{
// delete dialog;
dialog->hide();
return;
}
}
}
void ZSafe::delCategory()
{
if (!selectedItem)
@@ -2797,386 +2797,386 @@ void ZSafe::delCategory()
si != NULL; )
{
QListViewItem *_si = si;
si = si->nextSibling();
selectedItem->takeItem(_si); // remove from view list
if (_si) delete _si;
}
ListView->takeItem(selectedItem);
delete selectedItem;
selectedItem = NULL;
break;
case 1: // Don't delete
break;
}
}
}
void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
{
if (!dialog)
return;
QString icon;
if (selectedItem)
{
dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password")));
dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4")));
dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5")));
Category *cat= categories.find (selectedItem->text(0));
if (cat)
{
icon = cat->getIconName();
}
else
icon = conf->readEntry(APP_KEY+selectedItem->text(0));
}
else
{
dialog->Field1->setText(tr("Name"));
dialog->Field2->setText(tr("Username"));
dialog->Field3->setText(tr("Password"));
dialog->Field4->setText(tr("Comment"));
dialog->Field5->setText(tr("Field 4"));
dialog->Field6->setText(tr("Field 5"));
}
#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::setCategoryDialogFields(CategoryDialog *dialog, QString category)
{
if (!dialog)
return;
dialog->Field1->setText(getFieldLabel (category, "1", tr("Name")));
dialog->Field2->setText(getFieldLabel (category, "2", tr("Username")));
dialog->Field3->setText(getFieldLabel (category, "3", tr("Password")));
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);
#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);
}
dialog->IconField->insertItem("predefined");
while ( (fi=it.current()) ) { // for each file...
QString fileName = fi->fileName();
if(fileName.right(4) == ".png")
{
fileName = fileName.mid(0,fileName.length()-4);
#ifdef DESKTOP
QPixmap imageOfFile;
imageOfFile.load(iconPath + fi->fileName());
#else
QPixmap imageOfFile(Resource::loadPixmap(fileName));
#endif
QImage foo = imageOfFile.convertToImage();
foo = foo.smoothScale(16,16);
imageOfFile.convertFromImage(foo);
dialog->IconField->insertItem(imageOfFile,fileName);
if(fileName+".png"==icon)
dialog->IconField->setCurrentItem(i+1);
++i;
}
++it;
}
waitDialog.hide();
}
else
{
#ifdef DESKTOP
// QDir d(QDir::homeDirPath() + "/pics/");
QDir d(iconPath);
#else
QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
d.setFilter( QDir::Files);
const QFileInfoList *list = d.entryInfoList();
int i=0;
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
}
else
{
while ( (fi=it.current()) )
{ // for each file...
QString fileName = fi->fileName();
if(fileName.right(4) == ".png")
{
fileName = fileName.mid(0,fileName.length()-4);
if(fileName+".png"==icon)
{
dialog->IconField->setCurrentItem(i+1);
break;
}
++i;
}
++it;
}
}
}
// dialog->show();
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString fullIconPath;
QPixmap *pix;
if (result == Accepted)
{
modified = true;
if (category != dialog->CategoryField->currentText())
{
categories.remove (category);