author | kergoth <kergoth> | 2003-08-09 16:12:19 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 16:12:19 (UTC) |
commit | 1c58d1407f9584fedcdae390a04e2b37e5853361 (patch) (side-by-side diff) | |
tree | 3c6e741c4d382d1a53c182930052b684d6e35b91 | |
parent | e3f4607edd0c1ca1434adb446df1d4a1d27c6a86 (diff) | |
download | opie-1c58d1407f9584fedcdae390a04e2b37e5853361.zip opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.gz opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.bz2 |
Merge from BRANCH_1_0
46 files changed, 336 insertions, 367 deletions
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp index c06f14f..4de6d12 100644 --- a/noncore/apps/advancedfm/filePermissions.cpp +++ b/noncore/apps/advancedfm/filePermissions.cpp @@ -1,274 +1,270 @@ /**************************************************************************** ** copyright 2002 ljp ljp@llornkcor.com ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #include "filePermissions.h" -#include <qfile.h> #include <qfileinfo.h> #include <qcheckbox.h> #include <qlabel.h> #include <qlineedit.h> -#include <qlayout.h> -#include <qvariant.h> -#include <qtooltip.h> #include <qmessagebox.h> #include <unistd.h> #include <sys/stat.h> -#include <stdlib.h> +#include <stdlib.h> #include <sys/types.h> #include <pwd.h> #include <grp.h> filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "filePermissions" ); // qDebug("FilePermissions "+fileName); /* resize( 236, 210 ); setMaximumSize( QSize( 236, 210 ) ); */ setCaption( tr( "Set File Permissions" ) ); TextLabel1 = new QLabel( this, "TextLabel1" ); TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); TextLabel1->setText( tr( "Set file permissions for:" ) ); LineEdit1 = new QLineEdit( this, "LineEdit1" ); LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); LineEdit1->setReadOnly(true); TextLabel4 = new QLabel( this, "TextLabel4" ); TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); TextLabel4->setText( tr( "owner" ) ); TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); TextLabel4_2->setText( tr( "group" ) ); TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); TextLabel4_3->setText( tr( "others" ) ); CheckBox1 = new QCheckBox( this, "CheckBox1" ); CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); - CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); + CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); - CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); + CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); - CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); + CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); - CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); + CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); - CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); + CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); - CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); + CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); - GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); + GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); - OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); + OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); TextLabel5 = new QLabel( this, "TextLabel5" ); - TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); + TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); TextLabel5->setText( tr( "Owner" ) ); TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); - TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); + TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); TextLabel5_2->setText( tr( "Group" ) ); ModeLine = new QLineEdit( this, "TextLabelMode" ); - ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); + ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); - TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); + TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); TextLabel3_2->setText( tr( "read" ) ); TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); - TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); + TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); TextLabel3_2_2->setText( tr( "write" ) ); TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); TextLabel3 = new QLabel( this, "TextLabel3" ); - TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); + TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); TextLabel3->setText( tr( "execute" ) ); TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); struct stat buf; mode_t mode; file = fileName; QFileInfo fi(file); LineEdit1->setText( file); OwnerLineEdit->setText( fi.owner()); GroupLineEdit->setText( fi.group()); if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } - + stat(file.latin1(), &buf); mode = buf.st_mode; modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); ModeLine->setText(modeStr); bool ok; i_mode = modeStr.toInt(&ok,10); - + } -/* +/* * Destroys the object and frees any allocated resources */ filePermissions::~filePermissions() { } // might this be better as a callback routine??? void filePermissions::ownReadCheck() { if(CheckBox1->isChecked()) { i_mode +=400; } else i_mode -=400; modeStr.sprintf("0%d",i_mode); ModeLine->setText( modeStr); // 0400 } void filePermissions::ownWriteCheck() { if(CheckBox1_2->isChecked()) { i_mode +=200; } else i_mode -=200; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0200 } void filePermissions::ownExeCheck() { if(CheckBox1_3->isChecked()) { i_mode +=100; } else i_mode -=100; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0100 } void filePermissions::grpReadCheck() { if(CheckBox1_4->isChecked()) { i_mode +=40; } else i_mode -=40; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0040 } void filePermissions::grpWriteCheck() { if(CheckBox1_5->isChecked()) { i_mode +=20; } else i_mode -=20; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0020 } void filePermissions::grpExeCheck() { if(CheckBox1_6->isChecked()) { i_mode +=10; } else i_mode -=10; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0010 } void filePermissions::wrldReadCheck() { if(CheckBox1_7->isChecked()) { i_mode +=4; } else i_mode -=4; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0004 } void filePermissions::wrldWriteCheck() { if(CheckBox1_8->isChecked()) { i_mode +=2; } else i_mode -=2; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0002 } void filePermissions::wrldExeCheck() { if(CheckBox1_8_2->isChecked()) { i_mode +=1; } else i_mode -=1; modeStr.sprintf("0%d",i_mode); ModeLine->setText(modeStr); // 0001 } void filePermissions::accept() { QFileInfo fi(file); struct passwd *pwd=0; struct group *grp=0; pwd = getpwnam(OwnerLineEdit->text().latin1() ); if(pwd == NULL) { perror("getpwnam"); - QMessageBox::warning(this,"Warning","Error- no user"); + QMessageBox::warning(this,tr("Warning"),tr("Error- no user") ); return; } else { grp = getgrnam(GroupLineEdit->text().latin1()); if(grp==NULL) { perror("getgrnam"); - QMessageBox::warning(this,"Warning","Error- no group"); + QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); return; } if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { perror("chown"); - QMessageBox::warning(this,"Warning","Error setting ownership or group"); + QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group") ); return; } bool ok; uint moder = modeStr.toUInt(&ok,8); if( chmod( file.latin1(), moder) < 0) { perror("chmod"); - QMessageBox::warning(this,"Warning","Error setting mode"); + QMessageBox::warning(this,tr("Warning"),tr("Error setting mode") ); return; } } close(); } diff --git a/noncore/apps/advancedfm/main.cpp b/noncore/apps/advancedfm/main.cpp index a0401e8..8cacc4a 100644 --- a/noncore/apps/advancedfm/main.cpp +++ b/noncore/apps/advancedfm/main.cpp @@ -1,31 +1,27 @@ /*************************************************************************** main.cpp - description ------------------- begin : March 10, 2002 copyright : (C) 2002 by llornkcor email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include <qpe/qpeapplication.h> -#include <qpe/qcopenvelope_qws.h> -#include <qpe/config.h> -#include <qstring.h> -#include <qstringlist.h> #include "advancedfm.h" int main(int argc, char *argv[]) { QPEApplication a(argc, argv); AdvancedFm advencedFm; a.showMainWidget( &advencedFm); return a.exec(); } diff --git a/noncore/apps/advancedfm/opie-advancedfm.control b/noncore/apps/advancedfm/opie-advancedfm.control index f17c590..1e0f9ec 100644 --- a/noncore/apps/advancedfm/opie-advancedfm.control +++ b/noncore/apps/advancedfm/opie-advancedfm.control @@ -1,10 +1,10 @@ Package: opie-advancedfm Files: bin/advancedfm apps/Applications/advancedfm.desktop pics/advancedfm Priority: optional Section: opie/applications Maintainer: L.J. Potter <ljp@llornkcor.com> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal Description: Advanced File Manager The advanced file manager for the Opie environment. +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index a60cea6..33abdfc 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp @@ -1,284 +1,278 @@ /**************************************************************************** ** outputEdit.cpp ** ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> ****************************************************************************/ #include "output.h" #include <opie/oprocess.h> -#include <qpe/filemanager.h> #include <qpe/qpeapplication.h> #include <qpe/applnk.h> -#include <qmessagebox.h> -#include <qstringlist.h> #include <qfile.h> -#include <qcstring.h> -#include <qlineedit.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <qlayout.h> -#include <qvariant.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()); +// qDebug("count %d", cmmds.count()); if ( !name ) setName( tr("Output")); - resize( 196, 269 ); + resize( 196, 269 ); setCaption( name ); - OutputLayout = new QGridLayout( this ); + 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 *)), this, SLOT( processFinished())); 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( , SIGNAL(received(const QByteArray &)), // this, SLOT(commandStdin(const QByteArray &))); -// * proc << commands.latin1(); +// * 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("Process could not start"); + OutputEdit->append(tr("Process could not start") ); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); perror("Error: "); - QString errorMsg="Error\n"+(QString)strerror(errno); + 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(); + 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( "\nFinished\n"); + OutputEdit->append( tr("\nFinished\n") ); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); // close(); // disconnect( layer(), SIGNAL(received(const QByteArray &)), // this, SLOT(commandStdin(const QByteArray &))); } //============================== InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "InputDialog" ); - resize( 234, 50 ); + 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/opie-checkbook.control b/noncore/apps/checkbook/opie-checkbook.control index c0061e5..78f303c 100644 --- a/noncore/apps/checkbook/opie-checkbook.control +++ b/noncore/apps/checkbook/opie-checkbook.control @@ -1,10 +1,10 @@ Package: opie-checkbook Files: bin/checkbook apps/Applications/checkbook.desktop pics/checkbook Priority: optional Section: applications Maintainer: Dan Williams <drw@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, libopie1 Description: Checkbook keeping program. The checkbook accounting program for the Opie environment. +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp index 0bc6588..53b3853 100644 --- a/noncore/apps/opie-console/configdialog.cpp +++ b/noncore/apps/opie-console/configdialog.cpp @@ -1,114 +1,114 @@ #include <qdialog.h> #include <qlistview.h> #include "profile.h" #include "configdialog.h" #include "metafactory.h" #include "profileeditordialog.h" class ConfigListItem : public QListViewItem { public: ConfigListItem( QListView* item, const Profile& ); ~ConfigListItem(); Profile profile()const; private: Profile m_prof; }; ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) : QListViewItem( item ), m_prof( prof ) { setText(0, prof.name() ); } ConfigListItem::~ConfigListItem() { } Profile ConfigListItem::profile()const { return m_prof; } /* Dialog */ ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, QWidget* parent ) : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) { //init(); { Profile::ValueList::ConstIterator it; for (it = lis.begin(); it != lis.end(); ++it ) { new ConfigListItem( lstView, (*it) ); } } } ConfigDialog::~ConfigDialog() { } Profile::ValueList ConfigDialog::list()const { /* iterate over the list */ Profile::ValueList lst; QListViewItemIterator it(lstView); for ( ; it.current(); ++it ) { ConfigListItem* item = (ConfigListItem*)it.current(); lst.append( item->profile() ); } return lst; } /* our slots */ void ConfigDialog::slotRemove() { ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); if (!item ) return; lstView->takeItem( item ); delete item; } void ConfigDialog::slotEdit() { Profile p; if(!lstView->currentItem()) return; // Load profile p = ((ConfigListItem*)lstView->currentItem())->profile(); ProfileEditorDialog dlg(m_fact, p); - dlg.setCaption("Edit Connection Profile"); + dlg.setCaption(tr("Edit Connection Profile")); dlg.showMaximized(); int ret = dlg.exec(); if(ret == QDialog::Accepted) { if(lstView->currentItem()) delete lstView->currentItem(); // use dlg.terminal()! Profile p = dlg.profile(); new ConfigListItem(lstView, p); } } void ConfigDialog::slotAdd() { ProfileEditorDialog dlg(m_fact); - dlg.setCaption("New Connection"); + dlg.setCaption(tr("New Connection")); dlg.showMaximized(); int ret = dlg.exec(); if(ret == QDialog::Accepted) { // TODO: Move into general profile save part // assignments //QString type = dlg.term_type(); //if(type == "VT102") profile = Profile::VT102; // get profile from editor Profile p = dlg.profile(); new ConfigListItem(lstView, p); } } diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp index 3f2d154..faedc58 100644 --- a/noncore/apps/opie-console/consoleconfigwidget.cpp +++ b/noncore/apps/opie-console/consoleconfigwidget.cpp @@ -1,100 +1,111 @@ #include <qlabel.h> #include <qlayout.h> #include <qcombobox.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qlistview.h> #include <qhbox.h> #include <qregexp.h> #include <stdio.h> +#include <pwd.h> +#include <sys/types.h> + + #include "consoleconfigwidget.h" ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, const char* na ) : ProfileDialogConnectionWidget( name, parent, na ) { m_lay = new QVBoxLayout( this ); QLabel *label = new QLabel(tr("Command to execute"), this); m_lay->addWidget(label); m_cmd = new QLineEdit(this); m_lay->addWidget(m_cmd); label = new QLabel(tr("Environment Variables"), this); m_lay->addWidget(label); m_env = new QListView(this); m_env->addColumn(tr("Name")); m_env->addColumn(tr("Value")); m_lay->addWidget(m_env); QHBox *hbox = new QHBox(this); label = new QLabel(tr("Name :"), hbox); m_name = new QLineEdit(hbox); m_lay->addWidget(hbox); hbox = new QHBox(this); label = new QLabel(tr("Value :"), hbox); m_value = new QLineEdit(hbox); m_lay->addWidget(hbox); hbox = new QHBox(this); hbox->setSpacing(10); m_remove = new QPushButton(tr("Remove"), hbox); connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); m_add = new QPushButton(tr("Add"), hbox); connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); m_lay->addWidget(hbox); } void ConsoleConfigWidget::slotAdd() { if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { QListViewItem *item = new QListViewItem(m_env); item->setText(0, m_name->text()); item->setText(1, m_value->text()); m_env->insertItem(item); } } void ConsoleConfigWidget::slotRemove() { QListViewItem *item = m_env->currentItem(); if (item) { m_env->takeItem(item); } } ConsoleConfigWidget::~ConsoleConfigWidget() { } void ConsoleConfigWidget::load( const Profile& prof ) { /* - * we will use /bin/bash as default - * but will fallback in MyPty to /bin/sh - * if necessary + * default to the users default shell */ - m_cmd->setText(prof.readEntry("Command", "/bin/bash")); + struct passwd *ent = 0; + char *shell = "/bin/sh"; + + while ( (ent = getpwent()) != 0 ) { + if (ent->pw_shell != "") { + shell = ent->pw_shell; + } + } + + m_cmd->setText(prof.readEntry("Command", shell )); int envcount = prof.readNumEntry("EnvVars", 0); for (int i=0; i<envcount; i++) { QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); if (!(name.isEmpty() || value.isEmpty())) { QListViewItem *item = new QListViewItem(m_env); item->setText(0, name); item->setText(1, value); m_env->insertItem(item); } } } void ConsoleConfigWidget::save( Profile& prof ) { prof.writeEntry( "Command", m_cmd->text()); QListViewItem *item = m_env->firstChild(); int counter = 0; while (item) { QString name = item->text(0); QString value = item->text(1); prof.writeEntry("Env_Name_" + QString::number(counter), name); prof.writeEntry("Env_Value_" + QString::number(counter), value); item = item->nextSibling(); counter++; } prof.writeEntry("EnvVars", QString::number(counter)); } diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp index b17f8e8..228db57 100644 --- a/noncore/apps/opie-console/main.cpp +++ b/noncore/apps/opie-console/main.cpp @@ -1,114 +1,111 @@ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <qfile.h> #include <qpe/qpeapplication.h> #include "mainwindow.h" //#define FSCKED_DISTRIBUTION 1 #ifdef FSCKED_DISTRIBUTION /* * The Zaurus rom */ class FixIt { public: FixIt(); ~FixIt(); void fixIt(); /* no real interested in implementing it */ void breakIt() { }; char* m_file; }; FixIt::FixIt() { /* the new inittab */ - m_file = "#\n# /etc/inittab -# - -# 0 - halt (Do NOT set initdefault to this) -# 1 - Single user mode -# 2 - Multiuser, without NFS (The same as 3, if you do not have networking) -# 3 - Full multiuser mode -# 4 - JavaVM(Intent) developer mode -# 5 - JavaVM(Intent) -# 6 - reboot (Do NOT set initdefault to this) -# -id:5:initdefault: - -# Specify things to do when starting -si::sysinit:/etc/rc.d/rc.sysinit - -l0:0:wait:/root/etc/rc.d/rc 0 -l1:1:wait:/etc/rc.d/rc 1 -l2:2:wait:/etc/rc.d/rc 2 -l3:3:wait:/etc/rc.d/rc 3 -l4:4:wait:/etc/rc.d/rc 4 -l5:5:wait:/etc/rc.d/rc 5 -l6:6:wait:/root/etc/rc.d/rc 6 - -# Specify things to do before rebooting -um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1 -sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1 - -# Specify program to run on ttyS0 -s0:24:respawn:/sbin/getty 9600 ttyS0 -#pd:5:respawn:/etc/sync/serialctl - -# Specify program to run on tty1 -1:2:respawn:/sbin/getty 9600 tty1 -ln:345:respawn:survive -l 6 /sbin/launch -#qt:5:respawn:/sbin/qt - -# collie sp. -sy::respawn:/sbin/shsync\n"; - - + m_file = "#\n# /etc/inittab" +"#" +"" +"# 0 - halt (Do NOT set initdefault to this)" +"# 1 - Single user mode" +"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" +"# 3 - Full multiuser mode" +"# 4 - JavaVM(Intent) developer mode" +"# 5 - JavaVM(Intent)" +"# 6 - reboot (Do NOT set initdefault to this)" +"#" +"id:5:initdefault:" +"" +"# Specify things to do when starting" +"si::sysinit:/etc/rc.d/rc.sysinit" +"" +"l0:0:wait:/root/etc/rc.d/rc 0" +"l1:1:wait:/etc/rc.d/rc 1" +"l2:2:wait:/etc/rc.d/rc 2" +"l3:3:wait:/etc/rc.d/rc 3" +"l4:4:wait:/etc/rc.d/rc 4" +"l5:5:wait:/etc/rc.d/rc 5" +"l6:6:wait:/root/etc/rc.d/rc 6" +"" +"# Specify things to do before rebooting" +"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" +"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" +"" +"# Specify program to run on ttyS0" +"s0:24:respawn:/sbin/getty 9600 ttyS0" +"#pd:5:respawn:/etc/sync/serialctl" +"" +"# Specify program to run on tty1" +"1:2:respawn:/sbin/getty 9600 tty1" +"ln:345:respawn:survive -l 6 /sbin/launch" +"#qt:5:respawn:/sbin/qt" +"" +"# collie sp." +"sy::respawn:/sbin/shsync\n"; } FixIt::~FixIt() { } /* * the retail Zaurus is broken in many ways * one is that pppd is listening on our port... * we've to stop it from that and then do kill(SIGHUP,1); */ void FixIt::fixIt() { ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); QFile file( "/etc/inittab" ); if ( file.open(IO_WriteOnly | IO_Raw ) ) { file.writeBlock(m_file,strlen(m_file) ); } file.close(); ::kill( SIGHUP, 1 ); } #endif - int main(int argc, char **argv) { // too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole"; QPEApplication app( argc, argv ); #ifdef FSCKED_DISTRIBUTION qWarning("fscked"); FixIt it; it.fixIt(); #endif MainWindow mw; mw.setCaption(QObject::tr("Opie Console") ); app.showMainWidget( &mw ); int ap = app.exec(); #ifdef FSCKED_DISTRIBUTION /* should add a signal handler too */ it.breakIt(); #endif return ap; } diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index c48116d..3c9603c 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,738 +1,739 @@ #include <assert.h> #include <qaction.h> #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qwhatsthis.h> #include <qfileinfo.h> #include <qtextstream.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qpe/filemanager.h> #include <qpe/mimetype.h> #include <opie/ofiledialog.h> #include "TEmulation.h" #include "keytrans.h" #include "profileeditordialog.h" #include "configdialog.h" #include "default.h" #include "metafactory.h" #include "profile.h" #include "profilemanager.h" #include "mainwindow.h" #include "tabwidget.h" #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 Connection"), + 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 Connection"), + QAction *saveCon = new QAction( tr("Save Profile" ), Resource::loadPixmap( "save" ), QString::null, 0, this, 0 ); saveCon->addTo( m_console ); connect( saveCon, SIGNAL(activated() ), this, SLOT(slotSaveSession() ) ); m_console->insertSeparator(); /* * connect action */ m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), QString::null, 0, this, 0 ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), QString::null, 0, this, 0 ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); m_console->insertSeparator(); m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); m_quickLaunch->addTo( m_icons ); connect( m_quickLaunch, SIGNAL( activated() ), this, SLOT( slotQuickLaunch() ) ); QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 0, this, 0 ); m_transfer->addTo( m_console ); connect(m_transfer, SIGNAL(activated() ), this, SLOT(slotTransfer() ) ); /* * immediate change of line wrap policy */ m_isWrapped = false; m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); m_wrap->addTo( m_console ); connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); /* * fullscreen */ m_isFullscreen = false; m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) , QString::null, 0, this, 0); m_fullscreen->addTo( m_console ); connect( m_fullscreen, SIGNAL( activated() ), this, SLOT( slotFullscreen() ) ); m_console->insertSeparator(); QAction *a = new QAction(); a->setText( tr("Save history") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotSaveHistory() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_terminate, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); m_closewindow = new QAction(); m_closewindow->setText( tr("Close Window") ); m_closewindow->addTo( m_console ); connect( m_closewindow, SIGNAL(activated() ), this, SLOT(slotClose() ) ); /* * script actions */ m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); m_recordScript->addTo(m_scripts); connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); m_saveScript->addTo(m_scripts); connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); /* * action that open/closes the keyboard */ m_openKeys = new QAction (tr("Open Keyboard..."), Resource::loadPixmap( "console/keys/keyboard_icon" ), QString::null, 0, this, 0); m_openKeys->setToggleAction(true); connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); /* insert the submenu */ m_console->insertItem(tr("New from Profile"), m_sessionsPop, -1, 0); /* insert the connection menu */ m_bar->insertItem( tr("Connection"), m_console ); /* the scripts menu */ m_bar->insertItem( tr("Scripts"), m_scripts ); /* and the keyboard */ m_keyBar = new QToolBar(this); addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); m_keyBar->setHorizontalStretchable( TRUE ); m_keyBar->hide(); m_kb = new FunctionKeyboard(m_keyBar); connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); a = new QAction(tr("Copy"), Resource::loadPixmap("copy"), QString::null, 0, this, 0 ); //a->addTo( m_icons ); connect( a, SIGNAL(activated() ), this, SLOT(slotCopy() ) ); QAction *paste = new QAction(tr("Paste"), Resource::loadPixmap("paste"), QString::null, 0, this, 0 ); connect( paste, SIGNAL(activated() ), this, SLOT(slotPaste() ) ); newCon->addTo( m_icons ); //m_setProfiles->addTo( m_icons ); paste->addTo( m_icons ); m_openKeys->addTo(m_icons); m_fullscreen->addTo( m_icons ); m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_fullscreen->setEnabled( false ); m_closewindow->setEnabled( false ); m_wrap->setEnabled( false ); /* * connect to the menu activation */ connect( m_sessionsPop, SIGNAL(activated( int ) ), this, SLOT(slotProfile( int ) ) ); m_consoleWindow = new TabWidget( this, "blah"); connect(m_consoleWindow, SIGNAL(activated(Session*) ), this, SLOT(slotSessionChanged(Session*) ) ); setCentralWidget( m_consoleWindow ); slotQuickLaunch(); } ProfileManager* MainWindow::manager() { return m_manager; } TabWidget* MainWindow::tabWidget() { return m_consoleWindow; } void MainWindow::populateProfiles() { m_sessionsPop->clear(); Profile::ValueList list = manager()->all(); for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { m_sessionsPop->insertItem( (*it).name() ); } } void MainWindow::populateScripts() { m_scriptsPop->clear(); m_scriptsData.clear(); DocLnkSet files(QPEApplication::documentDir(), "text/plain"); QListIterator<DocLnk> dit(files.children()); for (; dit.current(); ++dit) { if (*dit && (*dit)->name().length()>0) { QFileInfo info((*dit)->file()); if (info.extension(false) == "script") { m_scriptsData.append(new DocLnk(**dit)); m_scriptsPop->insertItem((*dit)->name()); } } } } MainWindow::~MainWindow() { delete m_factory; manager()->save(); } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { ProfileEditorDialog dlg(factory() ); dlg.showMaximized(); dlg.setCaption( tr("New Connection") ); int ret = dlg.exec(); 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 = 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() ); conf.showMaximized(); int ret = conf.exec(); if ( QDialog::Accepted == ret ) { manager()->setProfiles( conf.list() ); manager()->save(); populateProfiles(); } } /* * we will remove * this window from the tabwidget * remove it from the list * delete it * and set the currentSession() */ void MainWindow::slotClose() { if (!currentSession() ) return; Session* ses = currentSession(); qWarning("removing! currentSession %s", currentSession()->name().latin1() ); /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ m_curSession = NULL; tabWidget()->remove( /*currentSession()*/ses ); /*it's autodelete */ m_sessions.remove( ses ); qWarning("after remove!!"); if (!currentSession() ) { m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); m_fullscreen->setEnabled( false ); m_wrap->setEnabled( false ); m_closewindow->setEnabled( false ); } m_kb->loadDefaults(); } /* * We will get the name * Then the profile * and then we will make a profile */ void MainWindow::slotProfile( int id) { Profile prof = manager()->profile( m_sessionsPop->text( id) ); create( prof ); } void MainWindow::create( const Profile& prof ) { if(m_curSession) if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); Session *ses = manager()->fromProfile( prof, tabWidget() ); if((!ses) || (!ses->layer()) || (!ses->widgetStack())) { QMessageBox::warning(this, QObject::tr("Session failed"), QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); //if(ses) delete ses; return; } m_sessions.append( ses ); tabWidget()->add( ses ); tabWidget()->repaint(); m_curSession = ses; // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( true ); m_fullscreen->setEnabled( true ); m_wrap->setEnabled( true ); m_closewindow->setEnabled( true ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); // is io_layer wants direct connection, then autoconnect //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { if (prof.autoConnect()) { slotConnect(); } QWidget *w = currentSession()->widget(); if(w) w->setFocus(); if(currentSession()->profile().readNumEntry("Wrap", 80)){ m_isWrapped = true; } else { m_isWrapped = false; } m_kb->load(currentSession()->profile()); } void MainWindow::slotTransfer() { if ( currentSession() ) { Session *mysession = currentSession(); TransferDialog dlg(/*mysession->widgetStack()*/this, this); mysession->setTransferDialog(&dlg); //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); //dlg.showMaximized(); currentSession()->widgetStack()->addWidget(&dlg, -1); dlg.show(); //dlg.exec(); while(dlg.isRunning()) qApp->processEvents(); mysession->setTransferDialog(0l); } } void MainWindow::slotOpenKeb(bool state) { if (state) m_keyBar->show(); else m_keyBar->hide(); } void MainWindow::slotOpenButtons( bool state ) { if ( state ) { m_buttonBar->show(); } else { m_buttonBar->hide(); } } void MainWindow::slotSessionChanged( Session* ses ) { qWarning("changed!"); if(m_curSession) if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); if(ses) if(ses->transferDialog()) ses->transferDialog()->show(); if ( ses ) { m_curSession = ses; qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); if ( m_curSession->layer()->isConnected() ) { m_connect->setEnabled( false ); m_disconnect->setEnabled( true ); m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); m_scripts->setItemEnabled(m_runScript_id, true); } else { m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); } if ( ( m_curSession->layer() )->supports()[1] == 0 ) { m_transfer->setEnabled( false ); } else { m_transfer->setEnabled( true ); } QWidget *w = m_curSession->widget(); if(w) w->setFocus(); if(currentSession()->profile().readNumEntry("Wrap", 80)){ m_isWrapped = true; } else { m_isWrapped = false; } m_kb->load(currentSession()->profile()); } } void MainWindow::slotWrap() { if(m_curSession) { EmulationHandler *e = m_curSession->emulationHandler(); if(e) { if(m_isWrapped) { e->setWrap(80); m_isWrapped = false; } else { e->setWrap(0); m_isWrapped = true; } } } } void MainWindow::slotFullscreen() { if ( m_isFullscreen ) { ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); ( m_curSession->emulationHandler() )->cornerButton()->hide(); disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } else { savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop , QPoint(0,0), false ); ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); ( m_curSession->widgetStack() )->setFocus(); ( m_curSession->widgetStack() )->show(); ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } m_isFullscreen = !m_isFullscreen; } void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { if ( m_curSession ) { QEvent::Type state; if (pressed) state = QEvent::KeyPress; else state = QEvent::KeyRelease; QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); // is this the best way to do this? cant figure out any other way to work QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); ke.ignore(); } } void MainWindow::slotCopy() { if (!currentSession() ) return; currentSession()->emulationHandler()->copy(); } void MainWindow::slotPaste() { if (!currentSession() ) return; currentSession()->emulationHandler()->paste(); } /* * Save the session */ void MainWindow::slotSaveSession() { if (!currentSession() ) { QMessageBox::information(this, tr("Save Connection"), tr("<qt>There is no Connection.</qt>"), 1 ); return; } manager()->add( currentSession()->profile() ); manager()->save(); populateProfiles(); } void MainWindow::slotSaveHistory() { QMap<QString, QStringList> map; QStringList text; text << "text/plain"; map.insert(tr("History"), text ); QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); if (filename.isEmpty() ) return; QFileInfo info(filename); DocLnk nf; nf.setType("text/plain"); nf.setFile(filename); nf.setName(info.fileName()); QFile file(filename); file.open(IO_WriteOnly ); QTextStream str(&file ); if ( currentSession() ) currentSession()->emulationHandler()->emulation()->streamHistory(&str); file.close(); nf.writeLink(); } diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control index 693c72c..852451d 100644 --- a/noncore/apps/opie-console/opie-console.control +++ b/noncore/apps/opie-console/opie-console.control @@ -1,11 +1,11 @@ Package: opie-console Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* Priority: optional Section: opie/applications Maintainer: Opie team <opie@handhelds.org> Architecture: arm Version: 0.6-$SUB_VERSION -Depends: qpe-base, libopie1, lrzsz, opie-keytabs +Depends: qpe-base, libopie1, opie-console-help-en, lrzsz, opie-keytabs License: GPL Description: Opie terminal app diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 58b29ca..ccf2e08 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro @@ -1,77 +1,76 @@ TEMPLATE = app TMAKE_CXXFLAGS += -DHAVE_OPENPTY CONFIG += qt warn_on release #CONFIG = qt debug DESTDIR = $(OPIEDIR)/bin HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ file_layer.h filetransfer.h \ metafactory.h \ session.h \ mainwindow.h \ profile.h \ profileconfig.h \ profilemanager.h \ - configwidget.h \ tabwidget.h \ configdialog.h \ keytrans.h \ transferdialog.h \ profiledialogwidget.h \ profileeditordialog.h \ default.h \ iolayerbase.h \ serialconfigwidget.h irdaconfigwidget.h \ btconfigwidget.h modemconfigwidget.h \ atconfigdialog.h dialdialog.h \ procctl.h \ function_keyboard.h \ receive_layer.h filereceive.h \ script.h \ dialer.h \ terminalwidget.h \ emulation_handler.h TECommon.h \ TEHistory.h TEScreen.h TEWidget.h \ TEmuVt102.h TEmulation.h MyPty.h \ consoleconfigwidget.h SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ file_layer.cpp filetransfer.cpp \ main.cpp \ metafactory.cpp \ session.cpp \ mainwindow.cpp \ profile.cpp \ profileconfig.cpp \ profilemanager.cpp \ tabwidget.cpp \ configdialog.cpp \ keytrans.cpp \ transferdialog.cpp \ profiledialogwidget.cpp \ profileeditordialog.cpp \ iolayerbase.cpp \ serialconfigwidget.cpp irdaconfigwidget.cpp \ btconfigwidget.cpp modemconfigwidget.cpp \ atconfigdialog.cpp dialdialog.cpp \ default.cpp procctl.cpp \ function_keyboard.cpp \ receive_layer.cpp filereceive.cpp \ script.cpp \ dialer.cpp \ terminalwidget.cpp \ emulation_handler.cpp TEHistory.cpp \ TEScreen.cpp TEWidget.cpp \ TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ consoleconfigwidget.cpp INTERFACES = configurebase.ui editbase.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -lutil TARGET = opie-console include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 6b607df..e2501a6 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -1,239 +1,242 @@ #include <qlayout.h> #include <qlineedit.h> #include <qlabel.h> #include <qmessagebox.h> #include <qstringlist.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("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); + // Default profile + m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102); - initUI(); + initUI(); - // Apply current profile - // plugin_plugin->load(profile); + // 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()); - slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); - slotTermActivated( m_fact->external(m_prof.terminalName() ) ); slotKeyActivated( "Default Keyboard" ); setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); + slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); + slotTermActivated( m_fact->external(m_prof.terminalName() ) ); m_autoConnect->setChecked(m_prof.autoConnect()); // signal and slots connect(m_conCmb, SIGNAL(activated(const QString& ) ), this, SLOT(slotConActivated(const QString&) ) ); connect(m_termCmb, SIGNAL(activated(const QString& ) ), this, SLOT(slotTermActivated(const QString& ) ) ); } ProfileEditorDialog::~ProfileEditorDialog() { } void ProfileEditorDialog::accept() { if(profName().isEmpty()) { QMessageBox::information(this, QObject::tr("Invalid profile"), QObject::tr("Please enter a profile name.")); return; } // Save profile and plugin profile //if(plugin_plugin) plugin_plugin->save(); // Save general values m_prof.setName( profName() ); m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); m_prof.setAutoConnect( m_autoConnect->isChecked() ); if (m_con ) m_con->save( m_prof ); if (m_term ) m_term->save( m_prof ); if (m_key) m_key->save( m_prof ); QDialog::accept(); } QString ProfileEditorDialog::profName()const { return m_name->text(); } QCString ProfileEditorDialog::profType()const { /*QStringList w = m_fact->configWidgets(); for(QStringList::Iterator it = w.begin(); it != w.end(); it++) if(device_box->currentText() == m_fact->name((*it))) return (*it); */ return QCString(); } /* * we need to switch the widget */ void ProfileEditorDialog::slotConActivated( const QString& str ) { delete m_con; m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); if ( !m_con ) { m_con = new NoOptions( str, m_svCon->viewport(), "name"); } // FIXME ugly hack right. Right solution would be to look into the layer and see if it // supports auto connect and then set it as prefered - //if ( ( )->layer()->supports()[0] == 1 ) { 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) { + 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-reader/Prefs.cpp b/noncore/apps/opie-reader/Prefs.cpp index 825608e..e5320d9 100644 --- a/noncore/apps/opie-reader/Prefs.cpp +++ b/noncore/apps/opie-reader/Prefs.cpp @@ -1,636 +1,636 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'Prefs.ui' ** ** Created: Tue Feb 11 23:53:35 2003 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #include "useqpe.h" #include "Prefs.h" #include <qcheckbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qspinbox.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qcombobox.h> #include <qbuttongroup.h> #include <qlineedit.h> #ifdef USEQPE #include <qpe/menubutton.h> #include <qpe/fontdatabase.h> #else #include <qfontdatabase.h> #endif CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QHBoxLayout* hb = new QHBoxLayout(this); - QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, "Text", this); + QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, tr("Text"), this); hb->addWidget(bg); StripCR = new QCheckBox( bg ); StripCR->setText( tr( "Strip CR" ) ); Dehyphen = new QCheckBox( bg ); Dehyphen->setText( tr( "Dehyphen" ) ); SingleSpace = new QCheckBox( bg ); SingleSpace->setText( tr( "Single Space" ) ); Unindent = new QCheckBox( bg ); Unindent->setText( tr( "Unindent" ) ); Reparagraph = new QCheckBox( bg ); Reparagraph->setText( tr( "Reparagraph" ) ); DoubleSpace = new QCheckBox( bg ); DoubleSpace->setText( tr( "Double Space" ) ); Remap = new QCheckBox( bg ); Remap->setText( tr( "Remap" ) ); Embolden = new QCheckBox( bg ); Embolden->setText( tr( "Embolden" ) ); FullJustify = new QCheckBox( bg ); FullJustify->setText( tr( "Full Justify" ) ); } /* * Destroys the object and frees any allocated resources */ CLayoutPrefs::~CLayoutPrefs() { // no need to delete child widgets, Qt does it all for us } CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QVBoxLayout* vb = new QVBoxLayout(this); QGridLayout* gl = new QGridLayout(vb, 4, 3); QLabel *TextLabel; TextLabel = new QLabel( this, "TextLabel1" ); TextLabel->setText( tr( "Indent" ) ); gl->addWidget(TextLabel, 0, 0); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Page\nOverlap" ) ); gl->addWidget(TextLabel, 0, 1); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Graphics\nZoom" ) ); gl->addWidget(TextLabel, 0, 2); Indent = new QSpinBox( this, "Indent" ); Indent->setRange(0,20); gl->addWidget(Indent, 1, 0); pageoverlap = new QSpinBox( this ); pageoverlap->setRange(0,20); gl->addWidget(pageoverlap, 1, 1); gfxzoom = new QSpinBox( this ); gfxzoom->setRange(0,100); gl->addWidget(gfxzoom, 1, 2); TextLabel = new QLabel( this, "TextLabel4" ); TextLabel->setText( tr( "Margin" ) ); gl->addWidget(TextLabel, 2, 0); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Paragraph\nLeading" ) ); gl->addWidget(TextLabel, 2, 1); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Line\nLeading" ) ); gl->addWidget(TextLabel, 2, 2); Margin = new QSpinBox( this, "Margin" ); Margin->setRange(0, 100); gl->addWidget(Margin, 3, 0); ParaLead = new QSpinBox( this ); ParaLead->setRange(-5, 50); gl->addWidget(ParaLead, 3, 1); LineLead = new QSpinBox( this ); LineLead->setRange(-5, 50); gl->addWidget(LineLead, 3, 2); gl = new QGridLayout(vb, 2, 2); TextLabel = new QLabel( this); TextLabel->setText( tr( "Markup" ) ); gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); TextLabel = new QLabel( this); TextLabel->setText( tr( "Font" ) ); gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); #ifdef USECOMBO Markup = new QComboBox( this); #else Markup = new MenuButton( this); #endif Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); Markup->insertItem("Auto"); Markup->insertItem("None"); Markup->insertItem("Text"); Markup->insertItem("HTML"); Markup->insertItem("PML"); gl->addWidget(Markup, 1, 0, Qt::AlignTop); #ifdef USECOMBO fontselector = new QComboBox( this); #else fontselector = new MenuButton( this); #endif fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); { #ifdef USEQPE FontDatabase f; #else QFontDatabase f; #endif QStringList flist = f.families(); for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) { fontselector->insertItem(*nm); } } // delete the FontDatabase!!! gl->addWidget(fontselector, 1, 1, Qt::AlignTop); } /* CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QHBoxLayout* hb = new QHBoxLayout(this); QVBoxLayout* vb = new QVBoxLayout; hb->addLayout(vb); QLabel *TextLabel; TextLabel = new QLabel( this, "TextLabel1" ); TextLabel->setText( tr( "Indent" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); Indent = new QSpinBox( this, "Indent" ); Indent->setRange(0,20); vb->addWidget( Indent, 0, Qt::AlignLeft ); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Page\nOverlap" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); pageoverlap = new QSpinBox( this ); pageoverlap->setRange(0,20); vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Graphics\nZoom" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); gfxzoom = new QSpinBox( this ); gfxzoom->setRange(0,100); vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); vb->addStretch(); vb = new QVBoxLayout; hb->addLayout(vb); TextLabel = new QLabel( this, "TextLabel4" ); TextLabel->setText( tr( "Margin" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); Margin = new QSpinBox( this, "Margin" ); Margin->setRange(0, 100); vb->addWidget( Margin, 0, Qt::AlignLeft ); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Paragraph\nLeading" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); ParaLead = new QSpinBox( this ); ParaLead->setRange(-5, 50); vb->addWidget( ParaLead, 0, Qt::AlignLeft ); TextLabel = new QLabel( this ); TextLabel->setText( tr( "Line\nLeading" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); LineLead = new QSpinBox( this ); LineLead->setRange(-5, 50); vb->addWidget( LineLead, 0, Qt::AlignLeft ); vb->addStretch(); vb = new QVBoxLayout; hb->addLayout(vb); TextLabel = new QLabel( this); TextLabel->setText( tr( "Markup" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); Markup = new MenuButton( this); Markup->insertItem("Auto"); Markup->insertItem("None"); Markup->insertItem("Text"); Markup->insertItem("HTML"); Markup->insertItem("PML"); vb->addWidget( Markup, 0, Qt::AlignLeft ); TextLabel = new QLabel( this); TextLabel->setText( tr( "Font" ) ); vb->addWidget( TextLabel, 0, Qt::AlignBottom ); fontselector = new MenuButton( this); fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); { FontDatabase f; QStringList flist = f.families(); for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) { fontselector->insertItem(*nm); } } // delete the FontDatabase!!! vb->addWidget( fontselector, 0, Qt::AlignLeft ); vb->addStretch(); } */ /* * Destroys the object and frees any allocated resources */ CLayoutPrefs2::~CLayoutPrefs2() { // no need to delete child widgets, Qt does it all for us } /* CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { Layout11 = new QVBoxLayout(this); Layout11->setMargin( 0 ); Depluck = new QCheckBox( this, "Depluck" ); Depluck->setText( tr( "Depluck" ) ); Layout11->addWidget( Depluck ); Dejpluck = new QCheckBox( this, "Dejpluck" ); Dejpluck->setText( tr( "Dejpluck" ) ); Layout11->addWidget( Dejpluck ); Continuous = new QCheckBox( this, "Continuous" ); Continuous->setText( tr( "Continuous" ) ); Layout11->addWidget( Continuous ); } CPluckerPrefs::~CPluckerPrefs() { // no need to delete child widgets, Qt does it all for us } */ /* CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QVBoxLayout* Layout11 = new QVBoxLayout(this); Layout11->setMargin( 0 ); QHBoxLayout* hl = new QHBoxLayout; QLabel* TextLabel = new QLabel( this ); TextLabel->setText( tr( "Action for\nSelect Button" ) ); hl->addWidget(TextLabel); action = new QComboBox( this ); action->insertItem("Open file"); action->insertItem("Autoscroll"); action->insertItem("Mark"); action->insertItem("Annotate"); action->insertItem("Fullscreen"); hl->addWidget( action ); Layout11->addLayout(hl); hl = new QHBoxLayout; TextLabel = new QLabel( this ); TextLabel->setText( tr( "Dictionary\nApplication" ) ); hl->addWidget(TextLabel); target = new QLineEdit(this); hl->addWidget( target ); Layout11->addLayout(hl); QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); Layout11->addWidget( bg ); annotation = new QCheckBox( bg ); annotation->setText( tr( "Annotation" ) ); dictionary = new QCheckBox( bg ); dictionary->setText( tr( "Dictionary" ) ); clipboard = new QCheckBox( bg ); clipboard->setText( tr( "Clipboard" ) ); } CMiscPrefs::~CMiscPrefs() { // no need to delete child widgets, Qt does it all for us } */ CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout* hl = new QGridLayout(this,1,2); hl->setMargin( 0 ); - QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Select Action", this); + QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("Select Action"), this); hl->addWidget( gb, 0, 0 ); annotation = new QCheckBox( gb ); annotation->setText( tr( "Annotation" ) ); dictionary = new QCheckBox( gb ); dictionary->setText( tr( "Dictionary" ) ); clipboard = new QCheckBox( gb ); clipboard->setText( tr( "Clipboard" ) ); - QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Plucker", this); + QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, tr("Plucker"), this); hl->addWidget( bg, 0 , 1 ); Depluck = new QCheckBox( bg ); Depluck->setText( tr( "Depluck" ) ); Dejpluck = new QCheckBox( bg ); Dejpluck->setText( tr( "Dejpluck" ) ); Continuous = new QCheckBox( bg ); Continuous->setText( tr( "Continuous" ) ); /* QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Navigation", this); TextLabel = new QLabel( gb ); TextLabel->setText( tr( "Overlap" ) ); QSpinBox* sb = new QSpinBox( gb ); Internationalisation Ideogram/Word Set Width Set Encoding Set Font */ } CMiscPrefs::~CMiscPrefs() { // no need to delete child widgets, Qt does it all for us } CPrefs::CPrefs(bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) { setCaption(tr( "OpieReader Settings" ) ); QTabWidget* td = new QTabWidget(this); layout = new CLayoutPrefs(this); layout2 = new CLayoutPrefs2(this); misc = new CMiscPrefs(this); button = new CButtonPrefs(this); inter = new CInterPrefs(this); td->addTab(layout, tr("Layout")); td->addTab(layout2, tr("Layout(2)")); td->addTab(inter, tr("Locale")); td->addTab(misc, tr("Misc")); td->addTab(button, tr("Buttons")); QVBoxLayout* v = new QVBoxLayout(this); v->addWidget(td); if (fs) showMaximized(); } /* Unicode Ideo/Word Width Encoding */ #include "CEncoding_tables.h" CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QHBoxLayout* hb = new QHBoxLayout(this); QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); hb->addWidget(gb); QLabel *TextLabel; ideogram = new QCheckBox( gb ); ideogram->setText( tr( "Ideograms" ) ); TextLabel = new QLabel( gb ); TextLabel->setText( tr( "Ideogram Width" ) ); ideogramwidth = new QSpinBox( gb ); ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); ideogramwidth->setRange(1,200); propfontchange = new QCheckBox( gb ); propfontchange->setText( tr( "Apply font\nto dialogs" ) ); TextLabel = new QLabel( gb ); TextLabel->setText( tr( "Encoding" ) ); #ifdef USECOMBO encoding = new QComboBox(gb); #else encoding = new MenuButton(gb); #endif encoding->insertItem("Ascii"); encoding->insertItem("UTF-8"); encoding->insertItem("UCS-2(BE)"); encoding->insertItem("USC-2(LE)"); encoding->insertItem("Palm"); for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) { encoding->insertItem(iter->mime); } QVBoxLayout* vb = new QVBoxLayout; - gb = new QGroupBox(1, Qt::Horizontal, "Dictionary", this); + gb = new QGroupBox(1, Qt::Horizontal, tr("Dictionary"), this); TextLabel = new QLabel( gb ); TextLabel->setText( tr( "Application" ) ); application = new QLineEdit(gb); application->setFixedWidth(80); TextLabel = new QLabel( gb ); TextLabel->setText( tr( "Message" ) ); message = new QLineEdit(gb); message->setFixedWidth(80); // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); twotouch = new QCheckBox( gb ); twotouch->setText( tr( "Two/One\nTouch" ) ); SwapMouse = new QCheckBox( gb ); - SwapMouse->setText("Swap Tap\nActions"); + SwapMouse->setText(tr("Swap Tap\nActions") ); vb->addWidget(gb); // vb->addStretch(); hb->addLayout(vb); } CInterPrefs::~CInterPrefs() { // no need to delete child widgets, Qt does it all for us } #ifdef USECOMBO void CButtonPrefs::populate(QComboBox *mb) #else void CButtonPrefs::populate(MenuButton *mb) #endif { mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - mb->insertItem("<Nothing>"); - mb->insertItem("Open file"); - mb->insertItem("Autoscroll"); - mb->insertItem("Bookmark"); - mb->insertItem("Annotate"); - mb->insertItem("Fullscreen"); - - mb->insertItem("Zoom in"); - mb->insertItem("Zoom out"); - mb->insertItem("Back"); - mb->insertItem("Forward"); - mb->insertItem("Home"); - mb->insertItem("Page up"); - mb->insertItem("Page down"); - mb->insertItem("Line up"); - mb->insertItem("Line down"); - mb->insertItem("Beginning"); - mb->insertItem("End"); + mb->insertItem(tr("<Nothing>") ); + mb->insertItem(tr("Open file") ); + mb->insertItem(tr("Autoscroll") ); + mb->insertItem(tr("Bookmark") ); + mb->insertItem(tr("Annotate") ); + mb->insertItem(tr("Fullscreen") ); + + mb->insertItem(tr("Zoom in") ); + mb->insertItem(tr("Zoom out") ); + mb->insertItem(tr("Back") ); + mb->insertItem(tr("Forward") ); + mb->insertItem(tr("Home") ); + mb->insertItem(tr("Page up") ); + mb->insertItem(tr("Page down") ); + mb->insertItem(tr("Line up") ); + mb->insertItem(tr("Line down") ); + mb->insertItem(tr("Beginning") ); + mb->insertItem(tr("End") ); } CButtonPrefs::CButtonPrefs( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout* hl = new QGridLayout(this,10,2); hl->setMargin( 0 ); - QLabel* ql = new QLabel("Escape Button", this); + QLabel* ql = new QLabel(tr("Escape Button"), this); hl->addWidget(ql, 0, 0, Qt::AlignBottom); #ifdef USECOMBO escapeAction = new QComboBox( this ); #else escapeAction = new MenuButton( this ); #endif populate(escapeAction); hl->addWidget(escapeAction, 1, 0, Qt::AlignTop | Qt::AlignLeft); - ql = new QLabel("Space Button", this); + ql = new QLabel(tr("Space Button"), this); hl->addWidget(ql, 2, 0, Qt::AlignBottom); #ifdef USECOMBO spaceAction = new QComboBox( this ); #else spaceAction = new MenuButton( this ); #endif populate(spaceAction); hl->addWidget(spaceAction, 3, 0, Qt::AlignTop | Qt::AlignLeft); - ql = new QLabel("Return Button", this); + ql = new QLabel(tr("Return Button"), this); hl->addWidget(ql, 2, 1, Qt::AlignBottom); #ifdef USECOMBO returnAction = new QComboBox( this ); #else returnAction = new MenuButton( this ); #endif populate(returnAction); hl->addWidget(returnAction, 3, 1, Qt::AlignTop | Qt::AlignLeft); - ql = new QLabel("Left Arrow", this); + ql = new QLabel(tr("Left Arrow"), this); hl->addWidget(ql, 4, 0, Qt::AlignBottom); #ifdef USECOMBO leftAction = new QComboBox( this ); #else leftAction = new MenuButton( this ); #endif populate(leftAction); hl->addWidget(leftAction, 5, 0, Qt::AlignTop | Qt::AlignLeft); leftScroll = new QCheckBox( tr("Scroll Speed"), this ); hl->addWidget(leftScroll, 6, 0, Qt::AlignTop | Qt::AlignLeft); - ql = new QLabel("Right Arrow", this); + ql = new QLabel(tr("Right Arrow"), this); hl->addWidget(ql, 4, 1, Qt::AlignBottom); #ifdef USECOMBO rightAction = new QComboBox( this ); #else rightAction = new MenuButton( this ); #endif populate(rightAction); hl->addWidget(rightAction, 5, 1, Qt::AlignTop | Qt::AlignLeft); rightScroll = new QCheckBox( tr("Scroll Speed"), this ); hl->addWidget(rightScroll, 6, 1, Qt::AlignTop | Qt::AlignLeft); - ql = new QLabel("Down Arrow", this); + ql = new QLabel(tr("Down Arrow"), this); hl->addWidget(ql, 7, 0, Qt::AlignBottom); #ifdef USECOMBO downAction = new QComboBox( this ); #else downAction = new MenuButton( this ); #endif populate(downAction); hl->addWidget(downAction, 8, 0, Qt::AlignTop | Qt::AlignLeft); downScroll = new QCheckBox( tr("Scroll Speed"), this ); hl->addWidget(downScroll, 9, 0, Qt::AlignTop | Qt::AlignLeft); - ql = new QLabel("Up Arrow", this); + ql = new QLabel(tr("Up Arrow"), this); hl->addWidget(ql, 7, 1, Qt::AlignBottom); #ifdef USECOMBO upAction = new QComboBox( this ); #else upAction = new MenuButton( this ); #endif populate(upAction); hl->addWidget(upAction, 8, 1, Qt::AlignTop | Qt::AlignLeft); upScroll = new QCheckBox( tr("Scroll Speed"), this ); hl->addWidget(upScroll, 9, 1, Qt::AlignTop | Qt::AlignLeft); } CButtonPrefs::~CButtonPrefs() { // no need to delete child widgets, Qt does it all for us } diff --git a/noncore/apps/opie-reader/Prefs.h b/noncore/apps/opie-reader/Prefs.h index 37d8c9e..8fef2f5 100644 --- a/noncore/apps/opie-reader/Prefs.h +++ b/noncore/apps/opie-reader/Prefs.h @@ -1,340 +1,341 @@ /**************************************************************************** ** Form interface generated from reading ui file 'Prefs.ui' ** ** Created: Tue Feb 11 23:53:32 2003 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #ifndef CPREFS_H #define CPREFS_H #include "useqpe.h" #include <qvariant.h> #include <qwidget.h> #include <qtabdialog.h> #include <qtabwidget.h> #include <qspinbox.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qlineedit.h> #ifdef USEQPE
#include <qpe/menubutton.h>
#endif //#include "opie.h" //#ifdef OPIE #define USECOMBO //#endif class QVBoxLayout; class QHBoxLayout; class QGridLayout; //class QCheckBox; class QLabel; //class QSpinBox; class CLayoutPrefs : public QWidget { - + Q_OBJECT public: friend class CPrefs; CLayoutPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CLayoutPrefs(); QCheckBox* StripCR; QCheckBox* Dehyphen; QCheckBox* SingleSpace; QCheckBox* Unindent; QCheckBox* Reparagraph; QCheckBox* DoubleSpace; QCheckBox* Remap; QCheckBox* Embolden; QCheckBox* FullJustify; }; class CLayoutPrefs2 : public QWidget { - + Q_OBJECT public: friend class CPrefs; CLayoutPrefs2( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CLayoutPrefs2(); QSpinBox* ParaLead; QSpinBox* LineLead; QSpinBox* Indent; QSpinBox* Margin, *gfxzoom, *pageoverlap; #ifdef USECOMBO QComboBox *Markup, *fontselector; #else MenuButton *Markup, *fontselector; #endif }; /* class CPluckerPrefs : public QWidget { public: friend class CPrefs; CPluckerPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CPluckerPrefs(); QCheckBox* Depluck; QCheckBox* Dejpluck; QCheckBox* Continuous; protected: QHBoxLayout* Layout5; QVBoxLayout* Layout11; QGridLayout* Layout4; }; */ class CMiscPrefs : public QWidget { - + Q_OBJECT public: friend class CPrefs; CMiscPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CMiscPrefs(); QCheckBox *annotation, *dictionary, *clipboard; QCheckBox *Depluck, *Dejpluck, *Continuous; }; class CButtonPrefs : public QWidget { + Q_OBJECT #ifdef USECOMBO void populate(QComboBox*); #else void populate(MenuButton*); #endif public: friend class CPrefs; CButtonPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CButtonPrefs(); #ifdef USECOMBO QComboBox *returnAction, *spaceAction, *escapeAction, *leftAction, *rightAction, *upAction, *downAction; #else MenuButton *returnAction, *spaceAction, *escapeAction, *leftAction, *rightAction, *upAction, *downAction; #endif QCheckBox *leftScroll, *rightScroll, *upScroll, *downScroll; }; class CInterPrefs : public QWidget { - + Q_OBJECT public: friend class CPrefs; CInterPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CInterPrefs(); QCheckBox *ideogram, *propfontchange, *SwapMouse, *twotouch; #ifdef USECOMBO QComboBox* encoding; #else MenuButton* encoding; #endif QSpinBox* ideogramwidth; QLineEdit *application, *message; }; class CPrefs : public QDialog { Q_OBJECT CLayoutPrefs* layout; CLayoutPrefs2* layout2; CMiscPrefs* misc; CButtonPrefs* button; CInterPrefs* inter; void keyPressEvent(QKeyEvent* e) { switch (e->key()) { case Key_Escape: e->accept(); reject(); break; case Key_Space: case Key_Return: e->accept(); accept(); break; default: QWidget::keyPressEvent(e); } } public: CPrefs(bool fs = true, QWidget* parent = 0, const char* name = 0); ~CPrefs() { } bool StripCR() { return layout->StripCR->isChecked(); } bool Dehyphen() { return layout->Dehyphen->isChecked(); } bool SingleSpace() { return layout->SingleSpace->isChecked(); } bool Unindent() { return layout->Unindent->isChecked(); } bool Reparagraph() { return layout->Reparagraph->isChecked(); } bool DoubleSpace() { return layout->DoubleSpace->isChecked(); } bool Remap() { return layout->Remap->isChecked(); } bool Embolden() { return layout->Embolden->isChecked(); } bool FullJustify() { return layout->FullJustify->isChecked(); } int ParaLead() { return layout2->ParaLead->value(); } int LineLead() { return layout2->LineLead->value(); } int Margin() { return layout2->Margin->value(); } int Indent() { return layout2->Indent->value(); } int Markup() { return layout2->Markup->currentItem(); } QString Font() { return layout2->fontselector->currentText(); } void StripCR(bool v) { layout->StripCR->setChecked(v); } void Dehyphen(bool v) { layout->Dehyphen->setChecked(v); } void SingleSpace(bool v) { layout->SingleSpace->setChecked(v); } void Unindent(bool v) { layout->Unindent->setChecked(v); } void Reparagraph(bool v) { layout->Reparagraph->setChecked(v); } void DoubleSpace(bool v) { layout->DoubleSpace->setChecked(v); } void Remap(bool v) { layout->Remap->setChecked(v); } void Embolden(bool v) { layout->Embolden->setChecked(v); } void FullJustify(bool v) { layout->FullJustify->setChecked(v); } void ParaLead(int v) { layout2->ParaLead->setValue(v); } void LineLead(int v) { layout2->LineLead->setValue(v); } void Margin(int v) { layout2->Margin->setValue(v); } void Indent(int v) { layout2->Indent->setValue(v); } #ifdef USECOMBO void Markup(int v) { layout2->Markup->setCurrentItem(v); } #else void Markup(int v) { layout2->Markup->select(v); } #endif #ifdef USECOMBO void Font(QString& s) { for (int i = 1; i <= layout2->fontselector->count(); i++) { if (layout2->fontselector->text(i) == s) { layout2->fontselector->setCurrentItem(i); break; } } } #else void Font(QString& s) { layout2->fontselector->select(s); } #endif bool Depluck() { return misc->Depluck->isChecked(); } void Depluck(bool v) { misc->Depluck->setChecked(v); } bool Dejpluck() { return misc->Dejpluck->isChecked(); } void Dejpluck(bool v) { misc->Dejpluck->setChecked(v); } bool Continuous() { return misc->Continuous->isChecked(); } void Continuous(bool v) { misc->Continuous->setChecked(v); } bool SwapMouse() { return inter->SwapMouse->isChecked(); } void SwapMouse(bool v) { inter->SwapMouse->setChecked(v); } void dictApplication(const QString& v) { inter->application->setText(v); } QString dictApplication() { return inter->application->text(); } void dictMessage(const QString& v) { inter->message->setText(v); } QString dictMessage() { return inter->message->text(); } void miscannotation(bool v) { misc->annotation->setChecked(v); } void miscdictionary(bool v) { misc->dictionary->setChecked(v); } void miscclipboard(bool v) { misc->clipboard->setChecked(v); } bool miscannotation() { return misc->annotation->isChecked(); } bool miscdictionary() { return misc->dictionary->isChecked(); } bool miscclipboard() { return misc->clipboard->isChecked(); } int spaceAction() { return button->spaceAction->currentItem(); } #ifdef USECOMBO void spaceAction(int v) { button->spaceAction->setCurrentItem(v); } #else void spaceAction(int v) { button->spaceAction->select(v); } #endif int escapeAction() { return button->escapeAction->currentItem(); } #ifdef USECOMBO void escapeAction(int v) { button->escapeAction->setCurrentItem(v); } #else void escapeAction(int v) { button->escapeAction->select(v); } #endif int returnAction() { return button->returnAction->currentItem(); } #ifdef USECOMBO void returnAction(int v) { button->returnAction->setCurrentItem(v); } #else void returnAction(int v) { button->returnAction->select(v); } #endif int leftAction() { return button->leftAction->currentItem(); } #ifdef USECOMBO void leftAction(int v) { button->leftAction->setCurrentItem(v); } #else void leftAction(int v) { button->leftAction->select(v); } #endif int rightAction() { return button->rightAction->currentItem(); } #ifdef USECOMBO void rightAction(int v) { button->rightAction->setCurrentItem(v); } #else void rightAction(int v) { button->rightAction->select(v); } #endif int upAction() { return button->upAction->currentItem(); } #ifdef USECOMBO void upAction(int v) { button->upAction->setCurrentItem(v); } #else void upAction(int v) { button->upAction->select(v); } #endif int downAction() { return button->downAction->currentItem(); } #ifdef USECOMBO void downAction(int v) { button->downAction->setCurrentItem(v); } #else void downAction(int v) { button->downAction->select(v); } #endif bool leftScroll() { return button->leftScroll->isChecked(); } void leftScroll(bool v) { button->leftScroll->setChecked(v); } bool rightScroll() { return button->rightScroll->isChecked(); } void rightScroll(bool v) { button->rightScroll->setChecked(v); } bool upScroll() { return button->upScroll->isChecked(); } void upScroll(bool v) { button->upScroll->setChecked(v); } bool downScroll() { return button->downScroll->isChecked(); } void downScroll(bool v) { button->downScroll->setChecked(v); } int gfxsize() { return layout2->gfxzoom->value(); } void gfxsize(int v) { layout2->gfxzoom->setValue(v); } int pageoverlap() { return layout2->pageoverlap->value(); } void pageoverlap(int v) { layout2->pageoverlap->setValue(v); } bool twotouch() { return inter->twotouch->isChecked(); } void twotouch(bool v) { inter->twotouch->setChecked(v); } bool ideogram() { return inter->ideogram->isChecked(); } void ideogram(bool v) { inter->ideogram->setChecked(v); } int ideogramwidth() { return inter->ideogramwidth->value(); } void ideogramwidth(int v) { inter->ideogramwidth->setValue(v); } bool propfontchange() { return inter->propfontchange->isChecked(); } void propfontchange(bool v) { inter->propfontchange->setChecked(v); } int encoding() { return inter->encoding->currentItem(); } #ifdef USECOMBO void encoding(int v) { inter->encoding->setCurrentItem(v); } #else void encoding(int v) { inter->encoding->select(v); } #endif }; #endif // CPREFS_H diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index af1da27..087ce00 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp @@ -1836,1537 +1836,1537 @@ void QTReaderApp::showprefs() reader->m_encd = prefwin->encoding(); reader->m_charpc = prefwin->ideogramwidth(); if ( reader->m_fontname != prefwin->Font() || m_propogatefontchange != prefwin->propfontchange()) { m_propogatefontchange = prefwin->propfontchange(); setfontHelper(prefwin->Font()); } delete prefwin; reader->setfilter(reader->getfilter()); reader->refresh(); } else { delete prefwin; } } void QTReaderApp::showtoolbarprefs() { #ifdef USEQPE CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); #else QFileInfo fi; QDir d = QDir::home(); // "/" if ( !d.cd(APPDIR) ) { // "/tmp" qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); d = QDir::home(); d.mkdir(APPDIR); d.cd(APPDIR); } fi.setFile(d, INIFILE); CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); #endif prefwin->tbpolicy(m_tbpolsave); prefwin->tbposition(m_tbposition-2); prefwin->tbmovable(m_tbmovesave); prefwin->floating(m_bFloatingDialog); if (prefwin->exec()) { m_bFloatingDialog = prefwin->floating(); if ( m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() || m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) || m_tbmovesave != prefwin->tbmovable() ) { QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); } m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); m_tbmovesave = prefwin->tbmovable(); bool isChanged = prefwin->isChanged(); delete prefwin; #ifdef USEQPE Config config( APPDIR ); #else QFileInfo fi; QDir d = QDir::home(); // "/" if ( !d.cd(APPDIR) ) { // "/tmp" qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); d = QDir::home(); d.mkdir(APPDIR); d.cd(APPDIR); } fi.setFile(d, INIFILE); Config config( fi.absFilePath() ); #endif if (isChanged) addtoolbars(&config); } else { delete prefwin; } } void QTReaderApp::showinfo() { unsigned long fs, ts, pl; if (reader->empty()) { QMessageBox::information(this, PROGNAME, "No file loaded", 1); } else { reader->sizes(fs,ts); pl = reader->pagelocate(); m_infoWin->setFileSize(fs); m_infoWin->setTextSize(ts); m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); m_infoWin->setLocation(pl); m_infoWin->setRead((100*pl + (ts >> 1))/ts); editorStack->raiseWidget( m_infoWin ); m_infoWin->setFocus(); } } void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) { if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; #ifdef _UNICODE CBuffer buff(name.length()+1); int i; for (i = 0; i < name.length(); i++) { buff[i] = name[i].unicode(); } buff[i] = 0; CBuffer buff2(text.length()+1); for (i = 0; i < text.length(); i++) { buff2[i] = text[i].unicode(); } buff2[i] = 0; pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); #else pBkmklist->push_front(Bkmk((const tchar*)text,posn)); #endif m_fBkmksChanged = true; pBkmklist->sort(); } void QTReaderApp::addAnno(const QString& name, const QString& text) { if (m_annoIsEditing) { if (name.isEmpty()) { QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); } else { addAnno(name, text, m_annoWin->getPosn()); } showEditTools(); } else { if (m_annoWin->edited()) { CBuffer buff(text.length()+1); int i; for (i = 0; i < text.length(); i++) { buff[i] = text[i].unicode(); } buff[i] = 0; m_fBkmksChanged = true; m_anno->setAnno(buff.data()); } bool found = findNextBookmark(m_anno->value()+1); if (found) { m_annoWin->setName(toQString(m_anno->name())); m_annoWin->setAnno(toQString(m_anno->anno())); } else { showEditTools(); } } } bool QTReaderApp::findNextBookmark(size_t start) { bool found = false; for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) { if (iter->value() >= start) { if (iter->value() < reader->locate()) { found = true; m_anno = iter.pContent(); } break; } } return found; } void QTReaderApp::addanno() { if (reader->empty()) { QMessageBox::information(this, PROGNAME, "No file loaded", 1); } else { m_annoWin->setName(""); m_annoWin->setAnno(""); m_annoWin->setPosn(reader->pagelocate()); m_annoIsEditing = true; editorStack->raiseWidget( m_annoWin ); #ifdef USEQPE Global::showInputMethod(); #endif m_annoWin->setFocus(); } } void QTReaderApp::infoClose() { showEditTools(); } /* void QTReaderApp::fileRevert() { clear(); fileOpen(); } void QTReaderApp::editCut() { #ifndef QT_NO_CLIPBOARD editor->cut(); #endif } */ void QTReaderApp::editMark() { m_savedpos = reader->pagelocate(); } void QTReaderApp::editCopy() { QClipboard* cb = QApplication::clipboard(); QString text; int ch; unsigned long currentpos = reader->pagelocate(); unsigned long endpos = reader->locate(); if (m_savedpos == 0xffffffff) { m_savedpos = currentpos; } reader->jumpto(m_savedpos); while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) { text += ch; } cb->setText(text); reader->locate(currentpos); m_savedpos = 0xffffffff; } void QTReaderApp::gotoStart() { reader->locate(reader->buffdoc.startSection()); } void QTReaderApp::gotoEnd() { reader->dopageup(reader->buffdoc.endSection()); } void QTReaderApp::pageup() { reader->NavUp(); } void QTReaderApp::pagedn() { reader->NavDown(); } void QTReaderApp::pagemode(bool _b) { reader->setpagemode(_b); } /* void QTReaderApp::setspacing() { m_nRegAction = cMonoSpace; char lcn[20]; sprintf(lcn, "%lu", reader->m_charpc); regEdit->setText(lcn); do_regedit(); } */ void QTReaderApp::settarget() { m_nRegAction = cSetTarget; QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) + "/" + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); regEdit->setText(text); do_regedit(); } /* void QTReaderApp::do_mono(const QString& lcn) { bool ok; unsigned long ulcn = lcn.toULong(&ok); if (ok) { reader->m_charpc = ulcn; reader->setfont(); reader->refresh(); // reader->setmono(true); } else QMessageBox::information(this, PROGNAME, "Must be a number"); } */ /* void QTReaderApp::editPaste() { #ifndef QT_NO_CLIPBOARD editor->paste(); #endif } */ void QTReaderApp::editFind() { searchStart = reader->pagelocate(); #ifdef __ISEARCH searchStack = new QStack<searchrecord>; #endif #ifdef USEQPE Global::showInputMethod(); #endif searchBar->show(); searchVisible = TRUE; searchEdit->setFocus(); #ifdef __ISEARCH searchStack->push(new searchrecord("",reader->pagelocate())); #endif } void QTReaderApp::findNext() { // // qDebug("findNext called\n"); #ifdef __ISEARCH QString arg = searchEdit->text(); #else QRegExp arg = searchEdit->text(); #endif CDrawBuffer test(&(reader->m_fontControl)); size_t start = reader->pagelocate(); reader->jumpto(start); reader->getline(&test); dosearch(start, test, arg); } void QTReaderApp::findClose() { searchVisible = FALSE; searchEdit->setText(""); #ifdef USEQPE Global::hideInputMethod(); #endif searchBar->hide(); #ifdef __ISEARCH // searchStack = new QStack<searchrecord>; while (!searchStack->isEmpty()) { delete searchStack->pop(); } delete searchStack; #endif reader->setFocus(); } void QTReaderApp::regClose() { regVisible = FALSE; regEdit->setText(""); regBar->hide(); #ifdef USEQPE Global::hideInputMethod(); #endif reader->setFocus(); } #ifdef __ISEARCH bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) #else bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) #endif { bool ret = true; unsigned long fs, ts; reader->sizes(fs,ts); size_t pos = reader->locate(); pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); pbar->show(); pbar->raise(); pbar->reset(); int offset; int lastpc = (100*pos)/ts; pbar->setProgress(lastpc); // qApp->processEvents(); if (reader->buffdoc.getpara(test) >= 0) { reader->setFocus(); #ifdef __ISEARCH while (strstr(test.data(),(const tchar*)arg) == NULL) #else #ifdef _UNICODE while ((offset = arg.match(toQString(test.data()))) == -1) #else while (arg.match(test.data()) == -1) #endif #endif { pos = reader->locate(); int pc = (100*pos)/ts; if (pc != lastpc) { pbar->setProgress(pc); qApp->processEvents(); reader->setFocus(); lastpc = pc; } if (reader->buffdoc.getpara(test) < 0) { if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) pos = searchStart; else pos = start; findClose(); pbar->hide(); reader->locate(pos); return false; } } // qDebug("Found it at %u:%u", pos, offset); pbar->hide(); // qDebug("Hid"); reader->locate(pos+offset); // qDebug("Loacted"); // qDebug("page up"); ret = true; } else { if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) pos = searchStart; else pos = start; ret = false; findClose(); } return ret; } #ifdef __ISEARCH void QTReaderApp::search(const QString & arg) { searchrecord* ss = searchStack->top(); CBuffer test; size_t start = reader->pagelocate(); bool haspopped = false; while (arg.left(ss->s.length()) != ss->s) { haspopped = true; start = ss->pos; // reader->locate(start); searchStack->pop(); delete ss; } if (haspopped) reader->locate(start); /* if (arg.length() < ss->len) { start = ss->pos; reader->locate(start); searchStack->pop(); delete ss; } */ else { start = reader->pagelocate(); reader->jumpto(start); searchStack->push(new searchrecord(arg,start)); } dosearch(start, test, arg); } #else void QTReaderApp::search() { findNext(); } #endif void QTReaderApp::openFile( const QString &f ) { // qDebug("File:%s", (const char*)f); // openFile(DocLnk(f)); //} // //void QTReaderApp::openFile( const DocLnk &f ) //{ clear(); QFileInfo fm(f); if ( fm.exists() ) { // QMessageBox::information(0, "Progress", "Calling fileNew()"); #ifdef USEQPE if (fm.extension( FALSE ) == "desktop") { DocLnk d(f); QFileInfo fnew(d.file()); fm = fnew; if (!fm.exists()) return; } #endif clear(); reader->setText(fm.baseName(), fm.absFilePath()); m_loadedconfig = readconfig(reader->m_string, false); showEditTools(); readbkmks(); m_savedpos = 0xffffffff; } else { QMessageBox::information(this, PROGNAME, "File does not exist"); reader->m_lastfile = QString::null; } } /* void QTReaderApp::resizeEvent(QResizeEvent* e) { if (m_fullscreen) { showNormal(); showFullScreen(); } } */ void QTReaderApp::handlekey(QKeyEvent* e) { // qDebug("Keypress event"); timeb now; ftime(&now); unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; if (etime < m_debounce) { return; } m_lastkeytime = now; switch(e->key()) { case Key_Escape: // qDebug("escape event"); if (m_disableesckey) { m_disableesckey = false; } else { m_bcloseDisabled = true; if (m_fullscreen) { m_actFullscreen->setOn(false); e->accept(); } else { // qDebug("escape action"); doAction(m_escapeTarget, e); } } break; case Key_Space: { doAction(m_spaceTarget, e); } break; case Key_Return: { doAction(m_returnTarget, e); } break; case Key_Left: { if (reader->m_autoScroll && m_leftScroll) { reader->reduceScroll(); } else { doAction(m_leftTarget, e); } } break; case Key_Right: { if (reader->m_autoScroll && m_rightScroll) { reader->increaseScroll(); } else { doAction(m_rightTarget, e); } } break; case Key_Up: { if (reader->m_autoScroll && m_upScroll) { reader->increaseScroll(); } else { doAction(m_upTarget, e); } } break; case Key_Down: { if (reader->m_autoScroll && m_downScroll) { reader->reduceScroll(); } else { doAction(m_downTarget, e); } } break; default: { e->ignore(); } /* QString msg("Key press was:"); QString key; msg += key.setNum(e->key()); QMessageBox::information(this, PROGNAME, msg); */ } } void QTReaderApp::showEditTools() { // if ( !doc ) // close(); if (m_fullscreen) { if (menubar != NULL) menubar->hide(); if (fileBar != NULL) fileBar->hide(); if (viewBar != NULL) viewBar->hide(); if (navBar != NULL) navBar->hide(); if (markBar != NULL) markBar->hide(); searchBar->hide(); regBar->hide(); #ifdef USEQPE Global::hideInputMethod(); #endif m_fontBar->hide(); // showNormal(); showFullScreen(); } else { // qDebug("him"); #ifdef USEQPE Global::hideInputMethod(); #endif // qDebug("eb"); menubar->show(); if (fileBar != NULL) fileBar->show(); if (viewBar != NULL) viewBar->show(); if (navBar != NULL) navBar->show(); if (markBar != NULL) markBar->show(); mb->show(); if ( searchVisible ) { #ifdef USEQPE Global::showInputMethod(); #endif searchBar->show(); } if ( regVisible ) { #ifdef USEQPE Global::showInputMethod(); #endif regBar->show(); } if (m_fontVisible) m_fontBar->show(); // qDebug("sn"); showNormal(); // qDebug("sm"); #ifdef USEQPE showMaximized(); #endif // setCentralWidget(reader); } // qDebug("uc"); updateCaption(); // qDebug("rw"); editorStack->raiseWidget( reader ); // qDebug("sf"); reader->setFocus(); reader->refresh(); } /* void QTReaderApp::save() { if ( !doc ) return; if ( !editor->edited() ) return; QString rt = editor->text(); QString pt = rt; if ( doc->name().isEmpty() ) { unsigned ispace = pt.find( ' ' ); unsigned ienter = pt.find( '\n' ); int i = (ispace < ienter) ? ispace : ienter; QString docname; if ( i == -1 ) { if ( pt.isEmpty() ) docname = "Empty Text"; else docname = pt; } else { docname = pt.left( i ); } doc->setName(docname); } FileManager fm; fm.saveFile( *doc, rt ); } */ void QTReaderApp::clear() { // if (doc != 0) // { // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); // delete doc; // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); // doc = 0; // } reader->clear(); } void QTReaderApp::updateCaption() { // if ( !doc ) // setCaption( tr("QTReader") ); // else { // QString s = doc->name(); // if ( s.isEmpty() ) // s = tr( "Unnamed" ); - setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); + setCaption( reader->m_string + " - " + tr("Reader") ); // } } void QTReaderApp::setDocument(const QString& fileref) { bFromDocView = TRUE; //QMessageBox::information(0, "setDocument", fileref); openFile(fileref); // showEditTools(); } void QTReaderApp::closeEvent( QCloseEvent *e ) { // qDebug("Close event"); if (m_fullscreen) { m_fullscreen = false; showEditTools(); e->accept(); } else if (m_dontSave) { e->accept(); } else { if (editorStack->visibleWidget() == reader) { if ((m_escapeTarget != cesNone) && m_bcloseDisabled) { // qDebug("Close disabled"); m_bcloseDisabled = false; e->ignore(); } else { if (m_fontVisible) { m_fontBar->hide(); m_fontVisible = false; } if (regVisible) { regBar->hide(); #ifdef USEQPE Global::hideInputMethod(); #endif regVisible = false; return; } if (searchVisible) { searchBar->hide(); #ifdef USEQPE Global::hideInputMethod(); #endif searchVisible = false; return; } if (m_fBkmksChanged && pBkmklist != NULL) { if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) savebkmks(); delete pBkmklist; pBkmklist = NULL; m_fBkmksChanged = false; } bFromDocView = FALSE; updatefileinfo(); saveprefs(); e->accept(); } } else { showEditTools(); m_disableesckey = true; } } } void QTReaderApp::do_gotomark() { m_nBkmkAction = cGotoBkmk; if (!listbkmk(pBkmklist)) QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); } void QTReaderApp::do_delmark() { m_nBkmkAction = cDelBkmk; if (!listbkmk(pBkmklist)) QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); } bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) { bkmkselector->clear(); if (_lab.isEmpty()) bkmkselector->setText("Cancel"); else bkmkselector->setText(_lab); int cnt = 0; if (plist != NULL) { for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) { #ifdef _UNICODE // qDebug("Item:%s", (const char*)toQString(i->name())); bkmkselector->insertItem(toQString(i->name())); #else bkmkselector->insertItem(i->name()); #endif cnt++; } } if (cnt > 0) { hidetoolbars(); editorStack->raiseWidget( bkmkselector ); return true; } else return false; } void QTReaderApp::do_autogen() { m_nRegAction = cAutoGen; regEdit->setText(m_autogenstr); do_regedit(); } void QTReaderApp::do_regedit() { // fileBar->hide(); reader->bDoUpdates = false; // qDebug("Showing regbar"); regBar->show(); // qDebug("Showing kbd"); #ifdef USEQPE Global::showInputMethod(); #endif regVisible = true; regEdit->setFocus(); // qApp->processEvents(); reader->bDoUpdates = true; reader->update(); } bool QTReaderApp::openfrombkmk(Bkmk* bk) { QString fn = toQString( CFiledata(bk->anno()).name() ); // qDebug("fileinfo"); if (!fn.isEmpty() && QFileInfo(fn).isFile()) { // qDebug("Opening"); openFile(fn); struct stat fnstat; stat((const char *)reader->m_lastfile, &fnstat); if (CFiledata(bk->anno()).date() != fnstat.st_mtime) { CFiledata fd(bk->anno()); fd.setdate(fnstat.st_mtime); bk->value(0); } else { unsigned short svlen = bk->filedatalen(); unsigned char* svdata = bk->filedata(); reader->putSaveData(svdata, svlen); // setstate(svdata, svlen); if (svlen != 0) { QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); } // qDebug("updating"); // showEditTools(); reader->locate(bk->value()); } return true; } else { return false; } } void QTReaderApp::gotobkmk(int ind) { showEditTools(); switch (m_nBkmkAction) { case cOpenFile: { // qApp->processEvents(); if (!openfrombkmk((*pOpenlist)[ind])) { pOpenlist->erase(ind); QMessageBox::information(this, PROGNAME, "Can't find file"); } } break; case cGotoBkmk: reader->locate((*pBkmklist)[ind]->value()); break; case cDelBkmk: //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); pBkmklist->erase(ind); m_fBkmksChanged = true; // pBkmklist->sort(); break; case cRmBkmkFile: { #ifndef USEQPE QDir d = QDir::home(); // "/" d.cd(APPDIR); d.remove(bkmkselector->text(ind)); #else /* USEQPE */ unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); #endif /* USEQPE */ } break; case cLdConfig: readconfig(bkmkselector->text(ind), false); break; case cRmConfig: { #ifndef USEQPE QDir d = QDir::home(); // "/" d.cd(APPDIR "/configs"); d.remove(bkmkselector->text(ind)); #else /* USEQPE */ unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); #endif /* USEQPE */ } break; case cExportLinks: { #ifndef USEQPE QDir d = QDir::home(); // "/" d.cd(APPDIR "/urls"); QFileInfo fi(d, bkmkselector->text(ind)); if (fi.exists()) { QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); if (!outfile.isEmpty()) { FILE* fout = fopen((const char *)outfile, "w"); if (fout != NULL) { FILE* fin = fopen((const char *)fi.absFilePath(), "r"); if (fin != NULL) { fprintf(fout, "<html><body>\n"); int ch = 0; while ((ch = fgetc(fin)) != EOF) { fputc(ch, fout); } fclose(fin); fprintf(fout, "</html></body>\n"); d.remove(bkmkselector->text(ind)); } fclose(fout); } else QMessageBox::information(this, PROGNAME, "Couldn't open output"); } } #else /* USEQPE */ FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); if (fin != NULL) { bool allok = false; fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); if (fb->exec()) { QString outfile = fb->getCurrentFile(); FILE* fout = fopen((const char *)outfile, "w"); if (fout != NULL) { fprintf(fout, "<html><body>\n"); int ch = 0; while ((ch = fgetc(fin)) != EOF) { fputc(ch, fout); } fprintf(fout, "</html></body>\n"); fclose(fout); allok = true; } else QMessageBox::information(this, PROGNAME, "Couldn't open output"); } delete fb; fclose(fin); if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); } else { QMessageBox::information(this, PROGNAME, "Couldn't open input"); } /* CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); int ret = f->exec(); qDebug("Return:%d", ret); DocLnk* doc = f->getDoc(); if (doc != NULL) { FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); QString rt; rt = "<html><body>\n"; int ch = 0; while ((ch = fgetc(fin)) != EOF) { rt += (char)ch; } fclose(fin); rt += "</html></body>\n"; if ( doc->name().isEmpty() ) { doc->setName(bkmkselector->text(ind)); } FileManager fm; fm.saveFile( *doc, rt ); qDebug("YES"); } else { qDebug("NO"); } delete f; */ #endif /* USEQPE */ } break; } } void QTReaderApp::cancelbkmk() { if (m_nBkmkAction == cOpenFile) { QString fn = usefilebrowser(); if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); } showEditTools(); } void QTReaderApp::jump() { m_nRegAction = cJump; char lcn[20]; sprintf(lcn, "%lu", reader->pagelocate()); regEdit->setText(lcn); do_regedit(); } void QTReaderApp::do_jump(const QString& lcn) { bool ok; unsigned long ulcn = lcn.toULong(&ok); if (ok) reader->locate(ulcn); else QMessageBox::information(this, PROGNAME, "Must be a number"); } void QTReaderApp::do_regaction() { reader->bDoUpdates = false; regBar->hide(); #ifdef USEQPE Global::hideInputMethod(); #endif regVisible = false; switch(m_nRegAction) { case cAutoGen: do_autogen(regEdit->text()); break; case cAddBkmk: do_addbkmk(regEdit->text()); break; case cJump: do_jump(regEdit->text()); break; /* case cMonoSpace: do_mono(regEdit->text()); break; */ case cSetTarget: do_settarget(regEdit->text()); break; #ifdef _SCROLLPIPE case cSetPipeTarget: do_setpipetarget(regEdit->text()); break; #endif case cSetConfigName: // qDebug("Saving config"); do_saveconfig(regEdit->text(), false); break; } // reader->restore(); // fileBar->show(); reader->setFocus(); // qApp->processEvents(); reader->bDoUpdates = true; reader->update(); } void QTReaderApp::do_settarget(const QString& _txt) { int ind = _txt.find('/'); if (ind == -1) { m_targetapp = ""; m_targetmsg = ""; QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); } else { m_targetapp = _txt.left(ind); m_targetmsg = _txt.right(_txt.length()-ind-1); } } void QTReaderApp::chooseencoding() { m_fontSelector->clear(); m_fontSelector->insertItem("Ascii"); m_fontSelector->insertItem("UTF-8"); m_fontSelector->insertItem("UCS-2(BE)"); m_fontSelector->insertItem("USC-2(LE)"); m_fontSelector->insertItem("Palm"); for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) { m_fontSelector->insertItem(iter->mime); } // delete the FontDatabase!!! m_fontSelector->setCurrentItem (reader->m_encd); m_fontAction = cChooseEncoding; m_fontBar->show(); m_fontVisible = true; } void QTReaderApp::setfont() { m_fontSelector->clear(); { #ifdef USEQPE FontDatabase f; #else QFontDatabase f; #endif QStringList flist = f.families(); m_fontSelector->insertStringList(flist); } // delete the FontDatabase!!! for (int i = 1; i <= m_fontSelector->count(); i++) { if (m_fontSelector->text(i) == reader->m_fontname) { m_fontSelector->setCurrentItem(i); break; } } m_fontAction = cChooseFont; m_fontBar->show(); m_fontVisible = true; } void QTReaderApp::setfontHelper(const QString& lcn, int size) { if (size == 0) size = reader->m_fontControl.currentsize(); if (m_propogatefontchange) { QFont f(lcn, 10); bkmkselector->setFont( f ); regEdit->setFont( f ); searchEdit->setFont( f ); m_annoWin->setFont( f ); } reader->m_fontname = lcn; if (!reader->ChangeFont(size)) { reader->ChangeFont(size); } } void QTReaderApp::do_setencoding(int i) { // qDebug("setencoding:%d", i); if (m_fontAction == cChooseEncoding) { reader->setencoding(i); } reader->refresh(); m_fontBar->hide(); m_fontVisible = false; // qDebug("showedit"); if (reader->isVisible()) showEditTools(); // qDebug("showeditdone"); } void QTReaderApp::do_setfont(const QString& lcn) { if (m_fontAction == cChooseFont) { setfontHelper(lcn); } reader->refresh(); m_fontBar->hide(); m_fontVisible = false; // qDebug("showedit"); //if (reader->isVisible()) showEditTools(); // qDebug("showeditdone"); } void QTReaderApp::do_autogen(const QString& regText) { unsigned long fs, ts; reader->sizes(fs,ts); // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); m_autogenstr = regText; QRegExp re(regText); CBuffer buff; if (pBkmklist != NULL) delete pBkmklist; pBkmklist = new CList<Bkmk>; m_fBkmksChanged = true; pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); pbar->show(); pbar->raise(); pbar->reset(); reader->update(); qApp->processEvents(); reader->setFocus(); reader->jumpto(0); int lastpc = 0; int i = 0; while (i >= 0) { unsigned int lcn = reader->locate(); int pc = (100*lcn)/ts; if (pc != lastpc) { pbar->setProgress(pc); qApp->processEvents(); if (reader->locate() != lcn) reader->jumpto(lcn); reader->setFocus(); lastpc = pc; } i = reader->buffdoc.getpara(buff); #ifdef _UNICODE if (re.match(toQString(buff.data())) != -1) #else if (re.match(buff.data()) != -1) #endif pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); } pBkmklist->sort(); pbar->setProgress(100); qApp->processEvents(); pbar->hide(); reader->refresh(); } void QTReaderApp::saveprefs() { // qDebug("saveprefs"); // reader->saveprefs("uqtreader"); // if (!m_loadedconfig) do_saveconfig( APPDIR, true ); /* Config config( APPDIR ); config.setGroup( "View" ); reader->m_lastposn = reader->pagelocate(); config.writeEntry("FloatDialogs", m_bFloatingDialog); config.writeEntry( "StripCr", reader->bstripcr ); config.writeEntry( "AutoFmt", reader->bautofmt ); config.writeEntry( "TextFmt", reader->btextfmt ); config.writeEntry( "StripHtml", reader->bstriphtml ); config.writeEntry( "Dehyphen", reader->bdehyphen ); config.writeEntry( "Depluck", reader->bdepluck ); config.writeEntry( "Dejpluck", reader->bdejpluck ); config.writeEntry( "OneSpace", reader->bonespace ); config.writeEntry( "Unindent", reader->bunindent ); config.writeEntry( "Repara", reader->brepara ); config.writeEntry( "DoubleSpace", reader->bdblspce ); config.writeEntry( "Indent", reader->bindenter ); config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); config.writeEntry( "ScrollDelay", reader->m_delay); config.writeEntry( "LastFile", reader->m_lastfile ); config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); config.writeEntry( "PageMode", reader->m_bpagemode ); config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); config.writeEntry( "SwapMouse", reader->m_swapmouse); config.writeEntry( "Fontname", reader->m_fontname ); config.writeEntry( "Encoding", reader->m_encd ); config.writeEntry( "CharSpacing", reader->m_charpc ); config.writeEntry( "Overlap", (int)(reader->m_overlap) ); config.writeEntry( "Margin", (int)reader->m_border ); config.writeEntry( "TargetApp", m_targetapp ); config.writeEntry( "TargetMsg", m_targetmsg ); #ifdef _SCROLLPIPE config.writeEntry( "PipeTarget", reader->m_pipetarget ); config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); #endif config.writeEntry( "TwoTouch", m_twoTouch ); config.writeEntry( "Annotation", m_doAnnotation); config.writeEntry( "Dictionary", m_doDictionary); config.writeEntry( "Clipboard", m_doClipboard); config.writeEntry( "SpaceTarget", m_spaceTarget); config.writeEntry( "EscapeTarget", m_escapeTarget); config.writeEntry( "ReturnTarget", m_returnTarget); config.writeEntry( "LeftTarget", m_leftTarget); config.writeEntry( "RightTarget", m_rightTarget); config.writeEntry( "UpTarget", m_upTarget); config.writeEntry( "DownTarget", m_downTarget); config.writeEntry("LeftScroll", m_leftScroll); config.writeEntry("RightScroll", m_rightScroll); config.writeEntry("UpScroll", m_upScroll); config.writeEntry("DownScroll", m_downScroll); #ifdef REPALM config.writeEntry( "Repalm", reader->brepalm ); #endif config.writeEntry( "Remap", reader->bremap ); config.writeEntry( "Peanut", reader->bpeanut ); config.writeEntry( "MakeBold", reader->bmakebold ); config.writeEntry( "Continuous", reader->m_continuousDocument ); config.writeEntry( "FullJust", reader->bfulljust ); config.writeEntry( "ExtraSpace", reader->getextraspace() ); config.writeEntry( "ExtraLead", reader->getlead() ); config.writeEntry( "Basesize", (int)reader->getBaseSize()); config.writeEntry( "RequestorFontChange", m_propogatefontchange); config.setGroup( "Toolbar" ); config.writeEntry("Movable", m_tbmovesave); config.writeEntry("Policy", m_tbpolsave); config.writeEntry("Position", m_tbposition); */ savefilelist(); } /* void QTReaderApp::oldFile() { // qDebug("oldFile called"); reader->setText(true); // qDebug("settext called"); showEditTools(); // qDebug("showedit called"); } */ /* void info_cb(Fl_Widget* o, void* _data) { if (infowin == NULL) { infowin = new Fl_Window(160,240); filename = new Fl_Output(45,5,110,14,"Filename"); filesize = new Fl_Output(45,25,110,14,"Filesize"); textsize = new Fl_Output(45,45,110,14,"Textsize"); comprat = new CBar(45,65,110,14,"Ratio %"); posn = new Fl_Output(45,85,110,14,"Location"); frcn = new CBar(45,105,110,14,"% Read"); about = new Fl_Multiline_Output(5,125,150,90); about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); infowin->set_modal(); } if (((reader_ui *)_data)->g_filename[0] != '\0') { unsigned long fs,ts; tchar sz[20]; ((reader_ui *)_data)->input->sizes(fs,ts); unsigned long pl = ((reader_ui *)_data)->input->locate(); filename->value(((reader_ui *)_data)->g_filename); sprintf(sz,"%u",fs); filesize->value(sz); sprintf(sz,"%u",ts); textsize->value(sz); comprat->value(100-(100*fs + (ts >> 1))/ts); sprintf(sz,"%u",pl); posn->value(sz); frcn->value((100*pl + (ts >> 1))/ts); } infowin->show(); } */ void QTReaderApp::savebkmks() { if (pBkmklist != NULL) { #ifndef USEQPE QDir d = QDir::home(); // "/" d.cd(APPDIR); QFileInfo fi(d, reader->m_string); BkmkFile bf((const char *)fi.absFilePath(), true); #else /* USEQPE */ BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); #endif /* USEQPE */ bf.write(*pBkmklist); } m_fBkmksChanged = false; } void QTReaderApp::readfilelist() { #ifndef USEQPE QDir d = QDir::home(); // "/" d.cd(APPDIR); QFileInfo fi(d, ".openfiles"); BkmkFile bf((const char *)fi.absFilePath()); #else /* USEQPE */ BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); #endif /* USEQPE */ // qDebug("Reading open files"); pOpenlist = bf.readall(); // if (pOpenlist != NULL) qDebug("...with success"); // else qDebug("...without success!"); } void QTReaderApp::savefilelist() { if (pOpenlist != NULL) { #ifndef USEQPE QDir d = QDir::home(); // "/" d.cd(APPDIR); QFileInfo fi(d, ".openfiles"); BkmkFile bf((const char *)fi.absFilePath(), true); #else /* USEQPE */ BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); #endif /* USEQPE */ // qDebug("Writing open files"); bf.write(*pOpenlist); } } void QTReaderApp::readbkmks() { if (pBkmklist != NULL) { delete pBkmklist; diff --git a/noncore/apps/opie-reader/ToolbarPrefs.h b/noncore/apps/opie-reader/ToolbarPrefs.h index 297d63a..9571c28 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.h +++ b/noncore/apps/opie-reader/ToolbarPrefs.h @@ -1,263 +1,263 @@ /**************************************************************************** ** Form interface generated from reading ui file 'Prefs.ui' ** ** Created: Tue Feb 11 23:53:32 2003 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #ifndef CTOOLBARPREFS_H #define CTOOLBARPREFS_H #include "useqpe.h" #include <qvariant.h> #include <qwidget.h> #include <qtabdialog.h> #include <qtabwidget.h> #include <qspinbox.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qlineedit.h> #ifdef USEQPE #include <qpe/menubutton.h> #include <qpe/config.h> #else #include "preferences.h" #endif //#include "opie.h" //#ifdef OPIE #define USECOMBO //#endif class QVBoxLayout; class QHBoxLayout; class QGridLayout; //class QCheckBox; class QLabel; //class QSpinBox; /* class CBarPrefs1 : public QWidget { Q_OBJECT Config& config; QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; bool m_isChanged; private slots: void isChanged(int _v) { m_isChanged = true; } public: CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CBarPrefs1(); void saveall(); bool isChanged() { return m_isChanged; } }; */ class CFileBarPrefs : public QWidget { Q_OBJECT Config& config; QCheckBox *open, *close, *info, *twotouch, *find, *scroll; bool m_isChanged; private slots: void isChanged(int _v) { m_isChanged = true; } public: CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CFileBarPrefs(); void saveall(); bool isChanged() { return m_isChanged; } }; class CNavBarPrefs : public QWidget { Q_OBJECT Config& config; QCheckBox *scroll, *navback, *navhome, *navforward; QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; bool m_isChanged; private slots: void isChanged(int _v) { m_isChanged = true; } public: CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CNavBarPrefs(); void saveall(); bool isChanged() { return m_isChanged; } }; /* class CBarPrefs2 : public QWidget { Q_OBJECT Config& config; QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; bool m_isChanged; private slots: void isChanged(int _v) { m_isChanged = true; } public: CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CBarPrefs2(); void saveall(); bool isChanged() { return m_isChanged; } }; */ class CViewBarPrefs : public QWidget { Q_OBJECT Config& config; QCheckBox *fullscreen, *zoomin, *zoomout, *setfont, *encoding, *ideogram; bool m_isChanged; private slots: void isChanged(int _v) { m_isChanged = true; } public: CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CViewBarPrefs(); void saveall(); bool isChanged() { return m_isChanged; } }; class CMarkBarPrefs : public QWidget { Q_OBJECT Config& config; QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; bool m_isChanged; private slots: void isChanged(int _v) { m_isChanged = true; } public: CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CMarkBarPrefs(); void saveall(); bool isChanged() { return m_isChanged; } }; class CIndBarPrefs : public QWidget { Q_OBJECT Config& config; QCheckBox *indannotate; bool m_isChanged; private slots: void isChanged(int _v) { m_isChanged = true; } public: CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CIndBarPrefs(); void saveall(); bool isChanged() { return m_isChanged; } }; class CMiscBarPrefs : public QWidget { - + Q_OBJECT public: CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~CMiscBarPrefs(); #ifdef USECOMBO QComboBox *tbpolicy, *tbposition; #else MenuButton *tbpolicy, *tbposition; #endif QCheckBox *tbmovable, *floating; }; class CBarPrefs : public QDialog { Q_OBJECT ; CMiscBarPrefs* misc; CFileBarPrefs* filebar; CNavBarPrefs* navbar; CViewBarPrefs* viewbar; CMarkBarPrefs* markbar; CIndBarPrefs* indbar; Config config; void keyPressEvent(QKeyEvent* e) { switch (e->key()) { case Key_Escape: e->accept(); reject(); break; case Key_Space: case Key_Return: e->accept(); accept(); break; default: QWidget::keyPressEvent(e); } } public: CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); ~CBarPrefs() { if (result()) { if (navbar->isChanged()) navbar->saveall(); if (filebar->isChanged()) filebar->saveall(); if (viewbar->isChanged()) viewbar->saveall(); if (markbar->isChanged()) markbar->saveall(); if (indbar->isChanged()) indbar->saveall(); } } bool isChanged() { return ( filebar->isChanged() || navbar->isChanged() || viewbar->isChanged() || markbar->isChanged() || indbar->isChanged() ); } bool floating() { return misc->floating->isChecked(); } void floating(bool v) { misc->floating->setChecked(v); } int tbpolicy() { return misc->tbpolicy->currentItem(); } #ifdef USECOMBO void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } #else void tbpolicy(int v) { misc->tbpolicy->select(v); } #endif bool tbmovable() { return misc->tbmovable->isChecked(); } void tbmovable(bool v) { misc->tbmovable->setChecked(v); } int tbposition() { return misc->tbposition->currentItem(); } #ifdef USECOMBO void tbposition(int v) { misc->tbposition->setCurrentItem(v); } #else void tbposition(int v) { misc->tbposition->select(v); } #endif }; #endif // CPREFS_H diff --git a/noncore/apps/opie-reader/opie-reader.control b/noncore/apps/opie-reader/opie-reader.control index 9996297..b7b0e8f 100644 --- a/noncore/apps/opie-reader/opie-reader.control +++ b/noncore/apps/opie-reader/opie-reader.control @@ -1,10 +1,10 @@ Package: opie-reader Files: bin/reader apps/Applications/opie-reader.desktop pics/opie-reader/* Priority: optional Section: applications Maintainer: Tim Wentford <timwentford@hotmail.com> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal License: GPL Description: E-Book reader +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/opie-write/opie-write.control b/noncore/apps/opie-write/opie-write.control index 52b518a..7b37671 100644 --- a/noncore/apps/opie-write/opie-write.control +++ b/noncore/apps/opie-write/opie-write.control @@ -1,10 +1,10 @@ Package: opie-write Files: bin/opie-write apps/Applications/opie-write.desktop pics/opie-write Priority: optional Section: opie/applications Maintainer: L.J. Potter <ljp@llornkcor.com> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal Description: Rich Text Editor The rich text editor for the Opie environment. +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/oxygen/opie-oxygen.control b/noncore/apps/oxygen/opie-oxygen.control index 1eff80b..6d40d1b 100644 --- a/noncore/apps/oxygen/opie-oxygen.control +++ b/noncore/apps/oxygen/opie-oxygen.control @@ -1,10 +1,10 @@ Package: opie-oxygen Files: bin/oxygen apps/Applications/oxygen.desktop pics/oxygen/oxygen.png share/oxygen/* Priority: optional Section: applications Maintainer: Carsten Niehaus <cniehaus@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal Description: Periodic System of the Elements The chemistry application for the Opie-environment +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tableviewer/opie-tableviewer.control b/noncore/apps/tableviewer/opie-tableviewer.control index b5495e1..aba9b8d 100644 --- a/noncore/apps/tableviewer/opie-tableviewer.control +++ b/noncore/apps/tableviewer/opie-tableviewer.control @@ -1,11 +1,11 @@ Package: opie-tableviewer Files: bin/tableviewer apps/Applications/tableviewer.desktop Priority: optional Section: opie/applications Maintainer: Warwick Allison <warwick@trolltech.com> Architecture: arm Arch: iPAQ -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal Description: XML database browsers A table/database viewer for the Opie environment. +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp index 38ba55d..22a4917 100644 --- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp +++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp @@ -1,179 +1,179 @@ /* This file is part of KWrite Copyright (c) 2000 Waldo Bastian <bastian@kde.org> Copyright (c) 2002 Joseph Wenninger <jowenn@kde.org> $Id$ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 "katebuffer.h" // Includes for reading file #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <unistd.h> #include <qfile.h> #include <qtextstream.h> #include <qtimer.h> #include <qtextcodec.h> // #include <assert.h> #include <kdebug.h> /** * Create an empty buffer. */ KWBuffer::KWBuffer() { clear(); } void KWBuffer::clear() { m_stringListIt=0; m_stringListCurrent=0; m_stringList.clear(); m_lineCount=1; m_stringListIt = m_stringList.append(new TextLine()); } /** * Insert a file at line @p line in the buffer. */ void KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec) { if (line) { qDebug("insert File only supports insertion at line 0 == file opening"); return; } clear(); QFile iofile(file); iofile.open(IO_ReadOnly); QTextStream stream(&iofile); stream.setCodec(codec); QString qsl; int count=0; for (count=0;((qsl=stream.readLine())!=QString::null); count++) { if (count==0) { (*m_stringListIt)->append(qsl.unicode(),qsl.length()); } else { TextLine::Ptr tl=new TextLine(); tl ->append(qsl.unicode(),qsl.length()); m_stringListIt=m_stringList.append(tl); } } if (count!=0) { m_stringListCurrent=count-1; m_lineCount=count; } } void KWBuffer::loadFilePart() { } void KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec) { } void KWBuffer::slotLoadFile() { loadFilePart(); // emit linesChanged(m_totalLines); emit linesChanged(20); } /** * Return the total number of lines in the buffer. */ int KWBuffer::count() { -// qDebug("m_stringList.count %d",m_stringList.count()); + qDebug("m_stringList.count %d",m_stringList.count()); return m_lineCount; // return m_stringList.count(); // return m_totalLines; } void KWBuffer::seek(int i) { if (m_stringListCurrent == i) return; while(m_stringListCurrent < i) { ++m_stringListCurrent; ++m_stringListIt; } while(m_stringListCurrent > i) { --m_stringListCurrent; --m_stringListIt; } } TextLine::Ptr KWBuffer::line(int i) { if (i>=m_stringList.count()) return 0; seek(i); return *m_stringListIt; } void KWBuffer::insertLine(int i, TextLine::Ptr line) { seek(i); m_stringListIt = m_stringList.insert(m_stringListIt, line); m_stringListCurrent = i; m_lineCount++; } void KWBuffer::removeLine(int i) { seek(i); m_stringListIt = m_stringList.remove(m_stringListIt); m_stringListCurrent = i; m_lineCount--; } void KWBuffer::changeLine(int i) { } diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp index 844f27d..f90a5f8 100644 --- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp @@ -1,305 +1,306 @@ /*************************************************************************** katesyntaxdocument.cpp - description ------------------- begin : Sat 31 March 2001 copyright : (C) 2001,2002 by Joseph Wenninger email : 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 "katesyntaxdocument.h" #include <kateconfig.h> #include <qfile.h> #include <kdebug.h> #include <kstddirs.h> #include <klocale.h> #include <kmessagebox.h> #include <qstringlist.h> #include <kglobal.h> #include <qpe/qpeapplication.h> #include <qdir.h> SyntaxDocument::SyntaxDocument() { m_root=0; currentFile=""; setupModeList(); } void SyntaxDocument::setIdentifier(const QString& identifier) { #warning FIXME delete m_root; m_root=Opie::XMLElement::load(identifier); if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); } SyntaxDocument::~SyntaxDocument() { } void SyntaxDocument::setupModeList(bool force) { if (myModeList.count() > 0) return; KateConfig *config=KGlobal::config(); KStandardDirs *dirs = KGlobal::dirs(); // QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true); QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; QDir dir(path); QStringList list=dir.entryList("*.xml"); for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { QString Group="Highlighting_Cache"+path+*it; if ((config->hasGroup(Group)) && (!force)) { config->setGroup(Group); syntaxModeListItem *mli=new syntaxModeListItem; mli->name = config->readEntry("name",""); mli->section = config->readEntry("section",""); mli->mimetype = config->readEntry("mimetype",""); mli->extension = config->readEntry("extension",""); - mli->identifier = *it; + mli->identifier = path+*it; myModeList.append(mli); } else { qDebug("Found a description file:"+path+(*it)); setIdentifier(path+(*it)); Opie::XMLElement *e=m_root; if (e) { e=e->firstChild(); qDebug(e->tagName()); if (e->tagName()=="language") { syntaxModeListItem *mli=new syntaxModeListItem; mli->name = e->attribute("name"); mli->section = e->attribute("section"); mli->mimetype = e->attribute("mimetype"); mli->extension = e->attribute("extensions"); qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); if (mli->section.isEmpty()) mli->section=i18n("Other"); mli->identifier = path+(*it); config->setGroup(Group); config->writeEntry("name",mli->name); config->writeEntry("section",mli->section); config->writeEntry("mimetype",mli->mimetype); config->writeEntry("extension",mli->extension); myModeList.append(mli); } } } } + config->write(); // config->sync(); } SyntaxModeList SyntaxDocument::modeList() { return myModeList; } bool SyntaxDocument::nextGroup( syntaxContextData* data) { if(!data) return false; if (!data->currentGroup) data->currentGroup=data->parent->firstChild(); else data->currentGroup=data->currentGroup->nextChild(); data->item=0; if (!data->currentGroup) return false; else return true; } bool SyntaxDocument::nextItem( syntaxContextData* data) { if(!data) return false; if (!data->item) data->item=data->currentGroup->firstChild(); else data->item=data->item->nextChild(); if (!data->item) return false; else return true; } QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name) { if(!data) return QString::null; if ( (data->item) && (name.isEmpty())) return data->item->tagName(); if (data->item) return data->item->attribute(name); else return QString(); } QString SyntaxDocument::groupData( syntaxContextData* data,QString name) { if(!data) return QString::null; if (data->currentGroup) return data->currentGroup->attribute(name); else return QString(); } void SyntaxDocument::freeGroupInfo( syntaxContextData* data) { if (data) delete data; } syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) { syntaxContextData *retval=new syntaxContextData; retval->parent=0; retval->currentGroup=0; retval->item=0; if (data != 0) { retval->parent=data->currentGroup; retval->currentGroup=data->item; retval->item=0; } return retval; } syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) { Opie::XMLElement *e = m_root->firstChild()->firstChild(); while (e) { kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; if (e->tagName().compare(mainGroupName)==0 ) { Opie::XMLElement *e1=e->firstChild(); while (e1) { kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; if (e1->tagName()==Config) { syntaxContextData *data=new ( syntaxContextData); data->currentGroup=0; data->parent=0; data->item=e1; return data; } e1=e1->nextChild(); } kdDebug(13010) << "WARNING :returning null 3"<< endl; return 0; } e=e->nextChild(); } kdDebug(13010) << "WARNING :returning null 4" << endl; return 0; } syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, const QString &group) { Opie::XMLElement *e=m_root->firstChild()->firstChild(); while (e) { kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; if (e->tagName().compare(mainGroupName)==0 ) { Opie::XMLElement *e1=e->firstChild(); while (e1) { kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; if (e1->tagName()==group+"s") { syntaxContextData *data=new ( syntaxContextData); data->parent=e1; data->currentGroup=0; data->item=0; return data; } e1=e1->nextChild(); } kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl; return 0; } e=e->nextChild(); } kdDebug(13010) << "WARNING : getGroupInfo returning null :2" << endl; return 0; } QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList) { Opie::XMLElement *e = m_root->firstChild(); if (clearList) m_data.clear(); for(e=e->firstChild(); e; e=e->nextChild()) { if (e->tagName()==mainGroup) { for (Opie::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) { if (e1->tagName()!="list") continue; if (e1->attribute("name")==type) { for (Opie::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) { qDebug("FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value()); m_data+=e2->firstChild()->value().stripWhiteSpace(); } break; } } break; } } return m_data; } diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro index 5cb0b14..b282059 100644 --- a/noncore/apps/tinykate/libkate/libkate.pro +++ b/noncore/apps/tinykate/libkate/libkate.pro @@ -1,86 +1,91 @@ -TEMPLATE = lib -CONFIG = qt warn_on release -HEADERS = microkde/kapplication.h \ - kateconfig.h \ +TEMPLATE = lib +CONFIG = qt warn_on release +HEADERS = microkde/kapplication.h \ + kateconfig.h \ microkde/kdebug.h \ microkde/kdialog.h \ microkde/kdialogbase.h \ microkde/kfiledialog.h \ microkde/kglobal.h \ microkde/kiconloader.h \ microkde/klineedit.h \ microkde/klocale.h \ microkde/kmessagebox.h \ microkde/kprinter.h \ microkde/krestrictedline.h \ microkde/kseparator.h \ microkde/kstandarddirs.h \ microkde/ktempfile.h \ microkde/kunload.h \ microkde/kurlrequester.h \ microkde/kfontdialog.h \ microkde/krun.h \ microkde/knumvalidator.h \ microkde/kstaticdeleter.h \ microkde/klistview.h \ microkde/kglobalsettings.h \ - microkde/kcolorbtn.h \ - qt3back/qregexp3.h \ - microkde/ksharedptr.h \ - document/katebuffer.h document/katedialogs.h \ - document/katetextline.h \ - document/katecmd.h \ - document/katehighlight.h \ - document/katecmds.h document/katedocument.h \ - document/katesyntaxdocument.h \ - view/kateundohistory.h \ - view/kateview.h \ - view/kateviewdialog.h \ - interfaces/view.h \ - interfaces/document.h \ - ktexteditor/ktexteditor.h + microkde/kcolorbtn.h \ + \ + \ + qt3back/qregexp3.h \ + microkde/ksharedptr.h \ + document/katebuffer.h document/katedialogs.h \ + document/katetextline.h \ + document/katecmd.h \ + document/katehighlight.h \ + document/katecmds.h document/katedocument.h \ + document/katesyntaxdocument.h \ + view/kateundohistory.h \ + view/kateview.h \ + view/kateviewdialog.h \ + interfaces/view.h \ + interfaces/document.h \ + ktexteditor/ktexteditor.h -SOURCES = microkde/kapplication.cpp \ +SOURCES = microkde/kapplication.cpp \ microkde/kdialogbase.cpp \ - kateconfig.cpp \ + kateconfig.cpp \ microkde/klocale.cpp \ microkde/kmessagebox.cpp \ microkde/kprocess.cpp \ microkde/kstandarddirs.cpp \ microkde/ktempfile.cpp \ microkde/kurlrequester.cpp \ + microkde/kcolordialog.cpp \ microkde/kfontdialog.cpp \ microkde/krun.cpp \ microkde/knumvalidator.cpp \ microkde/kglobal.cpp \ microkde/kglobalsettings.cpp \ - microkde/kcolorbtn.cpp \ - qt3back/qregexp3.cpp \ - ktexteditor/ktexteditor.cpp \ - document/katebuffer.cpp document/katedialogs.cpp \ - document/katehighlight.cpp \ - document/katecmd.cpp \ - document/katesyntaxdocument.cpp document/katecmds.cpp \ - document/katedocument.cpp document/katetextline.cpp \ - view/kateundohistory.cpp \ - view/kateview.cpp \ - view/kateviewdialog.cpp \ - interfaces/interfaces.cpp + microkde/kcolorbtn.cpp \ + \ + \ + qt3back/qregexp3.cpp \ + ktexteditor/ktexteditor.cpp \ + document/katebuffer.cpp document/katedialogs.cpp \ + document/katehighlight.cpp \ + document/katecmd.cpp \ + document/katesyntaxdocument.cpp document/katecmds.cpp \ + document/katedocument.cpp document/katetextline.cpp \ + view/kateundohistory.cpp \ + view/kateview.cpp \ + view/kateviewdialog.cpp \ + interfaces/interfaces.cpp -INTERFACES = -INCLUDEPATH += $(OPIEDIR)/include \ - $(OPIEDIR)/noncore/apps/tinykate/libkate \ - $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ - $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ - $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ - $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ - $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ - $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back -DEPENDPATH += $(OPIEDIR)/include +INTERFACES = +INCLUDEPATH += $(OPIEDIR)/include \ + $(OPIEDIR)/noncore/apps/tinykate/libkate \ + $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ + $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ + $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ + $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ + $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ + $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back +DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -TARGET = tinykate +TARGET = tinykate INCLUDEPATH += $(OPIEDIR)/include DESTDIR = $(OPIEDIR)/lib$(PROJMAK) include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp index 976f1db..5d21f15 100644 --- a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp +++ b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp @@ -1,86 +1,84 @@ /* This file is part of the KDE libraries Copyright (C) 1997 Martin Jones (mjones@kde.org) Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org) 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 <qdialog.h> #include <qpainter.h> #include <qdrawutil.h> #include <qapplication.h> #include <kglobalsettings.h> -//#include "kcolordialog.h" +#include "kcolordialog.h" #include "kcolorbtn.h" -#include <opie/colordialog.h> - KColorButton::KColorButton( QWidget *parent, const char *name ) : QPushButton( parent, name ), dragFlag(false) { // 2000-10-15 (putzer): fixes broken keyboard usage connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); } KColorButton::KColorButton( const QColor &c, QWidget *parent, - const char *name ) + const char *name ) : QPushButton( parent, name ), col(c), dragFlag(false) { // 2000-10-15 (putzer): fixes broken keyboard usage connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); } void KColorButton::setColor( const QColor &c ) { col = c; repaint( false ); } void KColorButton::drawButtonLabel( QPainter *painter ) { QRect r = QApplication::style().buttonRect( 0, 0, width(), height() ); int l = r.x(); int t = r.y(); int w = r.width(); int h = r.height(); int b = 5; QColor lnCol = colorGroup().text(); QColor fillCol = isEnabled() ? col : backgroundColor(); if ( isDown() ) { qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); b++; painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); } else { qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); b++; painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); } } void KColorButton::chooseColor() { - QColor newCol=OColorDialog::getColor( col); - if( newCol != QDialog::Rejected ) + if( KColorDialog::getColor( col) == QDialog::Rejected ) { - col=newCol; + return; + } + repaint( false ); emit changed( col ); - } } diff --git a/noncore/apps/tinykate/libkate/microkde/kcolordialog.h b/noncore/apps/tinykate/libkate/microkde/kcolordialog.h index 1d5c27e..0f831cd 100644 --- a/noncore/apps/tinykate/libkate/microkde/kcolordialog.h +++ b/noncore/apps/tinykate/libkate/microkde/kcolordialog.h @@ -1,16 +1,14 @@ #ifndef MINIKDE_KCOLORDIALOG_H #define MINIKDE_KCOLORDIALOG_H #include <qcolor.h> -#include <opie/colordialog.h> -class KColorDialog : OColorDialog +class KColorDialog { - Q_OBJECT public: enum { Accepted }; static int getColor( const QColor & ); }; #endif diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp index de81d0f..af3b30d 100644 --- a/noncore/apps/tinykate/libkate/view/kateview.cpp +++ b/noncore/apps/tinykate/libkate/view/kateview.cpp @@ -1431,1495 +1431,1493 @@ void KateView::keyPressEvent( QKeyEvent *ev ) shiftWordRight(); else shiftCursorRight(); } else if ( ev->state() & ControlButton ) wordRight(); else cursorRight(); break; case Key_Home: if ( ev->state() & ShiftButton ) { if ( ev->state() & ControlButton ) shiftTop(); else shiftHome(); } else if ( ev->state() & ControlButton ) top(); else home(); break; case Key_End: if ( ev->state() & ShiftButton ) { if ( ev->state() & ControlButton ) shiftBottom(); else shiftEnd(); } else if ( ev->state() & ControlButton ) bottom(); else end(); break; case Key_Up: if ( ev->state() & ShiftButton ) shiftUp(); else if ( ev->state() & ControlButton ) scrollUp(); else up(); break; case Key_Down: if ( ev->state() & ShiftButton ) shiftDown(); else if ( ev->state() & ControlButton ) scrollDown(); else down(); break; case Key_PageUp: if ( ev->state() & ShiftButton ) shiftPageUp(); else if ( ev->state() & ControlButton ) topOfView(); else pageUp(); break; case Key_PageDown: if ( ev->state() & ShiftButton ) shiftPageDown(); else if ( ev->state() & ControlButton ) bottomOfView(); else pageDown(); break; case Key_Return: case Key_Enter: keyReturn(); break; case Key_Delete: if ( ev->state() & ControlButton ) { VConfig c; shiftWordRight(); myViewInternal->getVConfig(c); myDoc->delMarkedText(c); myViewInternal->update(); } else keyDelete(); break; case Key_Backspace: if ( ev->state() & ControlButton ) { VConfig c; shiftWordLeft(); myViewInternal->getVConfig(c); myDoc->delMarkedText(c); myViewInternal->update(); } else backspace(); break; case Key_Insert: toggleInsert(); break; case Key_K: if ( ev->state() & ControlButton ) { killLine(); break; } default: KTextEditor::View::keyPressEvent( ev ); return; break; } ev->accept(); } void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) { setCursorPositionInternal( line, col ); } void KateView::getCursorPosition( int *line, int *col ) { if ( line ) *line = currentLine(); if ( col ) *col = currentColumn(); } int KateView::currentLine() { return myViewInternal->cursor.y; } int KateView::currentColumn() { return myDoc->currentColumn(myViewInternal->cursor); } int KateView::currentCharNum() { return myViewInternal->cursor.x; } void KateView::setCursorPositionInternal(int line, int col) { PointStruc cursor; cursor.x = col; cursor.y = line; myViewInternal->updateCursor(cursor); myViewInternal->center(); // myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); // myDoc->updateViews(myViewInternal); //uptade all other views except this one myDoc->updateViews(); } int KateView::config() { int flags; flags = configFlags; if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; return flags; } void KateView::setConfig(int flags) { bool updateView; // cfSingleSelection is a doc-property myDoc->setSingleSelection(flags & KateView::cfSingleSelection); flags &= ~KateView::cfSingleSelection; if (flags != configFlags) { // update the view if visibility of tabs has changed updateView = (flags ^ configFlags) & KateView::cfShowTabs; configFlags = flags; emit newStatus(); if (updateView) myViewInternal->update(); } } int KateView::tabWidth() { return myDoc->tabChars; } void KateView::setTabWidth(int w) { myDoc->setTabWidth(w); myDoc->updateViews(); } void KateView::setEncoding (QString e) { myDoc->setEncoding (e); myDoc->updateViews(); } int KateView::undoSteps() { return myDoc->undoSteps; } void KateView::setUndoSteps(int s) { myDoc->setUndoSteps(s); } bool KateView::isReadOnly() { return myDoc->readOnly; } bool KateView::isModified() { return myDoc->modified; } void KateView::setReadOnly(bool m) { myDoc->setReadOnly(m); } void KateView::setModified(bool m) { myDoc->setModified(m); } bool KateView::isLastView() { return myDoc->isLastView(1); } KateDocument *KateView::doc() { return myDoc; } int KateView::undoState() { if (isReadOnly()) return 0; else return myDoc->undoState; } int KateView::nextUndoType() { return myDoc->nextUndoType(); } int KateView::nextRedoType() { return myDoc->nextRedoType(); } void KateView::undoTypeList(QValueList<int> &lst) { myDoc->undoTypeList(lst); } void KateView::redoTypeList(QValueList<int> &lst) { myDoc->redoTypeList(lst); } const char * KateView::undoTypeName(int type) { return KateActionGroup::typeName(type); } QColor* KateView::getColors() { return myDoc->colors; } void KateView::applyColors() { myDoc->tagAll(); myDoc->updateViews(); } bool KateView::isOverwriteMode() const { return ( configFlags & KateView::cfOvr ); } void KateView::setOverwriteMode( bool b ) { if ( isOverwriteMode() && !b ) setConfig( configFlags ^ KateView::cfOvr ); else setConfig( configFlags | KateView::cfOvr ); } void KateView::toggleInsert() { setConfig(configFlags ^ KateView::cfOvr); } void KateView::toggleVertical() { setConfig(configFlags ^ KateView::cfVerticalSelect); } int KateView::numLines() { return myDoc->numLines(); } QString KateView::text() { return myDoc->text(); } QString KateView::currentTextLine() { TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); return QString(textLine->getText(), textLine->length()); } QString KateView::textLine(int num) { TextLine::Ptr textLine = myDoc->getTextLine(num); return QString(textLine->getText(), textLine->length()); } QString KateView::currentWord() { return myDoc->getWord(myViewInternal->cursor); } QString KateView::word(int x, int y) { PointStruc cursor; cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); return myDoc->getWord(cursor); } void KateView::setText(const QString &s) { myDoc->setText(s); myDoc->updateViews(); } void KateView::insertText(const QString &s, bool /*mark*/) { VConfig c; myViewInternal->getVConfig(c); myDoc->insert(c, s); myDoc->updateViews(); } bool KateView::hasMarkedText() { return myDoc->hasMarkedText(); } QString KateView::markedText() { return myDoc->markedText(configFlags); } bool KateView::canDiscard() { int query; if (isModified()) { query = KMessageBox::warningYesNoCancel(this, i18n("The current Document has been modified.\nWould you like to save it?")); switch (query) { case KMessageBox::Yes: //yes if (save() == CANCEL) return false; if (isModified()) { query = KMessageBox::warningContinueCancel(this, i18n("Could not save the document.\nDiscard it and continue?"), QString::null, i18n("&Discard")); if (query == KMessageBox::Cancel) return false; } break; case KMessageBox::Cancel: //cancel return false; } } return true; } void KateView::flush() { if (canDiscard()) myDoc->flush(); } KateView::fileResult KateView::save() { int query = KMessageBox::Yes; if (isModified()) { return saveAs(); } return OK; } KateView::fileResult KateView::saveAs() { return OK; } void KateView::doCursorCommand(int cmdNum) { VConfig c; myViewInternal->getVConfig(c); if (cmdNum & selectFlag) c.flags |= KateView::cfMark; if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; cmdNum &= ~(selectFlag | multiSelectFlag); myViewInternal->doCursorCommand(c, cmdNum); myDoc->updateViews(); } void KateView::doEditCommand(int cmdNum) { VConfig c; myViewInternal->getVConfig(c); myViewInternal->doEditCommand(c, cmdNum); myDoc->updateViews(); } void KateView::undoMultiple(int count) { if (isReadOnly()) return; VConfig c; myViewInternal->getVConfig(c); myDoc->undo(c, count); myDoc->updateViews(); } void KateView::redoMultiple(int count) { if (isReadOnly()) return; VConfig c; myViewInternal->getVConfig(c); myDoc->redo(c, count); myDoc->updateViews(); } void KateView::undoHistory() { UndoHistory *undoH; undoH = new UndoHistory(this, this, "UndoHistory", true); undoH->setCaption(i18n("Undo/Redo History")); connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); undoH->exec(); delete undoH; } static void kwview_addToStrList(QStringList &list, const QString &str) { if (list.count() > 0) { if (list.first() == str) return; QStringList::Iterator it; it = list.find(str); if (*it != 0L) list.remove(it); if (list.count() >= 16) list.remove(list.fromLast()); } list.prepend(str); } void KateView::find() { SearchDialog *searchDialog; if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, searchFlags & ~KateView::sfReplace); // If the user has marked some text we use that otherwise // use the word under the cursor. QString str; if (myDoc->hasMarkedText()) str = markedText(); if (str.isEmpty()) str = currentWord(); if (!str.isEmpty()) { str.replace(QRegExp("^\n"), ""); int pos=str.find("\n"); if (pos>-1) str=str.left(pos); searchDialog->setSearchText( str ); } myViewInternal->focusOutEvent(0L);// QT bug ? if (searchDialog->exec() == QDialog::Accepted) { kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); initSearch(s, searchFlags); findAgain(s); } delete searchDialog; } void KateView::replace() { SearchDialog *searchDialog; if (isReadOnly()) return; if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, searchFlags | KateView::sfReplace); // If the user has marked some text we use that otherwise // use the word under the cursor. QString str; if (myDoc->hasMarkedText()) str = markedText(); if (str.isEmpty()) str = currentWord(); if (!str.isEmpty()) { str.replace(QRegExp("^\n"), ""); int pos=str.find("\n"); if (pos>-1) str=str.left(pos); searchDialog->setSearchText( str ); } myViewInternal->focusOutEvent(0L);// QT bug ? if (searchDialog->exec() == QDialog::Accepted) { // myDoc->recordReset(); kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); searchFlags = searchDialog->getFlags(); initSearch(s, searchFlags); replaceAgain(); } delete searchDialog; } void KateView::gotoLine() { GotoLineDialog *dlg; PointStruc cursor; dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); // dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); if (dlg->exec() == QDialog::Accepted) { // myDoc->recordReset(); cursor.x = 0; cursor.y = dlg->getLine() - 1; myDoc->needPreHighlight(cursor.y); myViewInternal->updateCursor(cursor); myViewInternal->center(); myViewInternal->updateView(KateView::ufUpdateOnScroll); myDoc->updateViews(this); //uptade all other views except this one } delete dlg; } void KateView::initSearch(SConfig &s, int flags) { s.flags = flags; s.setPattern(myDoc->searchForList.first()); if (!(s.flags & KateView::sfFromBeginning)) { // If we are continuing a backward search, make sure we do not get stuck // at an existing match. s.cursor = myViewInternal->cursor; TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); QString const txt(textLine->getText(),textLine->length()); const QString searchFor= myDoc->searchForList.first(); int pos = s.cursor.x-searchFor.length()-1; if ( pos < 0 ) pos = 0; pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); if ( s.flags & KateView::sfBackward ) { if ( pos <= s.cursor.x ) s.cursor.x= pos-1; } else if ( pos == s.cursor.x ) s.cursor.x++; } else { if (!(s.flags & KateView::sfBackward)) { s.cursor.x = 0; s.cursor.y = 0; } else { s.cursor.x = -1; s.cursor.y = myDoc->lastLine(); } s.flags |= KateView::sfFinished; } if (!(s.flags & KateView::sfBackward)) { if (!(s.cursor.x || s.cursor.y)) s.flags |= KateView::sfFinished; } s.startCursor = s.cursor; } void KateView::continueSearch(SConfig &s) { if (!(s.flags & KateView::sfBackward)) { s.cursor.x = 0; s.cursor.y = 0; } else { s.cursor.x = -1; s.cursor.y = myDoc->lastLine(); } s.flags |= KateView::sfFinished; s.flags &= ~KateView::sfAgain; } void KateView::findAgain(SConfig &s) { int query; PointStruc cursor; QString str; QString searchFor = myDoc->searchForList.first(); if( searchFor.isEmpty() ) { find(); return; } do { query = KMessageBox::Cancel; if (myDoc->doSearch(s,searchFor)) { cursor = s.cursor; if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; myViewInternal->updateCursor(s.cursor); //does deselectAll() exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); } else { if (!(s.flags & KateView::sfFinished)) { // ask for continue if (!(s.flags & KateView::sfBackward)) { // forward search str = i18n("End of document reached.\n" "Continue from the beginning?"); query = KMessageBox::warningContinueCancel(this, str, i18n("Find"), i18n("Continue")); } else { // backward search str = i18n("Beginning of document reached.\n" "Continue from the end?"); query = KMessageBox::warningContinueCancel(this, str, i18n("Find"), i18n("Continue")); } continueSearch(s); } else { // wrapped KMessageBox::sorry(this, i18n("Search string '%1' not found!").arg(searchFor), i18n("Find")); } } } while (query == KMessageBox::Continue); } void KateView::replaceAgain() { if (isReadOnly()) return; replaces = 0; if (s.flags & KateView::sfPrompt) { doReplaceAction(-1); } else { doReplaceAction(KateView::srAll); } } void KateView::doReplaceAction(int result, bool found) { int rlen; PointStruc cursor; bool started; QString searchFor = myDoc->searchForList.first(); QString replaceWith = myDoc->replaceWithList.first(); rlen = replaceWith.length(); switch (result) { case KateView::srYes: //yes myDoc->recordStart(this, s.cursor, configFlags, KateActionGroup::ugReplace, true); myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); replaces++; if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) s.startCursor.x += rlen - s.matchedLength; if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); break; case KateView::srNo: //no if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; break; case KateView::srAll: //replace all deleteReplacePrompt(); do { started = false; while (found || myDoc->doSearch(s,searchFor)) { if (!started) { found = false; myDoc->recordStart(this, s.cursor, configFlags, KateActionGroup::ugReplace); started = true; } myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); replaces++; if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) s.startCursor.x += rlen - s.matchedLength; if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; } if (started) myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); } while (!askReplaceEnd()); return; case KateView::srCancel: //cancel deleteReplacePrompt(); return; default: replacePrompt = 0L; } do { if (myDoc->doSearch(s,searchFor)) { //text found: highlight it, show replace prompt if needed and exit cursor = s.cursor; if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; myViewInternal->updateCursor(cursor); //does deselectAll() exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); if (replacePrompt == 0L) { replacePrompt = new ReplacePrompt(this); myDoc->setPseudoModal(replacePrompt);//disable(); connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); replacePrompt->show(); //this is not modal } return; //exit if text found } //nothing found: repeat until user cancels "repeat from beginning" dialog } while (!askReplaceEnd()); deleteReplacePrompt(); } void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { int x1, x2, y1, y2, xPos, yPos; VConfig c; myViewInternal->getVConfig(c); myDoc->selectLength(cursor,slen,c.flags); TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); x1 = myDoc->textWidth(textLine,cursor.x) -10; x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; y1 = myDoc->fontHeight*cursor.y -10; y2 = y1 + myDoc->fontHeight +30; xPos = myViewInternal->xPos; yPos = myViewInternal->yPos; if (x1 < 0) x1 = 0; if (replace) y2 += 90; if (x1 < xPos || x2 > xPos + myViewInternal->width()) { xPos = x2 - myViewInternal->width(); } if (y1 < yPos || y2 > yPos + myViewInternal->height()) { xPos = x2 - myViewInternal->width(); yPos = myDoc->fontHeight*cursor.y - height()/3; } myViewInternal->setPos(xPos, yPos); myViewInternal->updateView(flags);// | ufPos,xPos,yPos); myDoc->updateViews(this); } void KateView::deleteReplacePrompt() { myDoc->setPseudoModal(0L); } bool KateView::askReplaceEnd() { QString str; int query; myDoc->updateViews(); if (s.flags & KateView::sfFinished) { // replace finished str = i18n("%1 replacement(s) made").arg(replaces); KMessageBox::information(this, str, i18n("Replace")); return true; } // ask for continue if (!(s.flags & KateView::sfBackward)) { // forward search str = i18n("%1 replacement(s) made.\n" "End of document reached.\n" "Continue from the beginning?").arg(replaces); - query = KMessageBox::questionYesNo(this, str, i18n("Continue"), i18n("Stop")); + query = KMessageBox::questionYesNo(this, str, i18n("Replace"), + i18n("Continue"), i18n("Stop")); } else { // backward search str = i18n("%1 replacement(s) made.\n" "Beginning of document reached.\n" "Continue from the end?").arg(replaces); - query = KMessageBox::questionYesNo(this, str, i18n("Continue"), i18n("Stop")); + query = KMessageBox::questionYesNo(this, str, i18n("Replace"), + i18n("Continue"), i18n("Stop")); } replaces = 0; continueSearch(s); return (query == KMessageBox::No); } void KateView::replaceSlot() { doReplaceAction(replacePrompt->result(),true); } void KateView::installPopup(QPopupMenu *rmb_Menu) { rmbMenu = rmb_Menu; } void KateView::readConfig() { KateConfig *config = KGlobal::config(); config->setGroup("Kate View"); searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; // config->sync(); } void KateView::writeConfig() { KateConfig *config = KGlobal::config(); config->setGroup("Kate View"); config->writeEntry("SearchFlags",searchFlags); config->writeEntry("ConfigFlags",configFlags); // config->sync(); } void KateView::readSessionConfig(KateConfig *config) { PointStruc cursor; myViewInternal->xPos = config->readNumEntry("XPos"); myViewInternal->yPos = config->readNumEntry("YPos"); cursor.x = config->readNumEntry("CursorX"); cursor.y = config->readNumEntry("CursorY"); myViewInternal->updateCursor(cursor); myIconBorder = config->readBoolEntry("IconBorder on"); setIconBorder(myIconBorder); } void KateView::writeSessionConfig(KateConfig *config) { config->writeEntry("XPos",myViewInternal->xPos); config->writeEntry("YPos",myViewInternal->yPos); config->writeEntry("CursorX",myViewInternal->cursor.x); config->writeEntry("CursorY",myViewInternal->cursor.y); config->writeEntry("IconBorder on", myIconBorder); } void KateView::configDialog() { #warning fixme - QScrollView *pScroll; #if 1 KDialogBase *kd = new KDialogBase(KDialogBase::IconList, i18n("Configure Editor"), KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help , KDialogBase::Ok, this, "tabdialog"); // color options QFrame *page=kd->addPage(i18n("Colors")); (new QVBoxLayout(page))->setAutoAdd(true); ColorConfig *colorConfig = new ColorConfig(page); QColor* colors = getColors(); colorConfig->setColors(colors); page = kd->addPage(i18n("Fonts")); (new QVBoxLayout(page))->setAutoAdd(true); FontConfig *fontConfig = new FontConfig(page); fontConfig->setFont (myDoc->getFont()); // indent options page=kd->addPage(i18n("Indent")); (new QVBoxLayout(page))->setAutoAdd(true); IndentConfigTab *indentConfig = new IndentConfigTab(page, this); // select options page=kd->addPage(i18n("Select")); (new QVBoxLayout(page))->setAutoAdd(true); SelectConfigTab *selectConfig = new SelectConfigTab(page, this); // edit options page=kd->addPage(i18n("Edit")); (new QVBoxLayout(page))->setAutoAdd(true); - pScroll=new QScrollView(page); + EditConfigTab *editConfig = new EditConfigTab(page, this); - pScroll->addChild(editConfig); HighlightDialogPage *hlPage; HlManager *hlManager; HlDataList hlDataList; ItemStyleList defaultStyleList; hlManager = HlManager::self(); defaultStyleList.setAutoDelete(true); hlManager->getDefaults(defaultStyleList); hlDataList.setAutoDelete(true); //this gets the data from the KateConfig object hlManager->getHlDataList(hlDataList); page=kd->addPage(i18n("Highlighting")); (new QVBoxLayout(page))->setAutoAdd(true); - pScroll=new QScrollView(page); - hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, pScroll->viewport()); - pScroll->addChild(hlPage); - kd->showMaximized(); + hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); + kd->showMaximized(); if (kd->exec()) { // color options colorConfig->getColors(colors); myDoc->setFont (fontConfig->getFont()); applyColors(); // indent options indentConfig->getData(this); // select options selectConfig->getData(this); // edit options editConfig->getData(this); // spell checker hlManager->setHlDataList(hlDataList); hlManager->setDefaults(defaultStyleList); hlPage->saveData(); } // delete kd; #endif } int KateView::getHl() { return myDoc->highlightNum(); } void KateView::setDontChangeHlOnSave() { myDoc->setDontChangeHlOnSave(); } void KateView::setHl(int n) { myDoc->setHighlight(n); myDoc->setDontChangeHlOnSave(); myDoc->updateViews(); } int KateView::getEol() { return myDoc->eolMode; } void KateView::setEol(int eol) { if (isReadOnly()) return; myDoc->eolMode = eol; myDoc->setModified(true); } void KateView::paintEvent(QPaintEvent *e) { int x, y; QRect updateR = e->rect(); // update rectangle // debug("Update rect = ( %i, %i, %i, %i )", // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); int ux1 = updateR.x(); int uy1 = updateR.y(); int ux2 = ux1 + updateR.width(); int uy2 = uy1 + updateR.height(); QPainter paint; paint.begin(this); QColorGroup g = colorGroup(); x = width(); y = height(); paint.setPen(g.dark()); if (uy1 <= 0) paint.drawLine(0,0,x-2,0); if (ux1 <= 0) paint.drawLine(0,1,0,y-2); paint.setPen(black); if (uy1 <= 1) paint.drawLine(1,1,x-3,1); if (ux1 <= 1) paint.drawLine(1,2,1,y-3); paint.setPen(g.midlight()); if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); paint.setPen(g.light()); if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); x -= 2 + 16; y -= 2 + 16; if (ux2 > x && uy2 > y) { paint.fillRect(x,y,16,16,g.background()); } paint.end(); } void KateView::resizeEvent(QResizeEvent *) { // debug("Resize %d, %d",e->size().width(),e->size().height()); //myViewInternal->resize(width() -20, height() -20); myViewInternal->tagAll(); myViewInternal->updateView(0/*ufNoScroll*/); } // Applies a new pattern to the search context. void SConfig::setPattern(QString &newPattern) { bool regExp = (flags & KateView::sfRegularExpression); m_pattern = newPattern; if (regExp) { m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); m_regExp.setPattern(m_pattern); } } // Applies the search context to the given string, and returns whether a match was found. If one is, // the length of the string matched is also returned. int SConfig::search(QString &text, int index) { bool regExp = (flags & KateView::sfRegularExpression); bool caseSensitive = (flags & KateView::sfCaseSensitive); if (flags & KateView::sfBackward) { if (regExp) { index = text.findRev(m_regExp, index); } else { index = text.findRev(m_pattern, index, caseSensitive); } } else { if (regExp) { index = text.find(m_regExp, index); } else { index = text.find(m_pattern, index, caseSensitive); } } // Work out the matched length. if (index != -1) { if (regExp) { m_regExp.match(text, index, &matchedLength, false); } else { matchedLength = m_pattern.length(); } } return index; } void KateView::setActive (bool b) { active = b; } bool KateView::isActive () { return active; } void KateView::setFocus () { QWidget::setFocus (); emit gotFocus (this); } bool KateView::eventFilter (QObject *object, QEvent *event) { if ( (event->type() == QEvent::FocusIn) ) emit gotFocus (this); if ( (event->type() == QEvent::KeyPress) ) { QKeyEvent * ke=(QKeyEvent *)event; if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) { myViewInternal->keyPressEvent(ke); return true; } } return QWidget::eventFilter (object, event); } void KateView::findAgain (bool back) { bool b= (searchFlags & sfBackward) > 0; initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); if (s.flags & sfReplace) replaceAgain(); else KateView::findAgain(s); } void KateView::slotEditCommand () { #warning fixme /* bool ok; QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); if (ok) myDoc->cmd()->execCmd (cmd, this);*/ } void KateView::setIconBorder (bool enable) { myIconBorder = enable; if (myIconBorder) { myViewInternal->move(myViewInternal->iconBorderWidth+2, 2); myViewInternal->leftBorder->show(); } else { myViewInternal->leftBorder->hide(); myViewInternal->move(2, 2); } } void KateView::toggleIconBorder () { setIconBorder (!myIconBorder); } void KateView::gotoMark (Kate::Mark *mark) { PointStruc cursor; cursor.x = 0; cursor.y = mark->line; myDoc->needPreHighlight(cursor.y); myViewInternal->updateCursor(cursor); myViewInternal->center(); myViewInternal->updateView(KateView::ufUpdateOnScroll); myDoc->updateViews(this); } void KateView::toggleBookmark () { TextLine::Ptr line = myDoc->getTextLine (currentLine()); if (line->mark()&KateDocument::Bookmark) line->delMark(KateDocument::Bookmark); else line->addMark(KateDocument::Bookmark); myDoc->tagLines (currentLine(), currentLine()); myDoc->updateViews(); } void KateView::clearBookmarks() { QList<Kate::Mark> list = myDoc->marks(); for (int i=0; (uint) i < list.count(); i++) { if (list.at(i)->type&KateDocument::Bookmark) { myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark); myDoc->tagLines(list.at(i)->line, list.at(i)->line); } } myDoc->updateViews(); } void KateView::bookmarkMenuAboutToShow() { #warning fixme #if 0 bookmarkMenu->popupMenu()->clear (); bookmarkToggle->plug (bookmarkMenu->popupMenu()); bookmarkClear->plug (bookmarkMenu->popupMenu()); bookmarkMenu->popupMenu()->insertSeparator (); list = myDoc->marks(); for (int i=0; (uint) i < list.count(); i++) { if (list.at(i)->type&KateDocument::Bookmark) { QString bText = textLine(list.at(i)->line); bText.truncate(32); bText.append ("..."); bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i ); } } #endif } void KateView::gotoBookmark (int n) { gotoMark (list.at(n)); } int KateView::getHlCount () { return HlManager::self()->highlights(); } QString KateView::getHlName (int z) { return HlManager::self()->hlName(z); } QString KateView::getHlSection (int z) { return HlManager::self()->hlSection (z); } void KateView::slotIncFontSizes () { QFont font = myDoc->getFont(); font.setPointSize (font.pointSize()+2); myDoc->setFont (font); } void KateView::slotDecFontSizes () { QFont font = myDoc->getFont(); font.setPointSize (font.pointSize()-2); myDoc->setFont (font); } const char*bookmark_xpm[]={ "12 16 4 1", "b c #808080", "a c #000080", "# c #0000ff", ". c None", "............", "............", "........###.", ".......#...a", "......#.##.a", ".....#.#..aa", "....#.#...a.", "...#.#.a.a..", "..#.#.a.a...", ".#.#.a.a....", "#.#.a.a.....", "#.#a.a...bbb", "#...a..bbb..", ".aaa.bbb....", "............", "............"}; const char* breakpoint_xpm[]={ "11 16 6 1", "c c #c6c6c6", ". c None", "# c #000000", "d c #840000", "a c #ffffff", "b c #ff0000", "...........", "...........", "...#####...", "..#aaaaa#..", ".#abbbbbb#.", "#abbbbbbbb#", "#abcacacbd#", "#abbbbbbbb#", "#abcacacbd#", "#abbbbbbbb#", ".#bbbbbbb#.", "..#bdbdb#..", "...#####...", "...........", "...........", "..........."}; const char*breakpoint_bl_xpm[]={ "11 16 7 1", "a c #c0c0ff", "# c #000000", "c c #0000c0", "e c #0000ff", "b c #dcdcdc", "d c #ffffff", ". c None", "...........", "...........", "...#####...", "..#ababa#..", ".#bcccccc#.", "#acccccccc#", "#bcadadace#", "#acccccccc#", "#bcadadace#", "#acccccccc#", ".#ccccccc#.", "..#cecec#..", "...#####...", "...........", "...........", "..........."}; const char*breakpoint_gr_xpm[]={ "11 16 6 1", "c c #c6c6c6", "d c #2c2c2c", "# c #000000", ". c None", "a c #ffffff", "b c #555555", "...........", "...........", "...#####...", "..#aaaaa#..", ".#abbbbbb#.", "#abbbbbbbb#", "#abcacacbd#", "#abbbbbbbb#", "#abcacacbd#", "#abbbbbbbb#", ".#bbbbbbb#.", "..#bdbdb#..", "...#####...", "...........", "...........", "..........."}; const char*ddd_xpm[]={ "11 16 4 1", "a c #00ff00", "b c #000000", ". c None", "# c #00c000", "...........", "...........", "...........", "#a.........", "#aaa.......", "#aaaaa.....", "#aaaaaaa...", "#aaaaaaaaa.", "#aaaaaaa#b.", "#aaaaa#b...", "#aaa#b.....", "#a#b.......", "#b.........", "...........", "...........", "..........."}; KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) : QWidget(view), myView(view), myInternalView(internalView) { lmbSetsBreakpoints = true; } KateIconBorder::~KateIconBorder() { } void KateIconBorder::paintLine(int i) { if (!myView->myIconBorder) return; QPainter p(this); int fontHeight = myView->doc()->fontHeight; int y = i*fontHeight - myInternalView->yPos; p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); p.setPen(white); p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); p.setPen(QColor(colorGroup().background()).dark()); p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); TextLine *line = myView->doc()->getTextLine(i); if (!line) return; if (line->mark()&KateDocument::Bookmark) p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* if (line && (line->breakpointId() != -1)) { if (!line->breakpointEnabled()) p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); else if (line->breakpointPending()) p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); else p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); } if (line->isExecutionPoint()) p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ } void KateIconBorder::paintEvent(QPaintEvent* e) { if (!myView->myIconBorder) return; int lineStart = 0; int lineEnd = 0; QRect updateR = e->rect(); KateDocument *doc = myView->doc(); int h = doc->fontHeight; int yPos = myInternalView->yPos; if (h) { lineStart = (yPos + updateR.y()) / h; lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); } for(int i = lineStart; i <= lineEnd; ++i) paintLine(i); } void KateIconBorder::mousePressEvent(QMouseEvent* e) { myInternalView->placeCursor( 0, e->y(), 0 ); KateDocument *doc = myView->doc(); int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; TextLine *line = doc->getTextLine(cursorOnLine); switch (e->button()) { case LeftButton: if (!line) break; else { if (line->mark()&KateDocument::Bookmark) line->delMark (KateDocument::Bookmark); else line->addMark (KateDocument::Bookmark); doc->tagLines(cursorOnLine, cursorOnLine); doc->updateViews(); } break; /* case RightButton: { if (!line) break; KPopupMenu popup; popup.setCheckable(true); popup.insertTitle(i18n("Breakpoints/Bookmarks")); int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); popup.insertSeparator(); int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); popup.insertSeparator(); popup.insertSeparator(); int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); if (line->breakpointId() == -1) { popup.setItemEnabled(idEditBreakpoint, false); popup.setItemEnabled(idEnableBreakpoint, false); popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); } int res = popup.exec(mapToGlobal(e->pos())); if (res == idToggleBookmark) { line->toggleBookmark(); doc->tagLines(cursorOnLine, cursorOnLine); doc->updateViews(); } else if (res == idToggleBreakpoint) emit myView->toggledBreakpoint(cursorOnLine); else if (res == idEditBreakpoint) emit myView->editedBreakpoint(cursorOnLine); else if (res == idEnableBreakpoint) emit myView->toggledBreakpointEnabled(cursorOnLine+1); else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) lmbSetsBreakpoints = !lmbSetsBreakpoints; break; } case MidButton: line->toggleBookmark(); doc->tagLines(cursorOnLine, cursorOnLine); doc->updateViews(); break; */ default: break; } } diff --git a/noncore/apps/tinykate/main.cpp b/noncore/apps/tinykate/main.cpp index e92df69..e06668a 100644 --- a/noncore/apps/tinykate/main.cpp +++ b/noncore/apps/tinykate/main.cpp @@ -1,29 +1,28 @@ /*************************************************************************** main.cpp ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #include <qpe/qpeapplication.h> #include <qmainwindow.h> #include "tinykate.h" int main( int argc, char ** argv ) { QPEApplication a( argc, argv ); - TinyKate *m = new TinyKate(); - a.setMainWidget( m ); - m->showMaximized(); + TinyKate m; + a.showMainWidget(&m ); return a.exec(); } diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control b/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control index 76704c1..dd5e24b 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-commondev.control @@ -1,9 +1,9 @@ Package: opie-tinykate-syntax-commondev Files: share/tinykate/syntax/c.xml share/tinykate/syntax/cpp.xml share/tinykate/syntax/gnuassembler.xml share/tinykate/syntax/kbasic.xml share/tinykate/syntax/pascal.xml share/tinykate/syntax/perl.xml share/tinykate/syntax/php.xml share/tinykate/syntax/python.xml share/tinykate/syntax/ruby.xml share/tinykate/syntax/sql.xml share/tinykate/syntax/tcl.xml share/tinykate/syntax/xml.xml share/tinykate/syntax/xmldebug.xml share/tinykate/syntax/java.xml Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, opie-tinykate Description: Syntax Highlighting Patterns for for common programming languages for TinyKate +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control b/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control index 9f60156..c47acc0 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-documentation.control @@ -1,9 +1,9 @@ Package: opie-tinykate-syntax-documentation Files: share/tinykate/syntax/latex.xml share/tinykate/syntax/postscript.xml share/tinykate/syntax/sgml.xml Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, opie-tinykate Description: Syntax Highlighting Patterns for document oriented languages for TinyKate +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-misc.control b/noncore/apps/tinykate/opie-tinykate-syntax-misc.control index 4e0f529..0e80518 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-misc.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-misc.control @@ -1,9 +1,9 @@ Package: opie-tinykate-syntax-misc Files: share/tinykate/syntax/idconsole.xml share/tinykate/syntax/matlab.xml share/tinykate/syntax/verilog.xml share/tinykate/syntax/vhdl.xml Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, opie-tinykate Description: Syntax Highlighting Patterns for misc languages for TinyKate +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control b/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control index 3c8f61a..3f7ea0d 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control @@ -1,9 +1,9 @@ Package: opie-tinykate-syntax-miscdev Files: share/tinykate/syntax/ada.xml share/tinykate/syntax/eiffel.xml share/tinykate/syntax/ferite.xml share/tinykate/syntax/fortran.xml share/tinykate/syntax/haskell.xml share/tinykate/syntax/literate-haskell.xml share/tinykate/syntax/objectivec.xml share/tinykate/syntax/sather.xml share/tinykate/syntax/scheme.xml Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, opie-tinykate Description: Syntax Highlighting Patterns for for uncommon programming languages for TinyKate +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-unix.control b/noncore/apps/tinykate/opie-tinykate-syntax-unix.control index 36e88b5..ea4e026 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-unix.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-unix.control @@ -1,9 +1,9 @@ Package: opie-tinykate-syntax-unix Files: share/tinykate/syntax/cs.xml share/tinykate/syntax/bash.xml share/tinykate/syntax/changelog.xml share/tinykate/syntax/desktop.xml share/tinykate/syntax/diff.xml share/tinykate/syntax/mab.xml share/tinykate/syntax/makefile.xml share/tinykate/syntax/rpmspec.xml share/tinykate/syntax/sml.xml share/tinykate/syntax/winehq.xml Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, opie-tinykate Description: Syntax Highlighting Patterns for UNIX/Linux specific files for TinyKate +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/opie-tinykate-syntax-web.control b/noncore/apps/tinykate/opie-tinykate-syntax-web.control index 46fe64a..8f9c71a 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax-web.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax-web.control @@ -1,9 +1,9 @@ Package: opie-tinykate-syntax-web Files: share/tinykate/syntax/css.xml share/tinykate/syntax/html.xml share/tinykate/syntax/javascript.xml Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, opie-tinykate Description: Syntax Highlighting Patterns for for common programming languages for TinyKate +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/opie-tinykate-syntax.control b/noncore/apps/tinykate/opie-tinykate-syntax.control index c4156fc..712933c 100644 --- a/noncore/apps/tinykate/opie-tinykate-syntax.control +++ b/noncore/apps/tinykate/opie-tinykate-syntax.control @@ -1,9 +1,9 @@ Package: opie-tinykate-syntax Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, opie-tinykate, opie-tinykate-syntax-commondev, opie-tinykate-syntax-documentation, opie-tinykate-syntax-misc, opie-tinykate-syntax-miscdev, opie-tinykate-syntax-unix, opie-tinykate-syntax-web Description: Syntax Highlighting Patterns virtual package, which installs all available syntax patterns. Files: +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/opie-tinykate.control b/noncore/apps/tinykate/opie-tinykate.control index 95dd7e0..731375c 100644 --- a/noncore/apps/tinykate/opie-tinykate.control +++ b/noncore/apps/tinykate/opie-tinykate.control @@ -1,9 +1,9 @@ Package: opie-tinykate Files: bin/tinykate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 Priority: optional Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal Description: Kate for opie +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index dda8405..f470645 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp @@ -1,321 +1,283 @@ /*************************************************************************** tinykate.cpp Tiny KATE mainwindow ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * - * This program is free software; you can redistribute it and/or modify * + * 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 <qwidget.h> #include <qaction.h> #include <qlayout.h> -#include <qpe/qpetoolbar.h> -#include <qpe/qpemenubar.h> +#include <qtoolbutton.h> +#include <qmenubar.h> #include <qpe/resource.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <opie/ofiledialog.h> -#include "cgotoline.h" - #include "tinykate.h" #include <katedocument.h> #include <katehighlight.h> #include <kateview.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("TinyKATE : line 1 col 1"); + setCaption(tr("TinyKATE")); KGlobal::setAppName("TinyKATE"); - curLine=curCol=1; - - setToolBarsMovable(FALSE); - - QPEToolBar *bar = new QPEToolBar( this ); - bar->setHorizontalStretchable( TRUE ); - QPEMenuBar *mb = new QPEMenuBar( bar ); - mb->setMargin( 0 ); + QMenuBar *mb = new QMenuBar( this ); + mb->setMargin( 0 ); tabwidget=new OTabWidget(this); setCentralWidget(tabwidget); connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); //FILE ACTIONS QPopupMenu *popup = new QPopupMenu( this ); // Action for creating a new document - QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, CTRL+Key_N, this, 0 ); + 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, CTRL+Key_O, this, 0 ); + 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, CTRL+Key_S, this, 0 ); + 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 = 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( "close" ), QString::null, CTRL+Key_W, this, 0 ); + 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 QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, CTRL+Key_X, this, 0 ); - editCut->addTo( bar ); + editCut = new QToolButton( 0 ); + editCut->setAutoRaise( true ); + editCut->setIconSet( Resource::loadPixmap( "cut" ) ); // Action for Copying text - editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, CTRL+Key_C, this, 0 ); - editCopy->addTo( bar ); + editCopy = new QToolButton( 0 ); + editCopy->setAutoRaise( true ); + editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); // Action for pasting text - editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, CTRL+Key_V, this, 0 ); - editPaste->addTo( bar ); - + editPaste = new QToolButton( 0 ); + editPaste->setAutoRaise( true ); + editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); // Action for finding / replacing text - editFindReplace = new QAction( tr( "Replace" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_R, this, 0 ); - editFind = new QAction( tr( "Find" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_F, this, 0 ); - editFind->addTo( bar ); + editFindReplace = new QToolButton( 0 ); + editFindReplace->setAutoRaise( true ); + editFindReplace->setIconSet( Resource::loadPixmap("find") ); - // Action for undo - editUndo = new QAction( tr( "Undo" ), Resource::loadPixmap( "undo" ), QString::null, CTRL+Key_Z, this, 0 ); - editUndo->addTo( bar ); + // Action for undo + editUndo = new QToolButton( 0 ); + editUndo->setAutoRaise( true ); + editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); // Action for redo - editRedo = new QAction( tr( "Redo" ), Resource::loadPixmap( "redo" ), QString::null, CTRL+SHIFT+Key_Z, this, 0 ); - editRedo->addTo( bar ); - + editRedo = new QToolButton( 0 ); + editRedo->setAutoRaise( true ); + editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); //VIEW ACITONS popup = new QPopupMenu( this ); - - a = new QAction( tr( "Goto" ), QString::null, CTRL+Key_G, this, 0 ); - a->addTo( popup ); - connect(a, SIGNAL(activated()), this, SLOT(slotGoTo())); - + 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); + mb->insertItem(tr("View"),popup); + popup = new QPopupMenu( this ); + mb->insertItem(tr("Utils"),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); - popup->insertSeparator(); - editFind->addTo(popup); - editFindReplace->addTo(popup); - if( qApp->argc() > 1) open(qApp->argv()[1]); else slotNew(); } TinyKate::~TinyKate( ) { qWarning("TinyKate destructor\n"); - printf("~TinyKate()\n"); + + shutDown=true; + while (currentView!=0) { + slotClose(); + } + if( KGlobal::config() != 0 ) { - printf("~TinyKate(): delete configs...\n"); qWarning("deleting KateConfig object..\n"); delete KGlobal::config(); } } void TinyKate::slotOpen( ) { QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QString::null); if (!filename.isEmpty()) { open(filename); } } void TinyKate::open(const QString & filename) { KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; QFileInfo fi(filename); QString filenamed = fi.fileName(); tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); qDebug(filename); kd->setDocName( filenamed); kd->open( filename ); viewCount++; } -void TinyKate::setDocument(const QString &doc) +void TinyKate::setDocument(const QString& fileref) { - printf("tinykate: setDocument(\"%s\")\n",(const char*)doc); - open(doc); + 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(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); - disconnect(editFind,SIGNAL(activated()),currentView,SLOT(find())); - disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); - disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); + 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())); - disconnect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); } currentView=(KTextEditor::View*)view; - - connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); - connect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); - connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); - connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); - connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); - connect(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); - connect(editFind,SIGNAL(activated()),currentView,SLOT(find())); + + 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())); - connect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); + } void TinyKate::slotNew( ) { KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), "tinykate/tinykate", tr("Unnamed %1").arg(nextUnnamed++)); viewCount++; } void TinyKate::slotClose( ) { if (currentView==0) return; KTextEditor::View *dv=currentView; currentView=0; tabwidget->removePage(dv); delete dv->document(); viewCount--; - if (!viewCount) slotNew(); + if ((!viewCount) && (!shutDown)) slotNew(); } void TinyKate::slotSave() { // feel free to make this how you want if (currentView==0) return; // KateView *kv = (KateView*) currentView; KateDocument *kd = (KateDocument*) currentView->document(); // qDebug("saving file "+kd->docName()); if( kd->docName().isEmpty()) slotSaveAs(); else kd->saveFile(); // kv->save(); // kd->saveFile(); } void TinyKate::slotSaveAs() { if (currentView==0) return; KateDocument *kd = (KateDocument*) currentView->document(); QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null); if (!filename.isEmpty()) { qDebug("saving file "+filename); QFileInfo fi(filename); QString filenamed = fi.fileName(); kd->setDocFile( filename); kd->setDocName( filenamed); kd->saveFile(); // KTextEditor::View *dv = currentView; // tabwidget->changeTab( dv, filenamed); // need to change tab label here } } - -void TinyKate::slotGoTo() -{ - int l,c; - if (currentView==0) return; - - currentView->getCursorPosition(&l,&c); - - CGotoLine g(l); - - if(g.exec()==QDialog::Accepted) - { - currentView->setCursorPosition( g.line(), c ); - } -} - -void TinyKate::slotCursorMoved() -{ - char buf[100]; - int newLine,newCol; - currentView->getCursorPosition(&newLine,&newCol); - newLine++; - newCol++; - if((newLine!=curLine)||(newCol!=curCol)) - { - sprintf(buf,"TinyKATE : line %-6d col %d",newLine,newCol); - setCaption(buf); - curLine=newLine; - curCol=newCol; - } -} diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index 077d5f0..2bf4de6 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h @@ -1,75 +1,64 @@ /*************************************************************************** tinykate.h Tiny KATE mainwindow ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #ifndef __TINYKATE_H__ #define __TINYKATE_H__ #include <qmainwindow.h> #include <opie/otabwidget.h> #include <ktexteditor.h> +class QToolButton; class QAction; class QPopupMenu; -class CGotoLine; class TinyKate : public QMainWindow { Q_OBJECT public: TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); ~TinyKate( ); public slots: void slotNew(); + void setDocument(const QString& fileref); protected slots: void slotOpen(); void slotClose(); void slotCurrentChanged(QWidget *); void slotSave(); void slotSaveAs(); - void slotGoTo(); - void slotCursorMoved(); - void setDocument(const QString &doc); - protected: void open(const QString&); private: QString currentFileName; OTabWidget *tabwidget; KTextEditor::View *currentView; - - QAction *editCopy; - QAction *editCut; - QAction *editPaste; - QAction *editUndo; - QAction *editRedo; - QAction *editFind; - QAction *editFindReplace; - QAction *viewIncFontSizes; - QAction *viewDecFontSizes; - QAction *utilSettings; - + bool shutDown; + + QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; + QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; + QPopupMenu *hlmenu; uint nextUnnamed; uint viewCount; - int curLine,curCol; }; #endif // __TINYKATE_H__ diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro index f7ff451..632bd49 100644 --- a/noncore/apps/tinykate/tinykate.pro +++ b/noncore/apps/tinykate/tinykate.pro @@ -1,22 +1,22 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin -HEADERS = tinykate.h cgotoline.h -SOURCES = tinykate.cpp main.cpp cgotoline.cpp -INTERFACES = cgotobase.ui -INCLUDEPATH += $(OPIEDIR)/include \ - $(OPIEDIR)/noncore/apps/tinykate/libkate \ - $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ +TEMPLATE = app +CONFIG = qt warn_on release +DESTDIR = $(OPIEDIR)/bin +HEADERS = tinykate.h +SOURCES = tinykate.cpp main.cpp +INTERFACES = +INCLUDEPATH += $(OPIEDIR)/include \ + $(OPIEDIR)/noncore/apps/tinykate/libkate \ + $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back -DEPENDPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -ltinykate -lopie -TARGET = tinykate +TARGET = tinykate include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 45a6663..42093cf 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -247,975 +247,987 @@ void MainWindow :: initMainWidget() QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); installedIcon = Resource::loadPixmap( "installed" ); updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); packagesList = new QListView( networkPkgWindow ); packagesList->addColumn( tr( "Packages" ), 225 ); QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), this, SLOT(slotDisplayPackage(QListViewItem *)) ); QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); hbox1->addWidget( l ); hbox1->addWidget( serversList ); vbox->addWidget( packagesList ); downloadEnabled = TRUE; } void MainWindow :: initProgressWidget() { progressWindow = new QWidget( this ); QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); m_status = new QLabel( progressWindow ); m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); layout->addWidget( m_status ); m_progress = new QProgressBar( progressWindow ); layout->addWidget( m_progress ); } void MainWindow :: init() { #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); #endif stack->raiseWidget( progressWindow ); mgr = new DataManager(); connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), this, SLOT( setProgressMessage( const QString & ) ) ); connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); mgr->loadServers(); showUninstalledPkgs = false; showInstalledPkgs = false; showUpgradedPkgs = false; categoryFilterEnabled = false; updateData(); stack->raiseWidget( networkPkgWindow ); } void MainWindow :: setDocument( const QString &doc ) { // Remove path from package QString package = Utils::getPackageNameFromIpkFilename( doc ); // First select local server for ( int i = 0 ; i < serversList->count() ; ++i ) { if ( serversList->text( i ) == LOCAL_IPKGS ) { serversList->setCurrentItem( i ); break; } } serverSelected( 0 ); // Now set the check box of the selected package for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->text().startsWith( package ) ) { item->setOn( true ); break; } } } void MainWindow :: displaySettings() { SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); if ( dlg->showDlg() ) { stack->raiseWidget( progressWindow ); updateData(); stack->raiseWidget( networkPkgWindow ); } delete dlg; } void MainWindow :: closeEvent( QCloseEvent *e ) { // If install dialog is visible, return to main view, otherwise close app QWidget *widget = stack->visibleWidget(); if ( widget != networkPkgWindow && widget != progressWindow ) { if ( widget ) delete widget; stack->raiseWidget( networkPkgWindow ); e->ignore(); } else { e->accept(); } } void MainWindow :: displayFindBar() { findBar->show(); findEdit->setFocus(); } void MainWindow :: displayJumpBar() { jumpBar->show(); } void MainWindow :: repeatFind() { searchForPackage( findEdit->text() ); } void MainWindow :: findPackage( const QString &text ) { actionFindNext->setEnabled( !text.isEmpty() ); searchForPackage( text ); } void MainWindow :: hideFindBar() { findBar->hide(); } void MainWindow :: hideJumpBar() { jumpBar->hide(); } void MainWindow :: filterUninstalledPackages() { showUninstalledPkgs = actionUninstalled->isOn(); if ( showUninstalledPkgs ) { showInstalledPkgs = FALSE; showUpgradedPkgs = FALSE; } serverSelected( -1 ); actionInstalled->setOn( FALSE ); actionUpdated->setOn( FALSE ); } void MainWindow :: filterInstalledPackages() { showInstalledPkgs = actionInstalled->isOn(); if ( showInstalledPkgs ) { showUninstalledPkgs = FALSE; showUpgradedPkgs = FALSE; } serverSelected( -1 ); actionUninstalled->setOn( FALSE ); actionUpdated->setOn( FALSE ); } void MainWindow :: filterUpgradedPackages() { showUpgradedPkgs = actionUpdated->isOn(); if ( showUpgradedPkgs ) { showUninstalledPkgs = FALSE; showInstalledPkgs = FALSE; } serverSelected( -1 ); actionUninstalled->setOn( FALSE ); actionInstalled->setOn( FALSE ); } bool MainWindow :: setFilterCategory() { // Get categories; CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); if ( dlg.exec() == QDialog::Accepted ) { categoryFilter = dlg.getSelectedFilter(); if ( categoryFilter == "" ) return false; categoryFilterEnabled = true; serverSelected( -1 ); actionFilter->setOn( TRUE ); return true; } return false; } void MainWindow :: filterCategory() { if ( !actionFilter->isOn() ) { filterByCategory( FALSE ); } else { actionFilter->setOn( filterByCategory( TRUE ) ); } } bool MainWindow :: filterByCategory( bool val ) { if ( val ) { if ( categoryFilter == "" ) { if ( !setFilterCategory() ) return false; } categoryFilterEnabled = true; serverSelected( -1 ); return true; } else { // Turn off filter categoryFilterEnabled = false; serverSelected( -1 ); return false; } } void MainWindow :: raiseMainWidget() { stack->raiseWidget( networkPkgWindow ); } void MainWindow :: raiseProgressWidget() { stack->raiseWidget( progressWindow ); } void MainWindow :: enableUpgrade( bool enabled ) { actionUpgrade->setEnabled( enabled ); } void MainWindow :: enableDownload( bool enabled ) { if ( enabled ) { actionDownload->setIconSet( iconDownload ); actionDownload->setText( tr( "Download" ) ); actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); } else { actionDownload->setIconSet( iconRemove ); actionDownload->setText( tr( "Remove" ) ); actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); } } void MainWindow :: setProgressSteps( int numsteps ) { m_progress->setTotalSteps( numsteps ); } void MainWindow :: setProgressMessage( const QString &msg ) { m_status->setText( msg ); } void MainWindow :: updateProgress( int progress ) { m_progress->setProgress( progress ); } void MainWindow :: updateData() { m_progress->setTotalSteps( mgr->getServerList().count() ); serversList->clear(); packagesList->clear(); int activeItem = -1; int i = 0; QString serverName; QListIterator<Server> it( mgr->getServerList() ); Server *server; for ( ; it.current(); ++it, ++i ) { server = it.current(); serverName = server->getServerName(); m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); m_progress->setProgress( i ); qApp->processEvents(); if ( !server->isServerActive() ) { i--; continue; } serversList->insertItem( serverName ); if ( serverName == currentlySelectedServer ) activeItem = i; } // set selected server to be active server if ( activeItem != -1 ) serversList->setCurrentItem( activeItem ); serverSelected( 0, FALSE ); } void MainWindow :: serverSelected( int index ) { serverSelected( index, TRUE ); } void MainWindow :: serverSelected( int, bool raiseProgress ) { QPixmap nullIcon( installedIcon.size() ); nullIcon.fill( colorGroup().base() ); // display packages QString serverName = serversList->currentText(); currentlySelectedServer = serverName; Server *s = mgr->getServer( serverName ); QList<Package> &list = s->getPackageList(); QListIterator<Package> it( list ); // Display progress widget while loading list bool doProgress = ( list.count() > 200 ); if ( doProgress ) { if ( raiseProgress ) { stack->raiseWidget( progressWindow ); } m_progress->setTotalSteps( list.count() ); m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); } packagesList->clear(); #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "selectedServer", currentlySelectedServer ); #endif int i = 0; Package *package; for ( ; it.current(); ++it ) { // Update progress after every 100th package (arbitrary value, seems to give good balance) i++; if ( ( i % 100 ) == 0 ) { if ( doProgress ) { m_progress->setProgress( i ); } qApp->processEvents(); } QString text = ""; package = it.current(); // Apply show only uninstalled packages filter if ( showUninstalledPkgs && package->isInstalled() ) continue; // Apply show only installed packages filter if ( showInstalledPkgs && !package->isInstalled() ) continue; // Apply show only new installed packages filter if ( showUpgradedPkgs ) { if ( !package->isInstalled() || !package->getNewVersionAvailable() ) continue; } // Apply the section filter if ( categoryFilterEnabled && categoryFilter != "" ) { if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) continue; } // If the local server, only display installed packages if ( serverName == LOCAL_SERVER && !package->isInstalled() ) continue; QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), QCheckListItem::CheckBox ); if ( package->isInstalled() ) { // If a different version of package is available, show update available icon // Otherwise, show installed icon if ( package->getNewVersionAvailable()) { item->setPixmap( 0, updatedIcon ); } else { item->setPixmap( 0, installedIcon ); } } else { item->setPixmap( 0, nullIcon ); } packagesList->insertItem( item ); } // If the local server or the local ipkgs server disable the download button if ( serverName == LOCAL_SERVER ) { downloadEnabled = TRUE; actionUpgrade->setEnabled( FALSE ); } else if ( serverName == LOCAL_IPKGS ) { downloadEnabled = FALSE; actionUpgrade->setEnabled( FALSE ); } else { downloadEnabled = TRUE; actionUpgrade->setEnabled( TRUE ); } enableDownload( downloadEnabled ); // Display this widget once everything is done if ( doProgress && raiseProgress ) { stack->raiseWidget( networkPkgWindow ); } } void MainWindow :: searchForPackage( const QString &text ) { if ( !text.isEmpty() ) { // look through package list for text startng at current position QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( start == 0 ) start = (QCheckListItem *)packagesList->firstChild(); for ( QCheckListItem *item = start; item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->text().lower().find( text ) != -1 ) { packagesList->ensureItemVisible( item ); packagesList->setCurrentItem( item ); break; } } } } void MainWindow :: updateServer() { QString serverName = serversList->currentText(); // Update the current server // Display dialog // Disable buttons to stop silly people clicking lots on them :) // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); Ipkg *ipkg = new Ipkg; ipkg->setOption( "update" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), tr( "Update lists" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = FALSE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); // delete progDlg; } void MainWindow :: upgradePackages() { // We're gonna do an upgrade of all packages // First warn user that this isn't recommended // TODO - ODevice???? QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 0, this ); warn.adjustSize(); if ( warn.exec() == QMessageBox::Yes ) { // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now run upgrade Ipkg *ipkg = new Ipkg; ipkg->setOption( "upgrade" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), tr ( "Upgrade" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } } void MainWindow :: downloadPackage() { bool doUpdate = true; if ( downloadEnabled ) { // See if any packages are selected bool found = false; if ( serversList->currentText() != LOCAL_SERVER ) { for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 && !found; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) found = true; } } // If user selected some packages then download the and store the locally // otherwise, display dialog asking user what package to download from an http server // and whether to install it if ( found ) downloadSelectedPackages(); else downloadRemotePackage(); } else { doUpdate = false; for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { QString name = item->text(); int pos = name.find( "*" ); name.truncate( pos ); // if (there is a (installed), remove it pos = name.find( "(installed)" ); if ( pos > 0 ) name.truncate( pos - 1 ); Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); QString msgtext; msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); if ( QMessageBox::information( this, tr( "Are you sure?" ), msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) { doUpdate = true; QFile f( p->getFilename() ); f.remove(); } } } } if ( doUpdate ) { reloadData( 0x0 ); } } void MainWindow :: downloadSelectedPackages() { // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Display dialog to user asking where to download the files to bool ok = FALSE; QString dir = ""; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); #endif QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); if ( ok && !text.isEmpty() ) dir = text; // user entered something and pressed ok else return; // user entered nothing or pressed cancel #ifdef QWS // Store download directory in config file cfg.writeEntry( "downloadDir", dir ); #endif // Get starting directory char initDir[PATH_MAX]; getcwd( initDir, PATH_MAX ); // Download each package Ipkg ipkg; connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); ipkg.setOption( "download" ); ipkg.setRuntimeDirectory( dir ); for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { ipkg.setPackage( item->text() ); ipkg.runIpkg( ); } } } void MainWindow :: downloadRemotePackage() { // Display dialog bool ok; QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); if ( !ok || package.isEmpty() ) return; // DownloadRemoteDlgImpl dlg( this, "Install", true ); // if ( dlg.exec() == QDialog::Rejected ) // return; // grab details from dialog // QString package = dlg.getPackageLocation(); InstallData *item = new InstallData(); item->option = "I"; item->packageName = package; QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); workingPackages.append( item ); InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } void MainWindow :: applyChanges() { stickyOption = ""; // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now for each selected item // deal with it QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { InstallData *instdata = dealWithItem( item ); if ( instdata ) workingPackages.append( instdata ); else return; } } if ( workingPackages.count() == 0 ) { // Nothing to do QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } // do the stuff InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } // decide what to do - either remove, upgrade or install // Current rules: // If not installed - install // If installed and different version available - upgrade // If installed and version up to date - remove InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); // Get package Server *s = mgr->getServer( serversList->currentText() ); Package *p = s->getPackage( name ); // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) { InstallData *newitem = new InstallData(); newitem->option = "I"; newitem->packageName = name; return newitem; } else { InstallData *newitem = new InstallData(); newitem->option = "D"; + + // If local file, remove using package name, not filename + if ( p->isPackageStoredLocally() ) + name = item->text(); + if ( !p->isPackageStoredLocally() ) newitem->packageName = p->getInstalledPackageName(); else newitem->packageName = name; if ( p->getInstalledTo() ) { newitem->destination = p->getInstalledTo(); } else { newitem->destination = p->getLocalPackage()->getInstalledTo(); } // Now see if version is newer or not int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); // If the version requested is older and user selected a local ipk file, then reinstall the file if ( p->isPackageStoredLocally() && val == -1 ) val = 0; if ( val == -2 ) { // Error - should handle } else if ( val == -1 ) { // Version available is older - remove only newitem->option = "D"; + + // If local file, remove using package name, not filename + if ( p->isPackageStoredLocally() ) + name = item->text(); } else { QString caption; QString text; QString secondButton; QString secondOption; if ( val == 0 ) { // Version available is the same - option to remove or reinstall caption = tr( "Do you wish to remove or reinstall\n%1?" ); text = tr( "Remove or ReInstall" ); secondButton = tr( "ReInstall" ); secondOption = "R"; // Internal action code, do not translate } else if ( val == 1 ) { // Version available is newer - option to remove or upgrade caption = tr( "Do you wish to remove or upgrade\n%1?" ); text = tr( "Remove or Upgrade" ); secondButton = tr( "Upgrade" ); secondOption = "U"; // Internal action code, do not translate } // Sticky option not implemented yet, but will eventually allow // the user to say something like 'remove all' if ( stickyOption == "" ) { QString msgtext; msgtext = caption.arg( ( const char * )name ); QuestionDlg dlg( text, msgtext, secondButton ); switch( dlg.exec() ) { case 0: // Cancel delete newitem; return 0x0; break; case 1: // Remove newitem->option = "D"; + // If local file, remove using package name, not filename + if ( p->isPackageStoredLocally() ) + name = item->text(); break; case 2: // Reinstall or Upgrade newitem->option = secondOption; break; } } else { // newitem->option = stickyOption; } } // Check if we are reinstalling the same version if ( newitem->option != "R" ) newitem->recreateLinks = true; else newitem->recreateLinks = false; // User hit cancel (on dlg - assume remove) return newitem; } } void MainWindow :: reloadData( InstallDlgImpl *dlg ) { stack->raiseWidget( progressWindow ); if ( dlg ) { dlg->close(); delete dlg; } mgr->reloadServerData(); serverSelected( -1, FALSE ); #ifdef QWS if ( reloadDocuments ) { m_status->setText( tr( "Updating Launcher..." ) ); // Finally let the main system update itself QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; } #endif stack->raiseWidget( networkPkgWindow ); } void MainWindow :: letterPushed( QString t ) { QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( packagesList->firstChild() == 0 ) return; QCheckListItem *item; if ( start == 0 ) { item = (QCheckListItem *)packagesList->firstChild(); start = top; } else item = (QCheckListItem *)start->nextSibling(); if ( item == 0 ) item = (QCheckListItem *)packagesList->firstChild(); do { if ( item->text().lower().startsWith( t.lower() ) ) { packagesList->setSelected( item, true ); packagesList->ensureItemVisible( item ); break; } item = (QCheckListItem *)item->nextSibling(); if ( !item ) item = (QCheckListItem *)packagesList->firstChild(); } while ( item != start); } void MainWindow :: slotDisplayPackage( QListViewItem *item ) { QString itemstr( ((QCheckListItem*)item)->text() ); PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); p->showMaximized(); } QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) { setCaption( caption ); resize( 175, 100 ); QGridLayout *layout = new QGridLayout( this ); QLabel *l = new QLabel( text, this ); l->setAlignment( AlignCenter | WordBreak ); layout->addMultiCellWidget( l, 0, 0, 0, 1 ); btn1 = new QPushButton( tr( "Remove" ), this ); connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); layout->addWidget( btn1, 1, 0 ); btn2 = new QPushButton( secondbtn, this ); connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); layout->addWidget( btn2, 1, 1 ); executing = FALSE; } int QuestionDlg::exec() { show(); if ( !executing ) { executing = TRUE; qApp->enter_loop(); } return buttonpressed; } void QuestionDlg::slotButtonPressed() { if ( sender() == btn1 ) buttonpressed = 1; else if ( sender() == btn2 ) buttonpressed = 2; else buttonpressed = 0; qApp->exit_loop(); } diff --git a/noncore/settings/aqpkg/opie-aqpkg.control b/noncore/settings/aqpkg/opie-aqpkg.control index b8ad1e8..46bffdd 100644 --- a/noncore/settings/aqpkg/opie-aqpkg.control +++ b/noncore/settings/aqpkg/opie-aqpkg.control @@ -1,11 +1,11 @@ Package: opie-aqpkg Files: bin/aqpkg pics/aqpkg apps/Settings/aqpkg.desktop Priority: optional Section: Settings -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal Replaces: aqpkg Architecture: arm Maintainer: Andy Qua (andy.qua@blueyonder.co.uk) Description: A Package Manager +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp index adda832..5a521d3 100644 --- a/noncore/settings/aqpkg/package.cpp +++ b/noncore/settings/aqpkg/package.cpp @@ -1,162 +1,163 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. 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 "package.h" #include "global.h" #include <qobject.h> Package::Package( QString &name ) { packageName = name; QString tempstr = QObject::tr( "N/A" ); version = tempstr; description = tempstr; packageSize = tempstr; section = tempstr; localPackage = 0; installed = false; packageStoredLocally = false; installedToRoot = false; installed = false; installedTo = 0; } Package::Package( char *name ) { packageName = name; QString tempstr = QObject::tr( "N/A" ); version = tempstr; description = tempstr; packageSize = tempstr; section = tempstr; localPackage = 0; installed = false; packageStoredLocally = false; installedToRoot = false; installed = false; installedTo = 0; differentVersionAvailable = false; } Package::~Package() { } QString Package :: toString() { QString ret = QObject::tr( "Package - %1\n version - %2" ). arg( getPackageName() ). arg( getVersion() ); if ( localPackage ) ret.append( QObject::tr( "\n inst version - %1" ).arg( localPackage->getVersion() ) ); return ret; } void Package :: setStatus( const QString &s ) { QString state_status; int two, three; status = s.simplifyWhiteSpace( ); two = status.find( " " ); // find second column three = status.find( " ", two + 1 ); // find third column state_status = status.mid( three ).stripWhiteSpace( ); if ( state_status == "installed" ) installed = true; } void Package :: setLocalPackage( Package *p ) { localPackage = p; if ( localPackage ) if ( localPackage->getVersion() < getVersion() && !installed ) differentVersionAvailable = true; else differentVersionAvailable = false; } void Package :: setVersion( const QString &v ) { version = v; + differentVersionAvailable = false; if ( localPackage ) if ( localPackage->getVersion() < getVersion() && !installed ) differentVersionAvailable = true; else differentVersionAvailable = false; } void Package :: setPackageName( const QString &name ) { packageName = name; } void Package :: setDescription( const QString &d ) { description = d; } void Package :: setFilename( const QString &f ) { filename = f; } QString Package :: getInstalledVersion() { if ( localPackage ) return localPackage->getVersion(); else return getVersion(); } QString Package :: getInstalledPackageName() { if ( localPackage ) return localPackage->getPackageName(); else return getPackageName(); } bool Package :: isInstalled() { return installed || ( localPackage && localPackage->isInstalled() ); } diff --git a/noncore/settings/aqpkg/packagewin.cpp b/noncore/settings/aqpkg/packagewin.cpp index 9553cd1..499d647 100644 --- a/noncore/settings/aqpkg/packagewin.cpp +++ b/noncore/settings/aqpkg/packagewin.cpp @@ -1,118 +1,119 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. 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 "packagewin.h" #include "package.h" #include "datamgr.h" #include <qpe/resource.h> #include <qlayout.h> #include <qpushbutton.h> #include <qstring.h> #include <qtextview.h> PackageWindow::PackageWindow( Package *package, const QString &server ) : QWidget( 0, 0, 0 ) { QString str; if ( package ) { + Package *local = package->getLocalPackage(); setCaption( package->getPackageName() ); QString destName; - if ( package->getLocalPackage() ) + if ( local ) { - if ( package->getLocalPackage()->getInstalledTo() ) + if ( local->getInstalledTo() ) destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); } else { if ( package->getInstalledTo() ) destName = package->getInstalledTo()->getDestinationName(); } if ( !package->isPackageStoredLocally() ) { str.append( tr( "<b>Description</b> - " ) ); str.append( package->getDescription() ); if ( !destName.isNull() ) { str.append( tr( "<p><b>Installed To</b> - " ) ); str.append( destName ); } str.append( tr( "<p><b>Size</b> - " ) ); str.append( package->getPackageSize() ); str.append( tr( "<p><b>Section</b> - " ) ); str.append( package->getSection() ); } else { str.append( tr( "<p><b>Filename</b> - " ) ); str.append( package->getFilename() ); } if ( server == LOCAL_SERVER ) { str.append( tr( "<p><b>Version Installed</b> - " ) ); str.append( package->getVersion() ); } else { str.append( tr( "<p><b>Version Available</b> - " ) ); str.append( package->getVersion() ); - if ( package->getLocalPackage() ) + if ( local ) { if ( package->isInstalled() ) { str.append( tr( "<p><b>Version Installed</b> - " ) ); str.append( package->getInstalledVersion() ); } } } } else { setCaption( tr( "Package Information" ) ); str = tr( "Package information is unavailable" ); } QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 ); QTextView *l = new QTextView( str, QString::null, this ); layout->addWidget( l ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); layout->addWidget( btn ); connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) ); } PackageWindow::~PackageWindow() { } diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 4693db1..0282236 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp @@ -1,315 +1,326 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. 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 "server.h" #include "datamgr.h" #include <qfile.h> #include <qtextstream.h> #ifdef QWS #include <qpe/global.h> #include <qpe/applnk.h> #include <qlist.h> #endif #include "utils.h" #include "global.h" Server :: Server( const char *name, const char *url ) { serverName = name; serverUrl = url; packageFile = IPKG_DIR; active = true; packageFile.append( "lists/" ); packageFile.append( serverName ); } Server :: ~Server() { cleanUp(); } void Server :: cleanUp() { packageList.clear(); } void Server :: readStatusFile( QList<Destination> &destList ) { cleanUp(); Destination *dest; QListIterator<Destination> dit( destList ); bool rootRead = false; for ( ; dit.current(); ++dit ) { dest = dit.current(); bool installingToRoot = false; QString path = dest->getDestinationPath(); if ( path.right( 1 ) != "/" ) path.append( "/" ); if ( path == "/" ) { rootRead = true; installingToRoot = true; } packageFile = path; packageFile.append( "usr/lib/ipkg/status" ); readPackageFile( 0, false, installingToRoot, &( *dest ) ); } // Ensure that the root status file is read if ( !rootRead ) { packageFile = "/usr/lib/ipkg/status"; readPackageFile( 0, false, true ); } } void Server :: readLocalIpks( Server *local ) { cleanUp(); #ifdef QWS // First, get any local IPKGs in the documents area // Only applicable to Qtopie/Opie DocLnkSet files; Global::findDocuments( &files, "application/ipkg" ); // Now add the items to the list QListIterator<DocLnk> it( files.children() ); for ( ; it.current() ; ++it ) { // OK, we have a local IPK file, I think the standard naming conventions // for these are packagename_version_arm.ipk QString file = (*it)->file(); // Changed to display the filename (excluding the path) - QString packageName = Utils::getFilenameFromIpkFilename( file ); + QString packageName = Utils::getPackageNameFromIpkFilename( file ); QString ver = Utils::getPackageVersionFromIpkFilename( file ); Package *package = new Package( packageName ); package->setVersion( ver ); package->setFilename( file ); package->setPackageStoredLocally( true ); packageList.append( package ); } #else QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; for ( int i = 0 ; i < 4 ; ++i ) { // OK, we have a local IPK file, I think the standard naming conventions // for these are packagename_version_arm.ipk QString file = names[i]; int p = file.find( "_" ); QString tmp = file.mid( 0, p ); packageList.push_back( Package( tmp ) ); int p2 = file.find( "_", p+1 ); tmp = file.mid( p+1, p2-(p+1) ); packageList.back().setVersion( tmp ); packageList.back().setPackageStoredLocally( true ); } #endif // build local packages buildLocalPackages( local ); } void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) { QFile f( packageFile ); if ( !f.open( IO_ReadOnly ) ) return; QTextStream t( &f ); QString line; QString key; QString value; int pos; if ( clearAll ) cleanUp(); Package *currPackage = 0; bool newPackage = true; while ( !t.eof() ) { line = t.readLine(); pos = line.find( ':', 0 ); if ( pos > -1 ) key = line.mid( 0, pos ).stripWhiteSpace(); else key = QString::null; value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace(); if ( key == "Package" && newPackage ) { newPackage = false; currPackage = getPackage( value ); if ( !currPackage ) { Package *package = new Package( value ); packageList.append( package ); currPackage = package; currPackage->setInstalledTo( dest ); if ( installingToRoot ) currPackage->setInstalledToRoot( true ); } else { if ( currPackage->isInstalled() ) currPackage->setInstalledTo( dest ); } } else if ( key == "Version" ) { if ( currPackage ) currPackage->setVersion( value ); } else if ( key == "Status" ) { if ( currPackage ) currPackage->setStatus( value ); } else if ( key == "Description" ) { if ( currPackage ) currPackage->setDescription( value ); } else if ( key == "Filename" ) { if ( currPackage ) currPackage->setFilename( value ); } else if ( key == "Size" ) { if ( currPackage ) currPackage->setPackageSize( value ); } else if ( key == "Section" ) { if ( currPackage ) currPackage->setSection( value ); DataManager::setAvailableCategories( value ); } else if ( key == QString::null ) { newPackage = true; } } f.close(); // build local packages buildLocalPackages( local ); } void Server :: buildLocalPackages( Server *local ) { Package *curr; QListIterator<Package> it( packageList ); + + QList<Package> *locallist = &local->getPackageList(); + for ( ; it.current(); ++it ) { curr = it.current(); QString name = curr->getPackageName(); // If the package name is an ipk name, then convert the filename to a package name if ( name.find( ".ipk" ) != -1 ) name = Utils::getPackageNameFromIpkFilename( curr->getFilename() ); if ( local ) { Package *p = local->getPackage( name ); curr->setLocalPackage( p ); if ( p ) { + // Replace local version + if ( curr->getVersion() > p->getVersion() ) + { + int pos = locallist->at(); + locallist->remove( p ); + locallist->insert( pos, curr ); + } + // Set some default stuff like size and things if ( p->getInstalledVersion() == curr->getVersion() ) { p->setPackageSize( curr->getPackageSize() ); p->setSection( curr->getSection() ); p->setDescription( curr->getDescription() ); } } } else curr->setLocalPackage( 0 ); } } Package *Server :: getPackage( QString &name ) { return getPackage( (const char *)name ); } Package *Server :: getPackage( const char *name ) { Package *ret = 0; QListIterator<Package> it( packageList ); for ( ; it.current(); ++it ) { if ( it.current()->getPackageName() == name ) ret = it.current(); } return ret; } QString Server :: toString() { QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl ); QListIterator<Package> it( packageList ); for ( ; it.current(); ++it ) { ret.append( QString( "\n %1" ).arg( it.current()->toString() ) ); } return ret; } QList<Package> &Server::getPackageList() { return packageList; } diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 3d127a8..8def0d6 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp @@ -1,193 +1,191 @@ /********************************************************************** ** ModulesInfo ** ** Display Modules information ** ** Copyright (C) 2002, Michael Lauer ** mickey@tm.informatik.uni-frankfurt.de ** http://www.Vanille.de ** ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qcombobox.h> #include <qfile.h> #include <qheader.h> #include <qlayout.h> #include <qlistview.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qstring.h> #include <qtimer.h> #include <qwhatsthis.h> #include "modulesinfo.h" #include "detail.h" ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); ModulesView = new QListView( this ); int colnum = ModulesView->addColumn( tr( "Module" ) ); colnum = ModulesView->addColumn( tr( "Size" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ModulesView->addColumn( tr( "Use#" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); - colnum = ModulesView->addColumn( tr( "Used By" ) ); + colnum = ModulesView->addColumn( tr( "Used by" ) ); ModulesView->setAllColumnsShowFocus( TRUE ); layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); // Test if we have /sbin/modinfo, and if so, allow module detail window if ( QFile::exists( "/sbin/modinfo" ) ) { QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( viewModules( QListViewItem * ) ) ); } CommandCB = new QComboBox( FALSE, this ); CommandCB->insertItem( "modprobe -r" ); CommandCB->insertItem( "rmmod" ); // I can't think of other useful commands yet. Anyone? layout->addWidget( CommandCB, 1, 0 ); QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); QPushButton *btn = new QPushButton( this ); btn->setMinimumSize( QSize( 50, 24 ) ); btn->setMaximumSize( QSize( 50, 24 ) ); btn->setText( tr( "Send" ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); layout->addWidget( btn, 1, 1 ); QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); QTimer *t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); t->start( 5000 ); updateData(); ModulesDtl = new Detail(); QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); } ModulesInfo::~ModulesInfo() { } void ModulesInfo::updateData() { char modname[64]; char usage[200]; int modsize, usecount; QString selectedmod; QListViewItem *curritem = ModulesView->currentItem(); if ( curritem ) { selectedmod = curritem->text( 0 ); } ModulesView->clear(); FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); if ( procfile ) { QListViewItem *newitem; QListViewItem *selecteditem = 0x0; while ( true ) { int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); if ( success == EOF ) break; QString qmodname = QString( modname ); QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); QString qusage = QString( usage ); newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); if ( qmodname == selectedmod ) { selecteditem = newitem; } } ModulesView->setCurrentItem( selecteditem ); fclose( procfile ); } } void ModulesInfo::slotSendClicked() { if ( !ModulesView->currentItem() ) { return; } - QString capstr = tr( "You really want to execute\n" ); - capstr.append( CommandCB->currentText() ); - capstr.append( "\nfor this module?" ); + QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); QString modname = ModulesView->currentItem()->text( 0 ); if ( QMessageBox::warning( this, modname, capstr, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) { QString command = "/sbin/"; command.append( CommandCB->currentText() ); command.append( " " ); command.append( modname ); FILE* stream = popen( command, "r" ); if ( stream ) pclose( stream ); } } void ModulesInfo::viewModules( QListViewItem *modules ) { QString modname = modules->text( 0 ); QString capstr = "Module: "; capstr.append( modname ); ModulesDtl->setCaption( capstr ); QString command = "/sbin/modinfo "; command.append( modname ); FILE* modinfo = popen( command, "r" ); if ( modinfo ) { char line[200]; ModulesDtl->detailView->setText( " Details:\n------------\n" ); while( true ) { int success = fscanf( modinfo, "%[^\n]\n", line ); if ( success == EOF ) break; ModulesDtl->detailView->append( line ); } pclose( modinfo ); } ModulesDtl->showMaximized(); } diff --git a/noncore/settings/sysinfo/opie-sysinfo.control b/noncore/settings/sysinfo/opie-sysinfo.control index acb51e5..8250174 100644 --- a/noncore/settings/sysinfo/opie-sysinfo.control +++ b/noncore/settings/sysinfo/opie-sysinfo.control @@ -1,10 +1,10 @@ Package: opie-sysinfo Files: bin/sysinfo apps/Settings/sysinfo.desktop pics/sysinfo Priority: optional Section: opie/applications Maintainer: Dan Williams <williamsdr@acm.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION Depends: task-opie-minimal, libopie1 Description: System Information dialog For the Opie environment. +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 1de1a19..8dec9be 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp @@ -1,205 +1,203 @@ /********************************************************************** ** ProcessInfo ** ** Display process information ** ** Copyright (C) 2002, Dan Williams ** williamsdr@acm.org ** http://draknor.net ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qheader.h> #include <qlayout.h> #include <qlistview.h> #include <qmessagebox.h> #include <qtimer.h> #include <qwhatsthis.h> #include <sys/types.h> #include <signal.h> #include "processinfo.h" #include "detail.h" ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); ProcessView = new QListView( this, "ProcessView" ); int colnum = ProcessView->addColumn( tr( "PID" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ProcessView->addColumn( tr( "Command" ),96 ); colnum = ProcessView->addColumn( tr( "Status" ) ); colnum = ProcessView->addColumn( tr( "Time" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); ProcessView->setAllColumnsShowFocus( TRUE ); QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( viewProcess( QListViewItem * ) ) ); layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); SignalCB = new QComboBox( FALSE, this, "SignalCB" ); SignalCB->insertItem( " 1: SIGHUP" ); SignalCB->insertItem( " 2: SIGINT" ); SignalCB->insertItem( " 3: SIGQUIT" ); SignalCB->insertItem( " 5: SIGTRAP" ); SignalCB->insertItem( " 6: SIGABRT" ); SignalCB->insertItem( " 9: SIGKILL" ); SignalCB->insertItem( "14: SIGALRM" ); SignalCB->insertItem( "15: SIGTERM" ); SignalCB->insertItem( "18: SIGCONT" ); SignalCB->insertItem( "19: SIGSTOP" ); layout->addWidget( SignalCB, 1, 0 ); QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); SendButton = new QPushButton( this, "SendButton" ); SendButton->setMinimumSize( QSize( 50, 24 ) ); SendButton->setMaximumSize( QSize( 50, 24 ) ); SendButton->setText( tr( "Send" ) ); connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); layout->addWidget( SendButton, 1, 1 ); QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); QTimer *t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); t->start( 5000 ); updateData(); ProcessDtl = new Detail(); QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); } ProcessInfo::~ProcessInfo() { } void ProcessInfo::updateData() { int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, signal, blocked, sigignore, sigcatch; uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, endcode, startstack, kstkesp, kstkeip, wchan; char state; char comm[64]; QString selectedpid; QListViewItem *curritem = ProcessView->currentItem(); if ( curritem ) { selectedpid = curritem->text( 0 ); } ProcessView->clear(); QListViewItem *newitem; QListViewItem *selecteditem = 0x0; QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); if ( proclist ) { QFileInfoListIterator it(*proclist); QFileInfo *f; while ( ( f = it.current() ) != 0 ) { ++it; QString processnum = f->fileName(); if ( processnum >= "1" && processnum <= "99999" ) { FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); if ( procfile ) { fscanf( procfile, "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); processnum = processnum.rightJustify( 5, ' ' ); QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); QString processstatus = QChar(state); QString processtime = QString::number( ( utime + stime ) / 100 ); processtime = processtime.rightJustify( 9, ' ' ); fclose( procfile ); newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); if ( processnum == selectedpid ) { selecteditem = newitem; } } } } ProcessView->setCurrentItem( selecteditem ); } delete proclist; delete procdir; } void ProcessInfo::slotSendClicked() { QListViewItem *currprocess = ProcessView->currentItem(); if ( !currprocess ) { return; } - QString capstr = tr( "You really want to send\n" ); - capstr.append( SignalCB->currentText() ); - capstr.append( "\nto this process?" ); + QString capstr = tr( "You really want to send %1 to this process?" ).arg( SignalCB->currentText() ); if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) { currprocess = ProcessView->currentItem(); if ( currprocess ) { QString sigstr = SignalCB->currentText(); sigstr.truncate(2); int sigid = sigstr.toUInt(); kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); } } } void ProcessInfo::viewProcess( QListViewItem *process ) { QString pid= process->text( 0 ).stripWhiteSpace(); QString command = process->text( 1 ); ProcessDtl->setCaption( pid + " - " + command ); FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); if ( statfile ) { char line[81]; fgets( line, 81, statfile ); ProcessDtl->detailView->setText( line ); while ( fgets( line, 81, statfile ) ) { ProcessDtl->detailView->append( line ); } fclose( statfile ); } ProcessDtl->showMaximized(); } |