summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/filePermissions.cpp12
-rw-r--r--noncore/apps/advancedfm/main.cpp4
-rw-r--r--noncore/apps/advancedfm/opie-advancedfm.control2
-rw-r--r--noncore/apps/advancedfm/output.cpp12
-rw-r--r--noncore/apps/checkbook/opie-checkbook.control2
-rw-r--r--noncore/apps/opie-console/configdialog.cpp4
-rw-r--r--noncore/apps/opie-console/consoleconfigwidget.cpp19
-rw-r--r--noncore/apps/opie-console/main.cpp81
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp5
-rw-r--r--noncore/apps/opie-console/opie-console.control2
-rw-r--r--noncore/apps/opie-console/opie-console.pro1
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp11
-rw-r--r--noncore/apps/opie-reader/Prefs.cpp60
-rw-r--r--noncore/apps/opie-reader/Prefs.h9
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp2
-rw-r--r--noncore/apps/opie-reader/ToolbarPrefs.h2
-rw-r--r--noncore/apps/opie-reader/opie-reader.control2
-rw-r--r--noncore/apps/opie-write/opie-write.control2
-rw-r--r--noncore/apps/oxygen/opie-oxygen.control2
-rw-r--r--noncore/apps/tableviewer/opie-tableviewer.control2
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.cpp2
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp3
-rw-r--r--noncore/apps/tinykate/libkate/libkate.pro5
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp12
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kcolordialog.h4
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.cpp14
-rw-r--r--noncore/apps/tinykate/main.cpp5
-rw-r--r--noncore/apps/tinykate/opie-tinykate-syntax-commondev.control2
-rw-r--r--noncore/apps/tinykate/opie-tinykate-syntax-documentation.control2
-rw-r--r--noncore/apps/tinykate/opie-tinykate-syntax-misc.control2
-rw-r--r--noncore/apps/tinykate/opie-tinykate-syntax-miscdev.control2
-rw-r--r--noncore/apps/tinykate/opie-tinykate-syntax-unix.control2
-rw-r--r--noncore/apps/tinykate/opie-tinykate-syntax-web.control2
-rw-r--r--noncore/apps/tinykate/opie-tinykate-syntax.control2
-rw-r--r--noncore/apps/tinykate/opie-tinykate.control2
-rw-r--r--noncore/apps/tinykate/tinykate.cpp142
-rw-r--r--noncore/apps/tinykate/tinykate.h21
-rw-r--r--noncore/apps/tinykate/tinykate.pro6
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp12
-rw-r--r--noncore/settings/aqpkg/opie-aqpkg.control2
-rw-r--r--noncore/settings/aqpkg/package.cpp1
-rw-r--r--noncore/settings/aqpkg/packagewin.cpp7
-rw-r--r--noncore/settings/aqpkg/server.cpp13
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp6
-rw-r--r--noncore/settings/sysinfo/opie-sysinfo.control2
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp4
46 files changed, 241 insertions, 272 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 <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 ) );
connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck()));
CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" );
CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) );
connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck()));
CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" );
CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) );
connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck()));
CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" );
CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) );
connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck()));
CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" );
CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) );
connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck()));
CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" );
CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) );
connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck()));
CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" );
CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) );
connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck()));
GroupLineEdit = new QLineEdit( this, "GroupLineEdit" );
GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) );
OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" );
OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) );
TextLabel5 = new QLabel( this, "TextLabel5" );
TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) );
TextLabel5->setText( tr( "Owner" ) );
TextLabel5_2 = new QLabel( this, "TextLabel5_2" );
TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) );
TextLabel5_2->setText( tr( "Group" ) );
ModeLine = new QLineEdit( this, "TextLabelMode" );
ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) );
TextLabel3_2 = new QLabel( this, "TextLabel3_2" );
TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) );
TextLabel3_2->setText( tr( "read" ) );
TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" );
TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) );
TextLabel3_2_2->setText( tr( "write" ) );
TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
TextLabel3 = new QLabel( this, "TextLabel3" );
TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) );
TextLabel3->setText( tr( "execute" ) );
TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
struct stat buf;
mode_t mode;
file = fileName;
QFileInfo fi(file);
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());
if ( !name )
setName( tr("Output"));
resize( 196, 269 );
setCaption( name );
OutputLayout = new QGridLayout( this );
OutputLayout->setSpacing( 2);
OutputLayout->setMargin( 2);
QPushButton *docButton;
docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
docButton->setFixedSize( QSize( 20, 20 ) );
connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
// docButton->setFlat(TRUE);
OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
proc = new OProcess();
connect(proc, SIGNAL(processExited(OProcess *)),
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();
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();
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 );
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);
+ m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102);
initUI();
// Apply current profile
// plugin_plugin->load(profile);
}
Profile ProfileEditorDialog::profile() const
{
return m_prof;
}
void ProfileEditorDialog::initUI()
{
m_con = m_term = m_key = 0l;
QVBoxLayout *mainLayout = new QVBoxLayout( this );
tabWidget = new OTabWidget( this );
tabWidget->setTabStyle(OTabWidget::TextTab);
mainLayout->add(tabWidget);
/* base tabs */
tabprof = new QWidget(this);
m_tabTerm = new QWidget(this);
m_tabCon = new QWidget(this);
m_tabKey = new QWidget(this);
m_svCon = new QScrollView( m_tabCon );
m_svCon->setResizePolicy( QScrollView::AutoOneFit );
//m_svCon->setHScrollBarMode( QScrollView::AlwaysOff );
m_svCon->setFrameShape( QFrame::NoFrame );
m_svTerm = new QScrollView( m_tabTerm );
m_svTerm->setResizePolicy( QScrollView::AutoOneFit );
//m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff );
m_svTerm->setFrameShape( QFrame::NoFrame );
/* base layout for tabs */
m_layCon = new QHBoxLayout( m_tabCon , 2 );
m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
m_layKey = new QHBoxLayout( m_tabKey, 2 );
m_layCon->addWidget( m_svCon );
m_layTerm->addWidget( m_svTerm );
// profile tab
QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
m_name = new QLineEdit(tabprof);
QLabel *con = new QLabel(tr("Connection"), tabprof );
QLabel *term = new QLabel(tr("Terminal"), tabprof );
m_conCmb = new QComboBox( tabprof );
m_termCmb = new QComboBox( tabprof );
m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof);
// layouting
QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
vbox3->add(name);
vbox3->add(m_name);
vbox3->add(con );
vbox3->add(m_conCmb );
vbox3->add(term );
vbox3->add(m_termCmb );
vbox3->add(m_autoConnect);
vbox3->addStretch(1);
m_showconntab = 0;
tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys"));
tabWidget->setCurrentTab( tabprof );
// fill the comboboxes
QStringList list = m_fact->connectionWidgets();
QStringList::Iterator it;
for (it =list.begin(); it != list.end(); ++it ) {
m_conCmb->insertItem( (*it) );
}
list = m_fact->terminalWidgets();
for (it =list.begin(); it != list.end(); ++it ) {
m_termCmb->insertItem( (*it) );
}
// load profile values
m_name->setText(m_prof.name());
- 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) {
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
@@ -1,4222 +1,4222 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. Allrights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "useqpe.h"
#include <qregexp.h>
#include <qclipboard.h>
#include <qwidgetstack.h>
#ifdef USEQPE
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#endif
#include <qmenubar.h>
#include <qtoolbar.h>
#ifdef USEQPE
#include <qpe/menubutton.h>
#include <qpe/fontdatabase.h>
#endif
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qaction.h>
#include <qapplication.h>
#include <qlineedit.h>
#include <qtoolbutton.h>
#include <qspinbox.h>
#include <qobjectlist.h>
#ifdef USEQPE
#include <qpe/global.h>
#include <qpe/applnk.h>
#endif
#include <qfileinfo.h>
#include <stdlib.h> //getenv
#include <qprogressbar.h>
#ifdef USEQPE
#include <qpe/config.h>
#endif
#include <qbuttongroup.h>
#include <qradiobutton.h>
#ifdef USEQPE
#include <qpe/qcopenvelope_qws.h>
#endif
#include "QTReader.h"
#include "GraphicWin.h"
#include "Bkmks.h"
#include "cbkmkselector.h"
#include "infowin.h"
#include "ToolbarPrefs.h"
#include "Prefs.h"
#include "CAnnoEdit.h"
#include "QFloatBar.h"
#include "FixedFont.h"
#include "URLDialog.h"
//#include <qpe/fontdatabase.h>
#ifdef USEQPE
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include "fileBrowser.h"
#else
#include "qfiledialog.h"
#endif
#include "QTReaderApp.h"
#include "CDrawBuffer.h"
#include "Filedata.h"
#include "opie.h"
#include "useqpe.h"
#include "names.h"
#include "CEncoding_tables.h"
#include "CloseDialog.h"
bool CheckVersion(int&, int&, char&);
#ifdef _WINDOWS
#define PICDIR "c:\\uqtreader\\pics\\"
#else
#ifdef USEQPE
#define PICDIR "opie-reader/"
#else
#define PICDIR "/home/tim/uqtreader/pics/"
#endif
#endif
unsigned long QTReaderApp::m_uid = 0;
void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
#ifdef USEQPE
#define geticon(iconname) Resource::loadPixmap( iconname )
#define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname )
#else
#define geticon(iconname) QPixmap(PICDIR iconname ".png")
#define getmyicon(iconname) geticon(iconname)
//#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) )
#endif
#ifndef _WINDOWS
#include <unistd.h>
#endif
#include <stddef.h>
#ifndef _WINDOWS
#include <dirent.h>
#endif
void QTReaderApp::listBkmkFiles()
{
bkmkselector->clear();
bkmkselector->setText("Cancel");
#ifndef USEQPE
int cnt = 0;
QDir d = QDir::home(); // "/"
if ( !d.cd(APPDIR) ) { // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
d = QDir::home();
d.mkdir(APPDIR);
d.cd(APPDIR);
}
d.setFilter( QDir::Files | QDir::NoSymLinks );
// d.setSorting( QDir::Size | QDir::Reversed );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
while ( (fi=it.current()) ) { // for each file...
bkmkselector->insertItem(fi->fileName());
cnt++;
//qDebug( "%10li %s", fi->size(), fi->fileName().data() );
++it; // goto next list element
}
#else /* USEQPE */
int cnt = 0;
DIR *d;
d = opendir((const char *)Global::applicationFileName(APPDIR,""));
while(1)
{
struct dirent* de;
struct stat buf;
de = readdir(d);
if (de == NULL) break;
if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
{
bkmkselector->insertItem(de->d_name);
cnt++;
}
}
closedir(d);
#endif
if (cnt > 0)
{
//tjw menu->hide();
editorStack->raiseWidget( bkmkselector );
hidetoolbars();
m_nBkmkAction = cRmBkmkFile;
}
else
QMessageBox::information(this, PROGNAME, "No bookmark files");
}
void QTReaderApp::hidetoolbars()
{
menubar->hide();
if (fileBar != NULL) fileBar->hide();
if (viewBar != NULL) viewBar->hide();
if (navBar != NULL) navBar->hide();
if (markBar != NULL) markBar->hide();
if (m_fontVisible) m_fontBar->hide();
if (regVisible)
{
#ifdef USEQPE
Global::hideInputMethod();
#endif
regBar->hide();
}
if (searchVisible)
{
#ifdef USEQPE
Global::hideInputMethod();
#endif
searchBar->hide();
}
}
QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
: QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false),
fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL)
{
m_url_clipboard = false;
m_url_localfile = false;
m_url_globalfile = false;
ftime(&m_lastkeytime);
//// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
//// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
m_bcloseDisabled = true;
m_disableesckey = false;
pBkmklist = NULL;
pOpenlist = NULL;
// doc = 0;
m_fBkmksChanged = false;
QString lang = getenv( "LANG" );
QString rot = getenv( "QWS_DISPLAY" );
/*
int m_rot = 0;
if (rot.contains("Rot90"))
{
m_rot = 90;
}
else if (rot.contains("Rot180"))
{
m_rot = 180;
}
else if (rot.contains("Rot270"))
{
m_rot = 270;
}
// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot);
*/
m_autogenstr = "^ *[A-Z].*[a-z] *$";
#ifdef USEQPE
setIcon( Resource::loadPixmap( PICDIR "uqtreader") );
#else
setIcon( QPixmap (PICDIR "uqtreader.png") );
#endif /* USEQPE */
// QPEToolBar *bar = new QPEToolBar( this );
// menubar = new QPEToolBar( this );
#ifdef USEQPE
Config config( APPDIR );
#else
QDir d = QDir::home(); // "/"
if ( !d.cd(APPDIR) ) { // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
d = QDir::home();
d.mkdir(APPDIR);
d.cd(APPDIR);
}
QFileInfo fi(d, INIFILE);
// qDebug("Path:%s", (const char*)fi.absFilePath());
Config config(fi.absFilePath());
#endif
config.setGroup("Toolbar");
m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
menubar = new QToolBar("Menus", this, m_tbposition);
// fileBar = new QToolBar("File", this);
// QToolBar* viewBar = new QToolBar("File", this);
// QToolBar* navBar = new QToolBar("File", this);
// QToolBar* markBar = new QToolBar("File", this);
#ifdef USEQPE
mb = new QPEMenuBar( menubar );
#else
mb = new QMenuBar( menubar );
#endif
//#ifdef USEQPE
QPopupMenu* tmp = new QPopupMenu(mb);
mb->insertItem( geticon( "AppsIcon" ), tmp );
//#else
// QMenuBar* tmp = mb;
//#endif
QPopupMenu *file = new QPopupMenu( mb );
tmp->insertItem( tr( "File" ), file );
QPopupMenu *navigation = new QPopupMenu(mb);
tmp->insertItem( tr( "Navigation" ), navigation );
QPopupMenu *view = new QPopupMenu( mb );
tmp->insertItem( tr( "View" ), view );
QPopupMenu *marks = new QPopupMenu( this );
tmp->insertItem( tr( "Marks" ), marks );
QPopupMenu *settings = new QPopupMenu( this );
tmp->insertItem( tr( "Settings" ), settings );
// addToolBar(menubar, "Menus",QMainWindow::Top);
// addToolBar(fileBar, "Toolbar",QMainWindow::Top);
// QPopupMenu *edit = new QPopupMenu( this );
/*
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
a->addTo( bar );
a->addTo( file );
*/
editorStack = new QWidgetStack( this );
setCentralWidget( editorStack );
searchVisible = FALSE;
regVisible = FALSE;
m_fontVisible = false;
m_annoWin = new CAnnoEdit(editorStack);
editorStack->addWidget(m_annoWin, get_unique_id());
connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
m_infoWin = new infowin(editorStack);
editorStack->addWidget(m_infoWin, get_unique_id());
connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
m_graphicwin = new GraphicWin(editorStack);
editorStack->addWidget(m_graphicwin, get_unique_id());
connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
// bkmkselector = new QListBox(editorStack, "Bookmarks");
bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
// connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
editorStack->addWidget( bkmkselector, get_unique_id() );
/*
importSelector = new FileSelector( "*", editorStack, "importselector", false );
connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) );
editorStack->addWidget( importSelector, get_unique_id() );
// don't need the close visible, it is redundant...
importSelector->setCloseVisible( FALSE );
*/
// qDebug("Reading file list");
readfilelist();
reader = new QTReader( editorStack );
reader->bDoUpdates = false;
#ifdef USEQPE
((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
#endif
// qDebug("Reading config");
// Config config( APPDIR );
config.setGroup( "View" );
m_debounce = config.readNumEntry("Debounce", 0);
#ifdef USEQPE
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
#else
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
#endif
reader->bstripcr = config.readBoolEntry( "StripCr", true );
reader->bfulljust = config.readBoolEntry( "FullJust", false );
reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
reader->btextfmt = config.readBoolEntry( "TextFmt", false );
reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
reader->bpeanut = config.readBoolEntry( "Peanut", false );
reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
reader->bdepluck = config.readBoolEntry( "Depluck", false );
reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
reader->bonespace = config.readBoolEntry( "OneSpace", false );
reader->bunindent = config.readBoolEntry( "Unindent", false );
reader->brepara = config.readBoolEntry( "Repara", false );
reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
reader->bindenter = config.readNumEntry( "Indent", 0 );
reader->m_textsize = config.readNumEntry( "FontSize", 12 );
reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
reader->m_lastfile = config.readEntry( "LastFile", QString::null );
reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
reader->m_encd = config.readNumEntry( "Encoding", 0 );
reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
reader->m_overlap = config.readNumEntry( "Overlap", 0 );
reader->m_border = config.readNumEntry( "Margin", 6 );
#ifdef REPALM
reader->brepalm = config.readBoolEntry( "Repalm", true );
#endif
reader->bremap = config.readBoolEntry( "Remap", true );
reader->bmakebold = config.readBoolEntry( "MakeBold", false );
reader->setContinuous(config.readBoolEntry( "Continuous", true ));
m_targetapp = config.readEntry( "TargetApp", QString::null );
m_targetmsg = config.readEntry( "TargetMsg", QString::null );
#ifdef _SCROLLPIPE
reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
#endif
m_twoTouch = config.readBoolEntry( "TwoTouch", false);
m_doAnnotation = config.readBoolEntry( "Annotation", false);
m_doDictionary = config.readBoolEntry( "Dictionary", false);
m_doClipboard = config.readBoolEntry( "Clipboard", false);
m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
m_leftScroll = config.readBoolEntry("LeftScroll", false);
m_rightScroll = config.readBoolEntry("RightScroll", false);
m_upScroll = config.readBoolEntry("UpScroll", true);
m_downScroll = config.readBoolEntry("DownScroll", true);
m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
#ifndef USEQPE
config.setGroup( "Geometry" );
setGeometry(0,0,
config.readNumEntry( "width", QApplication::desktop()->width()/2 ),
config.readNumEntry( "height", QApplication::desktop()->height()/2 ));
move(
config.readNumEntry( "x", 20 ),
config.readNumEntry( "y", 20 ));
#endif
setTwoTouch(m_twoTouch);
connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) );
connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) );
connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) );
editorStack->addWidget( reader, get_unique_id() );
m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL);
connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) );
m_preferences_action->addTo( settings );
m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL);
connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) );
m_saveconfig_action->addTo( settings );
m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL);
connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) );
m_loadconfig_action->addTo( settings );
m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL);
connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) );
m_tidyconfig_action->addTo( settings );
settings->insertSeparator();
m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL);
connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) );
m_toolbarprefs_action->addTo( settings );
m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 );
connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
m_open_action->addTo( file );
m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) );
m_close_action->addTo( file );
#ifdef _SCRIPT
a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) );
a->addTo( file );
#endif
/*
a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
a->addTo( file );
a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( filebar() );
a->addTo( edit );
*/
m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL);
connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) );
m_info_action->addTo( file );
m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true );
connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
m_touch_action->setOn(m_twoTouch);
m_touch_action->addTo( file );
m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL);
connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) );
file->insertSeparator();
// a->addTo( bar );
m_find_action->addTo( file );
m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL);
connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) );
m_exportlinks_action->addTo( file );
m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true );
connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
m_scrollButton->addTo(navigation);
m_scrollButton->setOn(false);
m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL);
connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) );
m_start_action->addTo(navigation);
m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
m_end_action->addTo(navigation);
m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
m_jump_action->addTo(navigation);
m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
m_pageline_action->addTo(navigation);
m_pageline_action->setOn(reader->m_bpagemode);
m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
m_pageup_action->addTo( navigation );
m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
m_pagedn_action->addTo( navigation );
m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 );
connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) );
m_back_action->addTo( navigation );
m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 );
connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) );
m_home_action->addTo( navigation );
m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 );
connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) );
m_forward_action->addTo( navigation );
/*
a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
a->addTo( file );
a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
// connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
a->addTo( file );
*/
// file->insertSeparator();
#ifdef _SCROLLPIPE
QActionGroup* ag = new QActionGroup(this);
ag->setExclusive(false);
spacemenu = new QPopupMenu(this);
file->insertItem( tr( "Scrolling" ), spacemenu );
a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) );
a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true );
connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) );
a->setOn(reader->m_pauseAfterEachPara);
ag->addTo(spacemenu);
// file->insertSeparator();
#endif
/*
a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
a->addTo( file );
*/
/*
a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( fileBar );
a->addTo( edit );
*/
// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 );
m_fullscreen = false;
m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true );
connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
m_actFullscreen->setOn(m_fullscreen);
m_actFullscreen->addTo( view );
view->insertSeparator();
m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this);
connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) );
m_zoomin_action->addTo( view );
m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this);
connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) );
m_zoomout_action->addTo( view );
view->insertSeparator();
m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this);
connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) );
m_setfont_action->addTo( view );
view->insertSeparator();
m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this);
connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) );
m_setenc_action->addTo( view );
m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true);
connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
m_setmono_action->addTo( view );
m_setmono_action->setOn(reader->m_bMonoSpaced);
// a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
// a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 );
// a->addTo( filebar() );
// view->insertSeparator();
/*
a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
a->setOn(reader->m_bMonoSpaced);
a->addTo( view );
*/
/*
a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL);
connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
a->addTo( view );
*/
m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL);
connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
m_mark_action->addTo( marks );
m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL);
connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) );
m_annotate_action->addTo( marks );
m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false );
connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
m_goto_action->addTo( marks );
m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL);
connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
m_delete_action->addTo( marks );
m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false );
connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
marks->insertSeparator();
m_autogen_action->addTo( marks );
m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL);
connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
m_clear_action->addTo( marks );
m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL );
connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
m_save_action->addTo( marks );
m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL);
connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
marks->insertSeparator();
m_tidy_action->addTo( marks );
m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL);
connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) );
marks->insertSeparator();
m_startBlock_action->addTo( marks );
m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL);
connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) );
m_endBlock_action->addTo( marks );
m_bkmkAvail = NULL;
setToolBarsMovable(m_tbmove);
addtoolbars(&config);
pbar = new QProgressBar(this);
pbar->hide();
searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
searchBar->setHorizontalStretchable( TRUE );
connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
searchEdit = new QLineEdit( searchBar, "searchEdit" );
// QFont f("unifont", 16 /*, QFont::Bold*/);
// searchEdit->setFont( f );
searchBar->setStretchableWidget( searchEdit );
#ifdef __ISEARCH
connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT( search( const QString& ) ) );
#else
connect( searchEdit, SIGNAL( returnPressed( ) ),
this, SLOT( search( ) ) );
#endif
QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
a->addTo( searchBar );
a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
a->addTo( searchBar );
searchBar->hide();
regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE );
connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() ));
regBar->setHorizontalStretchable( TRUE );
regEdit = new QLineEdit( regBar, "regEdit" );
// regEdit->setFont( f );
regBar->setStretchableWidget( regEdit );
connect( regEdit, SIGNAL( returnPressed( ) ),
this, SLOT( do_regaction() ) );
a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
a->addTo( regBar );
a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
a->addTo( regBar );
regBar->hide();
m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
m_fontBar->setHorizontalStretchable( TRUE );
// qDebug("Font selector");
m_fontSelector = new QComboBox(false, m_fontBar);
m_fontBar->setStretchableWidget( m_fontSelector );
{
#ifndef USEQPE
QFontDatabase f;
#else
FontDatabase f;
#endif
QStringList flist = f.families();
bool realfont = false;
for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
{
if (reader->m_fontname == *nm)
{
realfont = true;
}
if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm);
}
if (!realfont) reader->m_fontname = flist[0];
} // delete the FontDatabase!!!
connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
this, SLOT( do_setfont(const QString&) ) );
connect( m_fontSelector, SIGNAL( activated(int ) ),
this, SLOT( do_setencoding(int) ) );
m_fontBar->hide();
m_fontVisible = false;
#ifdef USEMSGS
connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
#endif
// qDebug("Initing");
reader->init();
// qDebug("Inited");
// m_buttonAction[m_spaceTarget]->setOn(true);
// qDebug("fonting");
do_setfont(reader->m_fontname);
if (!reader->m_lastfile.isEmpty())
{
// qDebug("doclnk");
// doc = new DocLnk(reader->m_lastfile);
// qDebug("doclnk done");
if (pOpenlist != NULL)
{
/*
int ind = 0;
Bkmk* p = (*pOpenlist)[ind];
while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
{
p = (*pOpenlist)[++ind];
}
*/
Bkmk* p = NULL;
for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
{
p = iter.pContent();
if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
{
break;
}
// qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
p = NULL;
}
if (p != NULL)
{
// qDebug("openfrombkmk");
if (!openfrombkmk(p))
showEditTools();
}
else
{
// qDebug("openfile");
openFile( reader->m_lastfile );
}
}
else
{
// qDebug("Openfile 2");
if (!reader->m_lastfile.isEmpty())
openFile( reader->m_lastfile );
}
}
else
{
showEditTools();
}
// qApp->processEvents();
reader->bDoUpdates = true;
reader->update();
config.setGroup("Version");
int major = config.readNumEntry("Major", 0);
int bkmktype = config.readNumEntry("BkmkType", 0);
char minor = config.readNumEntry("Minor", 0);
if (CheckVersion(major, bkmktype, minor))
{
config.writeEntry("Major", major);
config.writeEntry("BkmkType", bkmktype);
config.writeEntry("Minor", (int)minor);
}
// qDebug("finished update");
}
void QTReaderApp::addtoolbars(Config* config)
{
config->setGroup("Toolbar");
if (fileBar != NULL)
{
if (fileBar != menubar)
{
fileBar->clear();
}
else
{
m_preferences_action->removeFrom( filebar() );
m_open_action->removeFrom( filebar() );
m_close_action->removeFrom( filebar() );
m_info_action->removeFrom( filebar() );
m_touch_action->removeFrom( filebar() );
m_find_action->removeFrom( filebar() );
}
}
m_preferences_action->addTo( filebar() );
addfilebar(config, "Open", m_open_action);
addfilebar(config, "Close", m_close_action);
addfilebar(config, "Info", m_info_action);
addfilebar(config, "Two/One Touch", m_touch_action);
addfilebar(config, "Find", m_find_action);
if (navBar != NULL)
{
if ((navBar == fileBar) && (fileBar == menubar))
{
m_scrollButton->removeFrom( navbar() );
m_start_action->removeFrom( navbar() );
m_end_action->removeFrom( navbar() );
m_jump_action->removeFrom( navbar() );
m_pageline_action->removeFrom( navbar() );
m_pageup_action->removeFrom( navbar() );
m_pagedn_action->removeFrom( navbar() );
m_back_action->removeFrom( navbar() );
m_home_action->removeFrom( navbar() );
m_forward_action->removeFrom( navbar() );
}
else if (navBar != fileBar)
{
navBar->clear();
}
}
addnavbar(config, "Scroll", m_scrollButton);
addnavbar(config, "Goto Start", m_start_action);
addnavbar(config, "Goto End", m_end_action);
addnavbar(config, "Jump", m_jump_action);
addnavbar(config, "Page/Line Scroll", m_pageline_action);
addnavbar(config, "Page Up", m_pageup_action);
addnavbar(config, "Page Down", m_pagedn_action);
addnavbar(config, "Back", m_back_action);
addnavbar(config, "Home", m_home_action);
addnavbar(config, "Forward", m_forward_action);
if (viewBar != NULL)
{
if ((viewBar == fileBar) && (fileBar == menubar))
{
m_actFullscreen->removeFrom( filebar() );
m_zoomin_action->removeFrom( viewbar() );
m_zoomout_action->removeFrom( viewbar() );
m_setfont_action->removeFrom( viewbar() );
m_setenc_action->removeFrom( viewbar() );
m_setmono_action->removeFrom( viewbar() );
}
else if (viewBar != fileBar)
{
viewBar->clear();
}
}
addviewbar(config, "Fullscreen", m_actFullscreen);
addviewbar(config, "Zoom In", m_zoomin_action);
addviewbar(config, "Zoom Out", m_zoomout_action);
addviewbar(config, "Set Font", m_setfont_action);
addviewbar(config, "Encoding Select", m_setenc_action);
addviewbar(config, "Ideogram Mode", m_setmono_action);
if (markBar != NULL)
{
if ((markBar == fileBar) && (fileBar == menubar))
{
m_mark_action->removeFrom( markbar() );
m_annotate_action->removeFrom( markbar());
m_goto_action->removeFrom( markbar() );
m_delete_action->removeFrom( markbar() );
m_autogen_action->removeFrom( markbar() );
m_clear_action->removeFrom( markbar() );
m_save_action->removeFrom( markbar() );
m_tidy_action->removeFrom( markbar() );
m_startBlock_action->removeFrom( markbar() );
m_endBlock_action->removeFrom( markbar() );
}
else if (markBar != fileBar)
{
markBar->clear();
}
}
addmarkbar(config, "Mark", m_mark_action);
addmarkbar(config, "Annotate", m_annotate_action);
addmarkbar(config, "Goto", m_goto_action);
addmarkbar(config, "Delete", m_delete_action);
addmarkbar(config, "Autogen", m_autogen_action);
addmarkbar(config, "Clear", m_clear_action);
addmarkbar(config, "Save", m_save_action);
addmarkbar(config, "Tidy", m_tidy_action);
addmarkbar(config, "Start Block", m_startBlock_action);
addmarkbar(config, "Copy Block", m_endBlock_action);
if (checkbar(config, "Annotation indicator"))
{
if (m_bkmkAvail == NULL)
{
m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 );
connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
m_bkmkAvail->setEnabled(false);
}
QLabel *spacer = new QLabel(markBar, "");
markbar()->setStretchableWidget(spacer);
m_bkmkAvail->removeFrom( markbar() );
m_bkmkAvail->addTo( markbar() );
}
else
{
if (m_bkmkAvail != NULL)
{
m_bkmkAvail->removeFrom( markbar() );
delete m_bkmkAvail;
m_bkmkAvail = NULL;
}
}
}
bool QTReaderApp::checkbar(Config* _config, const QString& key)
{
return _config->readBoolEntry(key, false);
}
QToolBar* QTReaderApp::filebar()
{
if (fileBar == NULL)
{
switch (m_tbpol)
{
case cesSingle:
// qDebug("Setting filebar to menubar");
fileBar = menubar;
break;
default:
qDebug("Incorrect toolbar policy set");
case cesMenuTool:
case cesMultiple:
// qDebug("Creating new file bar");
fileBar = new QToolBar("File", this, m_tbposition);
break;
}
// fileBar->setHorizontalStretchable( true );
}
return fileBar;
}
QToolBar* QTReaderApp::viewbar()
{
if (viewBar == NULL)
{
switch (m_tbpol)
{
case cesMultiple:
viewBar = new QToolBar("View", this, m_tbposition);
break;
default:
qDebug("Incorrect toolbar policy set");
case cesSingle:
case cesMenuTool:
viewBar = fileBar;
break;
}
}
return viewBar;
}
QToolBar* QTReaderApp::navbar()
{
if (navBar == NULL)
{
switch (m_tbpol)
{
case cesMultiple:
// qDebug("Creating new nav bar");
navBar = new QToolBar("Navigation", this, m_tbposition);
break;
default:
qDebug("Incorrect toolbar policy set");
case cesSingle:
case cesMenuTool:
navBar = fileBar;
// qDebug("Setting navbar to filebar");
break;
}
}
return navBar;
}
QToolBar* QTReaderApp::markbar()
{
if (markBar == NULL)
{
switch (m_tbpol)
{
case cesMultiple:
markBar = new QToolBar("Marks", this, m_tbposition);
break;
default:
qDebug("Incorrect toolbar policy set");
case cesSingle:
case cesMenuTool:
markBar = fileBar;
break;
}
}
return markBar;
}
void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a)
{
if (_config->readBoolEntry(key, false)) a->addTo( filebar() );
}
void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a)
{
if (_config->readBoolEntry(key, false)) a->addTo( navbar() );
}
void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a)
{
if (_config->readBoolEntry(key, false)) a->addTo( markbar() );
}
void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a)
{
if (_config->readBoolEntry(key, false)) a->addTo( viewbar() );
}
void QTReaderApp::suspend() { reader->suspend(); }
#ifdef USEMSGS
void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
{
QString msg = QString::fromUtf8(_msg);
//// qDebug("Received:%s", (const char*)msg);
QDataStream stream( _data, IO_ReadOnly );
if ( msg == "info(QString)" )
{
QString info;
stream >> info;
QMessageBox::information(this, PROGNAME, info);
}
else if ( msg == "Update(int)" )
{
int info;
stream >> info;
if (info)
{
reader->bDoUpdates = true;
reader->refresh();
}
else
{
reader->bDoUpdates = false;
}
}
else if ( msg == "warn(QString)" )
{
QString info;
stream >> info;
QMessageBox::warning(this, PROGNAME, info);
}
else if ( msg == "exit()" )
{
m_dontSave = true;
close();
}
else if ( msg == "pageDown()" )
{
reader->dopagedn();
}
else if ( msg == "pageUp()" )
{
reader->dopageup();
}
else if ( msg == "lineDown()" )
{
reader->lineDown();
}
else if ( msg == "lineUp()" )
{
reader->lineUp();
}
else if ( msg == "showText()" )
{
showEditTools();
}
else if ( msg == "home()" )
{
reader->goHome();
}
else if ( msg == "back()" )
{
reader->goBack();
}
else if ( msg == "forward()" )
{
reader->goForward();
}
else if ( msg == "File/Open(QString)" )
{
QString info;
stream >> info;
openFile( info );
}
else if ( msg == "File/Info()" )
{
showinfo();
}
else if ( msg == "File/Action(QString)" )
{
QString info;
stream >> info;
m_spaceTarget = ActNameToInt(info);
}
else if ( msg == "Navigation/Scroll(int)" )
{
int info;
stream >> info;
autoScroll(info);
}
else if ( msg == "Navigation/GotoStart()" )
{
gotoStart();
}
else if ( msg == "Navigation/GotoEnd()" )
{
gotoEnd();
}
else if ( msg == "Navigation/Jump(int)" )
{
int info;
stream >> info;
reader->locate(info);
}
else if ( msg == "Navigation/Page/LineScroll(int)" )
{
int info;
stream >> info;
pagemode(info);
}
else if ( msg == "Navigation/SetOverlap(int)" )
{
int info;
stream >> info;
reader->m_overlap = info;
}
else if ( msg == "Navigation/SetMargin(int)" )
{
int info;
stream >> info;
do_margin(info);
}
else if ( msg == "File/SetDictionary(QString)" )
{
QString info;
stream >> info;
do_settarget(info);
}
#ifdef _SCROLLPIPE
else if ( msg == "File/SetScrollTarget(QString)" )
{
QString info;
stream >> info;
reader->m_pipetarget = info;
}
#endif
else if ( msg == "File/Two/OneTouch(int)" )
{
int info;
stream >> info;
setTwoTouch(info);
}
else if ( msg == "Target/Annotation(int)" )
{
int info;
stream >> info;
OnAnnotation(info);
}
else if ( msg == "Target/Dictionary(int)" )
{
int info;
stream >> info;
OnDictionary(info);
}
else if ( msg == "Target/Clipboard(int)" )
{
int info;
stream >> info;
OnClipboard(info);
}
else if ( msg == "File/Find(QString)" )
{
QString info;
stream >> info;
QRegExp arg(info);
size_t pos = reader->pagelocate();
size_t start = pos;
CDrawBuffer test(&(reader->m_fontControl));
reader->getline(&test);
while (arg.match(toQString(test.data())) == -1)
{
pos = reader->locate();
if (!reader->getline(&test))
{
QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
pos = start;
break;
}
}
reader->locate(pos);
}
else if ( msg == "File/Fullscreen(int)" )
{
int info;
stream >> info;
setfullscreen(info);
}
else if ( msg == "File/Continuous(int)" )
{
int info;
stream >> info;
setcontinuous(info);
}
else if ( msg == "Markup(QString)" )
{
QString info;
stream >> info;
if (info == "Auto")
{
autofmt(true);
}
if (info == "None")
{
autofmt(false);
textfmt(false);
striphtml(false);
peanut(false);
}
if (info == "Text")
{
textfmt(true);
}
if (info == "HTML")
{
striphtml(true);
}
if (info == "Peanut/PML")
{
peanut(true);
}
}
else if ( msg == "Layout/StripCR(int)" )
{
int info;
stream >> info;
stripcr(info);
}
else if ( msg == "Layout/Dehyphen(int)" )
{
int info;
stream >> info;
dehyphen(info);
}
else if ( msg == "Layout/Depluck(int)" )
{
int info;
stream >> info;
depluck(info);
}
else if ( msg == "Layout/Dejpluck(int)" )
{
int info;
stream >> info;
dejpluck(info);
}
else if ( msg == "Layout/SingleSpace(int)" )
{
int info;
stream >> info;
onespace(info);
}
#ifdef REPALM
else if ( msg == "Layout/Repalm(int)" )
{
int info;
stream >> info;
repalm(info);
}
#endif
else if ( msg == "Layout/Unindent(int)" )
{
int info;
stream >> info;
unindent(info);
}
else if ( msg == "Layout/Re-paragraph(int)" )
{
int info;
stream >> info;
repara(info);
}
else if ( msg == "Layout/DoubleSpace(int)" )
{
int info;
stream >> info;
dblspce(info);
}
else if ( msg == "Layout/Indent(int)" )
{
int info;
stream >> info;
reader->bindenter = info;
reader->setfilter(reader->getfilter());
}
else if ( msg == "Layout/Remap(int)" )
{
int info;
stream >> info;
remap(info);
}
else if ( msg == "Layout/Embolden(int)" )
{
int info;
stream >> info;
embolden(info);
}
else if ( msg == "Format/Ideogram/Word(int)" )
{
int info;
stream >> info;
monospace(info);
}
else if ( msg == "Format/SetWidth(int)" )
{
int info;
stream >> info;
reader->m_charpc = info;
reader->setfont();
reader->refresh();
}
else if ( msg == "Format/SetFont(QString,int)" )
{
QString fontname;
int size;
stream >> fontname;
stream >> size;
setfontHelper(fontname, size);
}
else if ( msg == "Marks/Autogen(QString)" )
{
QString info;
stream >> info;
do_autogen(info);
}
else if ( msg == "File/StartBlock()" )
{
editMark();
}
else if ( msg == "File/CopyBlock()" )
{
editCopy();
}
}
#endif
ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
{
for (int i = 0; i < MAX_ACTIONS; i++)
{
if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i;
}
return cesAutoScroll;
}
void QTReaderApp::setfullscreen(bool sfs)
{
reader->bDoUpdates = false;
m_fullscreen = sfs;
showEditTools();
// qApp->processEvents();
reader->bDoUpdates = true;
reader->update();
}
void QTReaderApp::buttonActionSelected(QAction* _a)
{
//// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
m_spaceTarget = ActNameToInt(_a->text());
}
QTReaderApp::~QTReaderApp()
{
}
void QTReaderApp::autoScroll(bool _b)
{
reader->setautoscroll(_b);
setScrollState(reader->m_autoScroll);
}
void QTReaderApp::zoomin()
{
reader->zoomin();
}
void QTReaderApp::zoomout()
{
reader->zoomout();
}
void QTReaderApp::clearBkmkList()
{
delete pBkmklist;
pBkmklist = NULL;
m_fBkmksChanged = false;
}
void QTReaderApp::fileClose()
{
CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this);
if (cd->exec())
{
if (pOpenlist != NULL)
{
int ind = 0;
Bkmk* p = (*pOpenlist)[ind];
while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
{
p = (*pOpenlist)[++ind];
}
if (p != NULL) pOpenlist->erase(ind);
if (cd->delFile())
{
unlink((const char*)reader->m_lastfile);
}
if (cd->delMarks())
{
#ifndef USEQPE
QDir d = QDir::home(); // "/"
d.cd(APPDIR);
d.remove(reader->m_string);
#else /* USEQPE */
unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
#endif /* USEQPE */
}
if (cd->delConfig())
{
#ifndef USEQPE
QDir d = QDir::home(); // "/"
d.cd(APPDIR "/configs");
d.remove(reader->m_string);
#else /* USEQPE */
unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string));
#endif /* USEQPE */
}
}
fileOpen2();
}
delete cd;
}
void QTReaderApp::updatefileinfo()
{
if (reader->m_string.isEmpty()) return;
if (reader->m_lastfile.isEmpty()) return;
tchar* nm = fromQString(reader->m_string);
tchar* fl = fromQString(reader->m_lastfile);
// qDebug("Lastfile:%x", fl);
bool notadded = true;
if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
else
{
for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
{
if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0)
{
iter->value(reader->pagelocate());
unsigned short dlen;
unsigned char* data;
CFiledata fd(iter->anno());
reader->setSaveData(data, dlen, fd.content(), fd.length());
// qDebug("Filedata(1):%u, %u", fd.length(), dlen);
// getstate(data, dlen);
iter->setAnno(data, dlen);
notadded = false;
delete [] data;
break;
}
}
}
// qDebug("Added?:%x", notadded);
if (notadded)
{
struct stat fnstat;
stat((const char *)reader->m_lastfile, &fnstat);
CFiledata fd(fnstat.st_mtime, fl);
unsigned short dlen;
unsigned char* data;
reader->setSaveData(data, dlen, fd.content(), fd.length());
pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate()));
// qDebug("Filedata(2):%u, %u", fd.length(), dlen);
delete [] data;
}
delete [] nm;
delete [] fl;
}
void QTReaderApp::fileOpen()
{
/*
menu->hide();
fileBar->hide();
if (regVisible) regBar->hide();
if (searchVisible) searchBar->hide();
*/
// qDebug("fileOpen");
// if (!reader->m_lastfile.isEmpty())
updatefileinfo();
fileOpen2();
}
void QTReaderApp::fileOpen2()
{
if (pBkmklist != NULL)
{
if (m_fBkmksChanged)
{
if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
savebkmks();
}
delete pBkmklist;
pBkmklist = NULL;
m_fBkmksChanged = false;
}
reader->disableAutoscroll();
/*
editorStack->raiseWidget( fileSelector );
fileSelector->reread();
*/
bool usebrowser = true;
if (pOpenlist != NULL)
{
m_nBkmkAction = cOpenFile;
if (listbkmk(pOpenlist, "Browse")) usebrowser = false;
}
if (usebrowser)
{
QString fn = usefilebrowser();
// qApp->processEvents();
if (!fn.isEmpty() && QFileInfo(fn).isFile())
{
openFile(fn);
}
reader->setFocus();
}
// reader->refresh();
// qDebug("HEIGHT:%d", reader->m_lastheight);
}
QString QTReaderApp::usefilebrowser()
{
#ifndef USEQPE
QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) );
return s;
#else
fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog,
0,
// WStyle_Customize | WStyle_NoBorderEx,
"*", QFileInfo(reader->m_lastfile).dirPath(true));
QString fn;
if (fb->exec())
{
fn = fb->getCurrentFile();
}
// qDebug("Selected %s", (const char*)fn);
delete fb;
showEditTools();
return fn;
#endif
}
void QTReaderApp::showgraphic(QImage& pm)
{
QPixmap pc;
pc.convertFromImage(pm);
m_graphicwin->setPixmap(pc);
editorStack->raiseWidget( m_graphicwin );
m_graphicwin->setFocus();
}
void QTReaderApp::showprefs()
{
CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this);
prefwin->twotouch(m_twoTouch);
prefwin->propfontchange(m_propogatefontchange);
prefwin->StripCR(reader->bstripcr);
prefwin->Dehyphen(reader->bdehyphen);
prefwin->SingleSpace(reader->bonespace);
prefwin->Unindent(reader->bunindent);
prefwin->Reparagraph(reader->brepara);
prefwin->DoubleSpace(reader->bdblspce);
prefwin->Remap(reader->bremap);
prefwin->Embolden(reader->bmakebold);
prefwin->FullJustify(reader->bfulljust);
prefwin->ParaLead(reader->getextraspace());
prefwin->LineLead(reader->getlead());
prefwin->Margin(reader->m_border);
prefwin->Indent(reader->bindenter);
if (reader->bautofmt)
{
prefwin->Markup(0);
}
else if (reader->btextfmt)
{
prefwin->Markup(2);
}
else if (reader->bstriphtml)
{
prefwin->Markup(3);
}
else if (reader->bpeanut)
{
prefwin->Markup(4);
}
else
{
prefwin->Markup(1);
}
prefwin->Depluck(reader->bdepluck);
prefwin->Dejpluck(reader->bdejpluck);
prefwin->Continuous(reader->m_continuousDocument);
prefwin->dictApplication(m_targetapp);
prefwin->dictMessage(m_targetmsg);
prefwin->spaceAction(m_spaceTarget);
prefwin->escapeAction(m_escapeTarget);
prefwin->returnAction(m_returnTarget);
prefwin->leftAction(m_leftTarget);
prefwin->rightAction(m_rightTarget);
prefwin->upAction(m_upTarget);
prefwin->downAction(m_downTarget);
prefwin->leftScroll(m_leftScroll);
prefwin->rightScroll(m_rightScroll);
prefwin->upScroll(m_upScroll);
prefwin->downScroll(m_downScroll);
prefwin->miscannotation(m_doAnnotation);
prefwin->miscdictionary(m_doDictionary);
prefwin->miscclipboard(m_doClipboard);
prefwin->SwapMouse(reader->m_swapmouse);
prefwin->Font(reader->m_fontname);
prefwin->gfxsize(reader->getBaseSize());
prefwin->pageoverlap(reader->m_overlap);
prefwin->ideogram(reader->m_bMonoSpaced);
prefwin->encoding(reader->m_encd);
prefwin->ideogramwidth(reader->m_charpc);
if (prefwin->exec())
{
m_twoTouch = prefwin->twotouch();
reader->setTwoTouch(m_twoTouch);
m_touch_action->setOn(m_twoTouch);
reader->bstripcr = prefwin->StripCR();
reader->bdehyphen = prefwin->Dehyphen();
reader->bonespace = prefwin->SingleSpace();
reader->bunindent = prefwin->Unindent();
reader->brepara = prefwin->Reparagraph();
reader->bdblspce = prefwin->DoubleSpace();
reader->bremap = prefwin->Remap();
reader->bmakebold = prefwin->Embolden();
reader->bfulljust = prefwin->FullJustify();
reader->setextraspace(prefwin->ParaLead());
reader->setlead(prefwin->LineLead());
reader->m_border = prefwin->Margin();
reader->bindenter = prefwin->Indent();
reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false;
switch (prefwin->Markup())
{
case 0:
reader->bautofmt = true;
break;
case 1:
break;
case 2:
reader->btextfmt = true;
break;
case 3:
reader->bstriphtml = true;
break;
case 4:
reader->bpeanut = true;
break;
default:
qDebug("Format out of range");
}
reader->bdepluck = prefwin->Depluck();
reader->bdejpluck = prefwin->Dejpluck();
reader->setContinuous(prefwin->Continuous());
m_spaceTarget = (ActionTypes)prefwin->spaceAction();
m_escapeTarget = (ActionTypes)prefwin->escapeAction();
m_returnTarget = (ActionTypes)prefwin->returnAction();
m_leftTarget = (ActionTypes)prefwin->leftAction();
m_rightTarget = (ActionTypes)prefwin->rightAction();
m_upTarget = (ActionTypes)prefwin->upAction();
m_downTarget = (ActionTypes)prefwin->downAction();
m_leftScroll = prefwin->leftScroll();
m_rightScroll = prefwin->rightScroll();
m_upScroll = prefwin->upScroll();
m_downScroll = prefwin->downScroll();
m_targetapp = prefwin->dictApplication();
m_targetmsg = prefwin->dictMessage();
m_doAnnotation = prefwin->miscannotation();
m_doDictionary = prefwin->miscdictionary();
m_doClipboard = prefwin->miscclipboard();
reader->m_swapmouse = prefwin->SwapMouse();
reader->setBaseSize(prefwin->gfxsize());
reader->m_overlap = prefwin->pageoverlap();
reader->m_bMonoSpaced = prefwin->ideogram();
m_setmono_action->setOn(reader->m_bMonoSpaced);
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;
}
struct stat fnstat;
struct stat bkstat;
#ifndef USEQPE
QDir d = QDir::home(); // "/"
d.cd(APPDIR);
QFileInfo fi(d, reader->m_string);
#endif /* ! USEQPE */
if (
stat((const char *)reader->m_lastfile, &fnstat) == 0
&&
#ifndef USEQPE
stat((const char *)fi.absFilePath(), &bkstat) == 0
#else /* USEQPE */
stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0
#endif /* USEQPE */
)
{
if (bkstat.st_mtime < fnstat.st_mtime)
{
#ifndef USEQPE
unlink((const char *)fi.absFilePath());
#else /* USEQPE */
unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string));
#endif /* USEQPE */
}
}
#ifndef USEQPE
BkmkFile bf((const char *)fi.absFilePath());
#else /* USEQPE */
BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string));
#endif /* USEQPE */
pBkmklist = bf.readall();
m_fBkmksChanged = bf.upgraded();
if (pBkmklist == NULL)
{
pBkmklist = reader->getbkmklist();
}
if (pBkmklist != NULL)
pBkmklist->sort();
}
void QTReaderApp::addbkmk()
{
m_nRegAction = cAddBkmk;
regEdit->setText(reader->firstword());
do_regedit();
}
void QTReaderApp::do_addbkmk(const QString& text)
{
if (text.isEmpty())
{
QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1);
}
else
{
if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
#ifdef _UNICODE
CBuffer buff;
int i = 0;
for (i = 0; i < text.length(); i++)
{
buff[i] = text[i].unicode();
}
buff[i] = 0;
pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate()));
#else
pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate()));
#endif
m_fBkmksChanged = true;
pBkmklist->sort();
}
}
void QTReaderApp::OnRedraw()
{
if ((pBkmklist != NULL) && (m_bkmkAvail != NULL))
{
bool found = findNextBookmark(reader->pagelocate());
m_bkmkAvail->setEnabled(found);
}
}
void QTReaderApp::showAnnotation()
{
m_annoWin->setName(toQString(m_anno->name()));
m_annoWin->setAnno(toQString(m_anno->anno()));
m_annoIsEditing = false;
#ifdef USEQPE
Global::showInputMethod();
#endif
editorStack->raiseWidget( m_annoWin );
m_annoWin->setFocus();
}
void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line)
{
//// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
if (m_doClipboard)
{
QClipboard* cb = QApplication::clipboard();
cb->setText(wrd);
#ifdef USEQPE
if (wrd.length() > 10)
{
Global::statusMessage(wrd.left(8) + "..");
}
else
{
Global::statusMessage(wrd);
}
#endif
}
if (m_doAnnotation)
{
// addAnno(wrd, "Need to be able to edit this", posn);
m_annoWin->setName(line);
m_annoWin->setAnno("");
m_annoWin->setPosn(posn);
m_annoIsEditing = true;
#ifdef USEQPE
Global::showInputMethod();
#endif
editorStack->raiseWidget( m_annoWin );
}
#ifdef USEQPE
if (m_doDictionary)
{
if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
{
QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8());
e << wrd;
}
}
#endif
}
void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e)
{
if (a == 0)
{
e->ignore();
}
else
{
e->accept();
// qDebug("Accepted");
switch (a)
{
case cesOpenFile:
{
fileOpen();
}
break;
case cesAutoScroll:
{
reader->setautoscroll(!reader->m_autoScroll);
setScrollState(reader->m_autoScroll);
}
break;
case cesActionMark:
{
addbkmk();
}
break;
case cesFullScreen:
{
m_actFullscreen->setOn(!m_fullscreen);
}
break;
case cesActionAnno:
{
addanno();
}
break;
case cesZoomIn:
zoomin();
break;
case cesZoomOut:
zoomout();
break;
case cesBack:
reader->goBack();
break;
case cesForward:
reader->goForward();
break;
case cesHome:
reader->goHome();
break;
case cesPageUp:
reader->dopageup();
break;
case cesPageDown:
reader->dopagedn();
break;
case cesLineUp:
reader->lineUp();
break;
case cesLineDown:
reader->lineDown();
break;
case cesStartDoc:
gotoStart();
break;
case cesEndDoc:
gotoEnd();
break;
default:
qDebug("Unknown ActionType:%u", a);
break;
}
}
}
void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
void QTReaderApp::restoreFocus() { reader->setFocus(); }
void QTReaderApp::SaveConfig()
{
m_nRegAction = cSetConfigName;
regEdit->setText(reader->m_string);
do_regedit();
}
void QTReaderApp::do_saveconfig(const QString& _txt, bool full)
{
// qDebug("do_saveconfig:%s", (const char*)_txt);
#ifdef USEQPE
QString configname;
Config::Domain dom;
if (full)
{
configname = _txt;
dom = Config::User;
}
else
{
configname = Global::applicationFileName(APPDIR "/configs", _txt);
dom = Config::File;
}
Config config(configname, dom);
config.setGroup( "View" );
#else
QFileInfo fi;
if (full)
{
// qDebug("full:%s", (const char*)_txt);
QDir d = QDir::home(); // "/"
if ( !d.cd(_txt) )
{ // "/tmp"
qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt );
d = QDir::home();
d.mkdir(_txt);
d.cd(_txt);
}
fi.setFile(d, INIFILE);
}
else
{
QDir d = QDir::home(); // "/"
if ( !d.cd(APPDIR) )
{ // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
d = QDir::home();
d.mkdir(APPDIR);
d.cd(APPDIR);
}
if ( !d.cd("configs") )
{ // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" );
d = QDir::home();
d.cd(APPDIR);
d.mkdir("configs");
d.cd("configs");
}
fi.setFile(d, _txt);
}
// qDebug("Path:%s", (const char*)fi.absFilePath());
Config config(fi.absFilePath());
#endif
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);
if (full)
{
config.writeEntry("Debounce", m_debounce);
config.writeEntry("FloatDialogs", m_bFloatingDialog);
reader->m_lastposn = reader->pagelocate();
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);
if (full)
{
config.setGroup( "Toolbar" );
config.writeEntry("Movable", m_tbmovesave);
config.writeEntry("Policy", m_tbpolsave);
config.writeEntry("Position", m_tbposition);
#ifndef USEQPE
config.setGroup( "Geometry" );
config.writeEntry( "x", x() );
config.writeEntry( "y", y() );
config.writeEntry( "width", width() );
config.writeEntry( "height", height() );
#endif
}
}
/*
void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen)
{
unsigned short sdlen;
memcpy(&sdlen, _sd, sizeof(sdlen));
sdlen -= sizeof(sdlen);
_sd += sizeof(sdlen);
statedata* sd;
char* data;
if (sdlen < sizeof(statedata)+1)
{
sdlen = sizeof(statedata)+1;
}
data = new char[sdlen];
sd = (statedata*)data;
memcpy(sd, _sd, sdlen);
data[sdlen] = 0;
reader->setstate(*sd);
delete [] data;
}
void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
{
unsigned char* olddata = data;
unsigned short oldlen = len;
len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length();
data = new unsigned char[len];
memcpy(data, olddata, oldlen);
delete [] olddata;
memcpy(data+oldlen, &len, sizeof(len));
statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short));
sd->bstripcr = reader->bstripcr;
sd->btextfmt = reader->btextfmt;
sd->bautofmt = reader->bautofmt;
sd->bstriphtml = reader->bstriphtml;
sd->bpeanut = reader->bpeanut;
sd->bdehyphen = reader->bdehyphen;
sd->bdepluck = reader->bdepluck;
sd->bdejpluck = reader->bdejpluck;
sd->bonespace = reader->bonespace;
sd->bunindent = reader->bunindent;
sd->brepara = reader->brepara;
sd->bdblspce = reader->bdblspce;
sd->m_bpagemode = reader->m_bpagemode;
sd->m_bMonoSpaced = reader->m_bMonoSpaced;
sd->bremap = reader->bremap;
sd->bmakebold = reader->bmakebold;
sd->Continuous = reader->m_continuousDocument;
#ifdef REPALM
sd->brepalm = reader->brepalm;
#endif
sd->bindenter = reader->bindenter;
sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize()
sd->m_encd = reader->m_encd;
sd->m_charpc = reader->m_charpc;
strcpy(sd->m_fontname, reader->m_fontname.latin1());
}
*/
#ifdef _SCRIPT
void QTReaderApp::RunScript()
{
fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog,
0,
// WStyle_Customize | WStyle_NoBorderEx,
"*", Global::applicationFileName(APPDIR "/scripts", ""));
QString fn;
if (fb->exec())
{
fn = fb->fileList[0];
}
delete fb;
if ( !fn.isEmpty() && fork() == 0 )
{
execlp((const char *)fn,(const char *)fn,NULL);
}
}
void QTReaderApp::SaveScript(const char* sname)
{
FILE* f = fopen(sname,"w");
if (f != NULL)
{
#ifdef OPIE
fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n");
#else
fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n");
#endif
fprintf(f, "msg \"Update(int)\" 0\n");
fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0);
if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n");
else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n");
else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n");
else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n");
else fprintf(f, "msg \"Markup(QString)\" \"None\"\n");
fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0);
fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0);
fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0);
fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0);
fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0);
fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0);
fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0);
fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter);
fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize);
fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0);
fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0);
fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text());
fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc);
fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap);
fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0);
fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0);
fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0);
fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg);
#ifdef _SCROLLPIPE
fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget);
#endif
fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0);
fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0);
fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0);
fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0);
fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text());
fprintf(f, "msg \"Update(int)\" 1\n");
fprintf(f, "msg \"info(QString)\" \"All Done\"\n");
fclose(f);
chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH);
}
}
void QTReaderApp::SaveConfig()
{
m_nRegAction = cSetConfigName;
regEdit->setText("");
do_regedit();
}
void QTReaderApp::do_saveconfig(const QString& _txt)
{
SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt));
}
#endif
#ifdef _SCROLLPIPE
void QTReaderApp::setpipetarget()
{
m_nRegAction = cSetPipeTarget;
QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget;
regEdit->setText(text);
do_regedit();
}
void QTReaderApp::do_setpipetarget(const QString& _txt)
{
reader->m_pipetarget = _txt;
}
void QTReaderApp::setpause(bool sfs)
{
reader->m_pauseAfterEachPara = sfs;
}
#endif
void QTReaderApp::monospace(bool _b)
{
reader->setmono(_b);
}
bool QTReaderApp::readconfig(const QString& _txt, bool full=false)
{
#ifdef USEQPE
QString configname;
Config::Domain dom;
if (full)
{
configname = _txt;
dom = Config::User;
}
else
{
configname = Global::applicationFileName(APPDIR "/configs", _txt);
QFileInfo fm(configname);
if ( !fm.exists() ) return false;
dom = Config::File;
}
Config config(configname, dom);
config.setGroup( "View" );
#else
QFileInfo fi;
if (full)
{
QDir d = QDir::home(); // "/"
if ( !d.cd(_txt) )
{ // "/tmp"
qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt );
d = QDir::home();
d.mkdir(_txt);
d.cd(_txt);
}
fi.setFile(d, INIFILE);
}
else
{
QDir d = QDir::home(); // "/"
if ( !d.cd(APPDIR) )
{ // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
d = QDir::home();
d.mkdir(APPDIR);
d.cd(APPDIR);
}
if ( !d.cd("configs") )
{ // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" );
d = QDir::home();
d.mkdir("configs");
d.cd("configs");
}
fi.setFile(d, _txt);
}
#ifdef _WINDOWS
struct stat fnstat;
if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows
#else
if (!fi.exists()) return false;
#endif
Config config(fi.absFilePath());
#endif
if (full)
{
config.setGroup("Toolbar");
m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
}
config.setGroup( "View" );
m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
reader->bstripcr = config.readBoolEntry( "StripCr", true );
reader->bfulljust = config.readBoolEntry( "FullJust", false );
reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
reader->btextfmt = config.readBoolEntry( "TextFmt", false );
reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
reader->bpeanut = config.readBoolEntry( "Peanut", false );
reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
reader->bdepluck = config.readBoolEntry( "Depluck", false );
reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
reader->bonespace = config.readBoolEntry( "OneSpace", false );
reader->bunindent = config.readBoolEntry( "Unindent", false );
reader->brepara = config.readBoolEntry( "Repara", false );
reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
reader->bindenter = config.readNumEntry( "Indent", 0 );
reader->m_textsize = config.readNumEntry( "FontSize", 12 );
reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
if (full)
{
reader->m_lastfile = config.readEntry( "LastFile", QString::null );
reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
}
reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
reader->m_encd = config.readNumEntry( "Encoding", 0 );
reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
reader->m_overlap = config.readNumEntry( "Overlap", 0 );
reader->m_border = config.readNumEntry( "Margin", 6 );
#ifdef REPALM
reader->brepalm = config.readBoolEntry( "Repalm", true );
#endif
reader->bremap = config.readBoolEntry( "Remap", true );
reader->bmakebold = config.readBoolEntry( "MakeBold", false );
reader->setContinuous(config.readBoolEntry( "Continuous", true ));
m_targetapp = config.readEntry( "TargetApp", QString::null );
m_targetmsg = config.readEntry( "TargetMsg", QString::null );
#ifdef _SCROLLPIPE
reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
#endif
m_twoTouch = config.readBoolEntry( "TwoTouch", false);
m_doAnnotation = config.readBoolEntry( "Annotation", false);
m_doDictionary = config.readBoolEntry( "Dictionary", false);
m_doClipboard = config.readBoolEntry( "Clipboard", false);
m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
m_leftScroll = config.readBoolEntry("LeftScroll", false);
m_rightScroll = config.readBoolEntry("RightScroll", false);
m_upScroll = config.readBoolEntry("UpScroll", true);
m_downScroll = config.readBoolEntry("DownScroll", true);
m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
reader->setTwoTouch(m_twoTouch);
m_touch_action->setOn(m_twoTouch);
m_setmono_action->setOn(reader->m_bMonoSpaced);
setfontHelper(reader->m_fontname);
if (full)
{
addtoolbars(&config);
}
reader->setfilter(reader->getfilter());
reader->refresh();
return true;
}
bool QTReaderApp::PopulateConfig(const char* tgtdir)
{
bkmkselector->clear();
bkmkselector->setText("Cancel");
#ifndef USEQPE
int cnt = 0;
QDir d = QDir::home(); // "/"
if ( !d.cd(APPDIR) ) { // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
d = QDir::home();
d.mkdir(APPDIR);
d.cd(APPDIR);
}
if ( !d.cd(tgtdir) ) { // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir );
d = QDir::home();
d.mkdir(tgtdir);
d.cd(tgtdir);
}
d.setFilter( QDir::Files | QDir::NoSymLinks );
// d.setSorting( QDir::Size | QDir::Reversed );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
while ( (fi=it.current()) ) { // for each file...
bkmkselector->insertItem(fi->fileName());
cnt++;
//qDebug( "%10li %s", fi->size(), fi->fileName().data() );
++it; // goto next list element
}
#else /* USEQPE */
int cnt = 0;
DIR *d;
char* finaldir;
finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1];
strcpy(finaldir, APPDIR);
strcat(finaldir, "/");
strcat(finaldir, tgtdir);
d = opendir((const char *)Global::applicationFileName(finaldir,""));
while(1)
{
struct dirent* de;
struct stat buf;
de = readdir(d);
if (de == NULL) break;
if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
{
bkmkselector->insertItem(de->d_name);
cnt++;
}
}
delete [] finaldir;
closedir(d);
#endif
return (cnt > 0);
}
void QTReaderApp::LoadConfig()
{
if (PopulateConfig("configs"))
{
editorStack->raiseWidget( bkmkselector );
hidetoolbars();
m_nBkmkAction = cLdConfig;
}
else
QMessageBox::information(this, PROGNAME, "No config files");
}
void QTReaderApp::TidyConfig()
{
if (PopulateConfig("configs"))
{
editorStack->raiseWidget( bkmkselector );
hidetoolbars();
m_nBkmkAction = cRmConfig;
}
else
QMessageBox::information(this, PROGNAME, "No config files");
}
void QTReaderApp::ExportLinks()
{
if (PopulateConfig("urls"))
{
editorStack->raiseWidget( bkmkselector );
hidetoolbars();
m_nBkmkAction = cExportLinks;
}
else
QMessageBox::information(this, PROGNAME, "No url files");
}
void QTReaderApp::OnURLSelected(const QString& href)
{
CURLDialog* urld = new CURLDialog(href, false, this);
urld->clipboard(m_url_clipboard);
urld->localfile(m_url_localfile);
urld->globalfile(m_url_globalfile);
if (urld->exec())
{
m_url_clipboard = urld->clipboard();
m_url_localfile = urld->localfile();
m_url_globalfile = urld->globalfile();
if (m_url_clipboard)
{
QClipboard* cb = QApplication::clipboard();
cb->setText(href);
qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href);
}
if (m_url_localfile)
{
writeUrl(reader->m_string, href);
}
if (m_url_globalfile)
{
writeUrl("GlobalURLFile", href);
}
}
delete urld;
}
void QTReaderApp::writeUrl(const QString& file, const QString& href)
{
QString filename;
#ifdef USEQPE
filename = Global::applicationFileName(APPDIR "/urls", file);
#else
QFileInfo fi;
QDir d = QDir::home(); // "/"
if ( !d.cd(APPDIR) )
{ // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
d = QDir::home();
d.mkdir(APPDIR);
d.cd(APPDIR);
}
if ( !d.cd("urls") )
{ // "/tmp"
qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" );
d = QDir::home();
d.cd(APPDIR);
d.mkdir("urls");
d.cd("urls");
}
fi.setFile(d, file);
filename = fi.absFilePath();
#endif
FILE* fout = fopen(filename, "a");
if (fout != NULL)
{
fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href);
fclose(fout);
}
else
{
QMessageBox::warning(this, PROGNAME, "Problem with writing URL");
}
}
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 \
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
SOURCES = microkde/kapplication.cpp \
microkde/kdialogbase.cpp \
kateconfig.cpp \
microkde/klocale.cpp \
microkde/kmessagebox.cpp \
microkde/kprocess.cpp \
microkde/kstandarddirs.cpp \
microkde/ktempfile.cpp \
microkde/kurlrequester.cpp \
+ microkde/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
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
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 )
: 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
@@ -1,2925 +1,2923 @@
/***************************************************************************
kateview.cpp - description
-------------------
begin : Mon Jan 15 2001
copyright : (C) 2001 by Christoph "Crossfire" Cullmann
(C) 2002 by Joseph Wenninger
email : crossfire@babylon2k.de
jowenn@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/*
Copyright (C) 1998, 1999 Jochen Wilhelmy
digisnap@cs.tu-berlin.de
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kateview.h"
#include "../document/katedocument.h"
#include "../document/katecmd.h"
#include "../document/katehighlight.h"
#include "kateviewdialog.h"
#include "../document/katedialogs.h"
#include <kateconfig.h>
#include <qfocusdata.h>
#include <kdebug.h>
#include <kapplication.h>
#include <qscrollbar.h>
#include <qiodevice.h>
#include <qpopupmenu.h>
#include <kpopupmenu.h>
#include <qkeycode.h>
#include <qintdict.h>
#include <qfont.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qfileinfo.h>
#include <qfile.h>
#include <qevent.h>
#include <qdir.h>
#include <qvbox.h>
#include <qprintdialog.h>
#include <qpaintdevicemetrics.h>
#include <qiodevice.h>
#include <qbuffer.h>
#include <qfocusdata.h>
#include <klocale.h>
#include <kglobal.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <qregexp.h>
#include <kdialogbase.h>
#include <klineeditdlg.h>
#include <qapplication.h>
#include <kfiledialog.h>
#include <kiconloader.h>
#include "../document/katetextline.h"
#include "kateviewdialog.h"
#include "kateundohistory.h"
#include <qlayout.h>
KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view)
{
waitForPreHighlight=-1;
myView = view;
myDoc = doc;
iconBorderWidth = 16;
iconBorderHeight = 800;
QWidget::setCursor(ibeamCursor);
setBackgroundMode(NoBackground);
setFocusPolicy(StrongFocus);
xScroll = new QScrollBar(QScrollBar::Horizontal,myView);
yScroll = new QScrollBar(QScrollBar::Vertical,myView);
connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int)));
connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int)));
connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int)));
connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long)));
xPos = 0;
yPos = 0;
scrollTimer = 0;
cursor.x = 0;
cursor.y = 0;
cursorOn = false;
cursorTimer = 0;
cXPos = 0;
cOldXPos = 0;
startLine = 0;
endLine = -1;
exposeCursor = false;
updateState = 0;
numLines = 0;
lineRanges = 0L;
newXPos = -1;
newYPos = -1;
drawBuffer = new QPixmap ();
drawBuffer->setOptimization (QPixmap::BestOptim);
bm.sXPos = 0;
bm.eXPos = -1;
}
KateViewInternal::~KateViewInternal()
{
delete [] lineRanges;
delete drawBuffer;
}
void KateViewInternal::slotPreHighlightUpdate(long line)
{
//kdDebug()<<QString("slotPreHighlightUpdate - Wait for: %1, line: %2").arg(waitForPreHighlight).arg(line)<<endl;
if (waitForPreHighlight!=-1)
{
if (line>=waitForPreHighlight)
{
waitForPreHighlight=-1;
repaint();
}
}
}
void KateViewInternal::doCursorCommand(VConfig &c, int cmdNum) {
switch (cmdNum) {
case KateView::cmLeft:
cursorLeft(c);
break;
case KateView::cmRight:
cursorRight(c);
break;
case KateView::cmWordLeft:
wordLeft(c);
break;
case KateView::cmWordRight:
wordRight(c);
break;
case KateView::cmHome:
home(c);
break;
case KateView::cmEnd:
end(c);
break;
case KateView::cmUp:
cursorUp(c);
break;
case KateView::cmDown:
cursorDown(c);
break;
case KateView::cmScrollUp:
scrollUp(c);
break;
case KateView::cmScrollDown:
scrollDown(c);
break;
case KateView::cmTopOfView:
topOfView(c);
break;
case KateView::cmBottomOfView:
bottomOfView(c);
break;
case KateView::cmPageUp:
pageUp(c);
break;
case KateView::cmPageDown:
pageDown(c);
break;
case KateView::cmTop:
top_home(c);
break;
case KateView::cmBottom:
bottom_end(c);
break;
}
}
void KateViewInternal::doEditCommand(VConfig &c, int cmdNum) {
switch (cmdNum) {
case KateView::cmCopy:
myDoc->copy(c.flags);
return;
case KateView::cmSelectAll:
myDoc->selectAll();
return;
case KateView::cmDeselectAll:
myDoc->deselectAll();
return;
case KateView::cmInvertSelection:
myDoc->invertSelection();
return;
}
if (myView->isReadOnly()) return;
switch (cmdNum) {
case KateView::cmReturn:
if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c);
myDoc->newLine(c);
//emit returnPressed();
//e->ignore();
return;
case KateView::cmDelete:
if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText())
myDoc->delMarkedText(c);
else myDoc->del(c);
return;
case KateView::cmBackspace:
if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText())
myDoc->delMarkedText(c);
else myDoc->backspace(c);
return;
case KateView::cmKillLine:
myDoc->killLine(c);
return;
case KateView::cmCut:
myDoc->cut(c);
return;
case KateView::cmPaste:
if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c);
myDoc->paste(c);
return;
case KateView::cmUndo:
myDoc->undo(c);
return;
case KateView::cmRedo:
myDoc->redo(c);
return;
case KateView::cmIndent:
myDoc->indent(c);
return;
case KateView::cmUnindent:
myDoc->unIndent(c);
return;
case KateView::cmCleanIndent:
myDoc->cleanIndent(c);
return;
case KateView::cmComment:
myDoc->comment(c);
return;
case KateView::cmUncomment:
myDoc->unComment(c);
return;
}
}
void KateViewInternal::cursorLeft(VConfig &c) {
cursor.x--;
if (c.flags & KateView::cfWrapCursor && cursor.x < 0 && cursor.y > 0) {
cursor.y--;
cursor.x = myDoc->textLength(cursor.y);
}
cOldXPos = cXPos = myDoc->textWidth(cursor);
changeState(c);
}
void KateViewInternal::cursorRight(VConfig &c) {
if (c.flags & KateView::cfWrapCursor) {
if (cursor.x >= myDoc->textLength(cursor.y)) {
if (cursor.y == myDoc->lastLine()) return;
cursor.y++;
cursor.x = -1;
}
}
cursor.x++;
cOldXPos = cXPos = myDoc->textWidth(cursor);
changeState(c);
}
void KateViewInternal::wordLeft(VConfig &c) {
Highlight *highlight;
highlight = myDoc->highlight();
TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
if (cursor.x > 0) {
do {
cursor.x--;
} while (cursor.x > 0 && !highlight->isInWord(textLine->getChar(cursor.x)));
while (cursor.x > 0 && highlight->isInWord(textLine->getChar(cursor.x -1)))
cursor.x--;
} else {
if (cursor.y > 0) {
cursor.y--;
textLine = myDoc->getTextLine(cursor.y);
cursor.x = textLine->length();
}
}
cOldXPos = cXPos = myDoc->textWidth(cursor);
changeState(c);
}
void KateViewInternal::wordRight(VConfig &c) {
Highlight *highlight;
int len;
highlight = myDoc->highlight();
TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
len = textLine->length();
if (cursor.x < len) {
do {
cursor.x++;
} while (cursor.x < len && highlight->isInWord(textLine->getChar(cursor.x)));
while (cursor.x < len && !highlight->isInWord(textLine->getChar(cursor.x)))
cursor.x++;
} else {
if (cursor.y < myDoc->lastLine()) {
cursor.y++;
textLine = myDoc->getTextLine(cursor.y);
cursor.x = 0;
}
}
cOldXPos = cXPos = myDoc->textWidth(cursor);
changeState(c);
}
void KateViewInternal::home(VConfig &c) {
int lc;
lc = (c.flags & KateView::cfSmartHome) ? myDoc->getTextLine(cursor.y)->firstChar() : 0;
if (lc <= 0 || cursor.x == lc) {
cursor.x = 0;
cOldXPos = cXPos = 0;
} else {
cursor.x = lc;
cOldXPos = cXPos = myDoc->textWidth(cursor);
}
changeState(c);
}
void KateViewInternal::end(VConfig &c) {
cursor.x = myDoc->textLength(cursor.y);
cOldXPos = cXPos = myDoc->textWidth(cursor);
changeState(c);
}
void KateViewInternal::cursorUp(VConfig &c) {
cursor.y--;
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
changeState(c);
}
void KateViewInternal::cursorDown(VConfig &c) {
int x;
if (cursor.y == myDoc->lastLine()) {
x = myDoc->textLength(cursor.y);
if (cursor.x >= x) return;
cursor.x = x;
cXPos = myDoc->textWidth(cursor);
} else {
cursor.y++;
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos);
}
changeState(c);
}
void KateViewInternal::scrollUp(VConfig &c) {
if (! yPos) return;
newYPos = yPos - myDoc->fontHeight;
if (cursor.y == (yPos + height())/myDoc->fontHeight -1) {
cursor.y--;
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
changeState(c);
}
}
void KateViewInternal::scrollDown(VConfig &c) {
if (endLine >= myDoc->lastLine()) return;
newYPos = yPos + myDoc->fontHeight;
if (cursor.y == (yPos + myDoc->fontHeight -1)/myDoc->fontHeight) {
cursor.y++;
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
changeState(c);
}
}
void KateViewInternal::topOfView(VConfig &c) {
cursor.y = (yPos + myDoc->fontHeight -1)/myDoc->fontHeight;
cursor.x = 0;
cOldXPos = cXPos = 0;
changeState(c);
}
void KateViewInternal::bottomOfView(VConfig &c) {
cursor.y = (yPos + height())/myDoc->fontHeight -1;
if (cursor.y < 0) cursor.y = 0;
if (cursor.y > myDoc->lastLine()) cursor.y = myDoc->lastLine();
cursor.x = 0;
cOldXPos = cXPos = 0;
changeState(c);
}
void KateViewInternal::pageUp(VConfig &c) {
int lines = (endLine - startLine - 1);
if (lines <= 0) lines = 1;
if (!(c.flags & KateView::cfPageUDMovesCursor) && yPos > 0) {
newYPos = yPos - lines * myDoc->fontHeight;
if (newYPos < 0) newYPos = 0;
}
cursor.y -= lines;
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos);
changeState(c);
// cursorPageUp(c);
}
void KateViewInternal::pageDown(VConfig &c) {
int lines = (endLine - startLine - 1);
if (!(c.flags & KateView::cfPageUDMovesCursor) && endLine < myDoc->lastLine()) {
if (lines < myDoc->lastLine() - endLine)
newYPos = yPos + lines * myDoc->fontHeight;
else
newYPos = yPos + (myDoc->lastLine() - endLine) * myDoc->fontHeight;
}
cursor.y += lines;
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
changeState(c);
// cursorPageDown(c);
}
// go to the top, same X position
void KateViewInternal::top(VConfig &c) {
// cursor.x = 0;
cursor.y = 0;
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
// cOldXPos = cXPos = 0;
changeState(c);
}
// go to the bottom, same X position
void KateViewInternal::bottom(VConfig &c) {
// cursor.x = 0;
cursor.y = myDoc->lastLine();
cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos);
// cOldXPos = cXPos = 0;
changeState(c);
}
// go to the top left corner
void KateViewInternal::top_home(VConfig &c)
{
cursor.y = 0;
cursor.x = 0;
cOldXPos = cXPos = 0;
changeState(c);
}
// go to the bottom right corner
void KateViewInternal::bottom_end(VConfig &c) {
cursor.y = myDoc->lastLine();
cursor.x = myDoc->textLength(cursor.y);
cOldXPos = cXPos = myDoc->textWidth(cursor);
changeState(c);
}
void KateViewInternal::changeXPos(int p) {
int dx;
dx = xPos - p;
xPos = p;
if (QABS(dx) < width()) scroll(dx, 0); else update();
}
void KateViewInternal::changeYPos(int p) {
int dy;
dy = yPos - p;
yPos = p;
clearDirtyCache(height());
if (QABS(dy) < height())
{
scroll(0, dy);
leftBorder->scroll(0, dy);
}
else
update();
}
void KateViewInternal::getVConfig(VConfig &c) {
c.view = myView;
c.cursor = cursor;
c.cXPos = cXPos;
c.flags = myView->configFlags;
}
void KateViewInternal::changeState(VConfig &c) {
/*
* we need to be sure to kill the selection on an attempted cursor
* movement even if the cursor doesn't physically move,
* but we need to be careful not to do some other things in this case,
* like we don't want to expose the cursor
*/
// if (cursor.x == c.cursor.x && cursor.y == c.cursor.y) return;
bool nullMove = (cursor.x == c.cursor.x && cursor.y == c.cursor.y);
// if (cursor.y != c.cursor.y || c.flags & KateView::cfMark) myDoc->recordReset();
if (! nullMove) {
exposeCursor = true;
// mark old position of cursor as dirty
if (cursorOn) {
tagLines(c.cursor.y, c.cursor.y, c.cXPos -2, c.cXPos +3);
cursorOn = false;
}
// mark old bracket mark position as dirty
if (bm.sXPos < bm.eXPos) {
tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos);
}
// make new bracket mark
myDoc->newBracketMark(cursor, bm);
// remove trailing spaces when leaving a line
if (c.flags & KateView::cfRemoveSpaces && cursor.y != c.cursor.y) {
TextLine::Ptr textLine = myDoc->getTextLine(c.cursor.y);
int newLen = textLine->lastChar();
if (newLen != textLine->length()) {
textLine->truncate(newLen);
// if some spaces are removed, tag the line as dirty
myDoc->tagLines(c.cursor.y, c.cursor.y);
}
}
}
if (c.flags & KateView::cfMark) {
if (! nullMove)
myDoc->selectTo(c, cursor, cXPos);
} else {
if (!(c.flags & KateView::cfPersistent))
myDoc->deselectAll();
}
}
void KateViewInternal::insLine(int line) {
if (line <= cursor.y) {
cursor.y++;
}
if (line < startLine) {
startLine++;
endLine++;
yPos += myDoc->fontHeight;
} else if (line <= endLine) {
tagAll();
}
}
void KateViewInternal::delLine(int line) {
if (line <= cursor.y && cursor.y > 0) {
cursor.y--;
}
if (line < startLine) {
startLine--;
endLine--;
yPos -= myDoc->fontHeight;
} else if (line <= endLine) {
tagAll();
}
}
void KateViewInternal::updateCursor() {
cOldXPos = cXPos = myDoc->textWidth(cursor);
}
void KateViewInternal::updateCursor(PointStruc &newCursor) {
updateCursor(newCursor, myView->config());
}
void KateViewInternal::updateCursor(PointStruc &newCursor, int flags) {
if (!(flags & KateView::cfPersistent)) myDoc->deselectAll();
exposeCursor = true;
if (cursorOn) {
tagLines(cursor.y, cursor.y, cXPos -2, cXPos +3);
cursorOn = false;
}
if (bm.sXPos < bm.eXPos) {
tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos);
}
myDoc->newBracketMark(newCursor, bm);
cursor = newCursor;
cOldXPos = cXPos = myDoc->textWidth(cursor);
}
// init the line dirty cache
void KateViewInternal::clearDirtyCache(int height) {
int lines, z;
// calc start and end line of visible part
startLine = yPos/myDoc->fontHeight;
endLine = (yPos + height -1)/myDoc->fontHeight;
updateState = 0;
lines = endLine - startLine +1;
if (lines > numLines) { // resize the dirty cache
numLines = lines*2;
delete [] lineRanges;
lineRanges = new LineRange[numLines];
}
for (z = 0; z < lines; z++) { // clear all lines
lineRanges[z].start = 0xffffff;
lineRanges[z].end = -2;
}
newXPos = newYPos = -1;
}
void KateViewInternal::tagLines(int start, int end, int x1, int x2) {
LineRange *r;
int z;
start -= startLine;
if (start < 0) start = 0;
end -= startLine;
if (end > endLine - startLine) end = endLine - startLine;
if (x1 <= 0) x1 = -2;
if (x1 < xPos-2) x1 = xPos-2;
if (x2 > width() + xPos-2) x2 = width() + xPos-2;
if (x1 >= x2) return;
r = &lineRanges[start];
for (z = start; z <= end; z++) {
if (x1 < r->start) r->start = x1;
if (x2 > r->end) r->end = x2;
r++;
updateState |= 1;
}
}
void KateViewInternal::tagAll() {
updateState = 3;
}
void KateViewInternal::setPos(int x, int y) {
newXPos = x;
newYPos = y;
}
void KateViewInternal::center() {
newXPos = 0;
newYPos = cursor.y*myDoc->fontHeight - height()/2;
if (newYPos < 0) newYPos = 0;
}
void KateViewInternal::updateView(int flags) {
int fontHeight;
int oldXPos, oldYPos;
int w, h;
int z;
bool b;
int xMax, yMax;
int cYPos;
int cXPosMin, cXPosMax, cYPosMin, cYPosMax;
int dx, dy;
int pageScroll;
int scrollbarWidth = style().scrollBarExtent().width();
//debug("upView %d %d %d %d %d", exposeCursor, updateState, flags, newXPos, newYPos);
if (exposeCursor || flags & KateView::ufDocGeometry) {
emit myView->newCurPos();
} else {
if (updateState == 0 && newXPos < 0 && newYPos < 0) return;
}
if (cursorTimer) {
killTimer(cursorTimer);
cursorTimer = startTimer(KApplication::cursorFlashTime() / 2);
cursorOn = true;
}
oldXPos = xPos;
oldYPos = yPos;
/* if (flags & ufPos) {
xPos = newXPos;
yPos = newYPos;
exposeCursor = true;
}*/
if (newXPos >= 0) xPos = newXPos;
if (newYPos >= 0) yPos = newYPos;
fontHeight = myDoc->fontHeight;
cYPos = cursor.y*fontHeight;
z = 0;
do {
w = myView->width() - 4;
h = myView->height() - 4;
xMax = myDoc->textWidth() - w;
b = (xPos > 0 || xMax > 0);
if (b) h -= scrollbarWidth;
yMax = myDoc->textHeight() - h;
if (yPos > 0 || yMax > 0) {
w -= scrollbarWidth;
xMax += scrollbarWidth;
if (!b && xMax > 0) {
h -= scrollbarWidth;
yMax += scrollbarWidth;
}
}
if (!exposeCursor) break;
// if (flags & KateView::ufNoScroll) break;
/*
if (flags & KateView::ufCenter) {
cXPosMin = xPos + w/3;
cXPosMax = xPos + (w*2)/3;
cYPosMin = yPos + h/3;
cYPosMax = yPos + ((h - fontHeight)*2)/3;
} else {*/
cXPosMin = xPos + 4;
cXPosMax = xPos + w - 8;
cYPosMin = yPos;
cYPosMax = yPos + (h - fontHeight);
// }
if (cXPos < cXPosMin) {
xPos -= cXPosMin - cXPos;
}
if (xPos < 0) xPos = 0;
if (cXPos > cXPosMax) {
xPos += cXPos - cXPosMax;
}
if (cYPos < cYPosMin) {
yPos -= cYPosMin - cYPos;
}
if (yPos < 0) yPos = 0;
if (cYPos > cYPosMax) {
yPos += cYPos - cYPosMax;
}
z++;
} while (z < 2);
if (xMax < xPos) xMax = xPos;
if (yMax < yPos) yMax = yPos;
if (xMax > 0) {
pageScroll = w - (w % fontHeight) - fontHeight;
if (pageScroll <= 0)
pageScroll = fontHeight;
xScroll->blockSignals(true);
xScroll->setGeometry(2,h + 2,w,scrollbarWidth);
xScroll->setRange(0,xMax);
xScroll->setValue(xPos);
xScroll->setSteps(fontHeight,pageScroll);
xScroll->blockSignals(false);
xScroll->show();
} else xScroll->hide();
if (yMax > 0) {
pageScroll = h - (h % fontHeight) - fontHeight;
if (pageScroll <= 0)
pageScroll = fontHeight;
yScroll->blockSignals(true);
yScroll->setGeometry(w + 2,2,scrollbarWidth,h);
yScroll->setRange(0,yMax);
yScroll->setValue(yPos);
yScroll->setSteps(fontHeight,pageScroll);
yScroll->blockSignals(false);
yScroll->show();
} else yScroll->hide();
if (w != width() || h != height()) {
clearDirtyCache(h);
resize(w,h);
} else {
dx = oldXPos - xPos;
dy = oldYPos - yPos;
b = updateState == 3;
if (flags & KateView::ufUpdateOnScroll) {
b |= dx || dy;
} else {
b |= QABS(dx)*3 > w*2 || QABS(dy)*3 > h*2;
}
if (b) {
clearDirtyCache(h);
update();
} else {
if (dy)
leftBorder->scroll(0, dy);
if (updateState > 0) paintTextLines(oldXPos, oldYPos);
clearDirtyCache(h);
if (dx || dy) {
scroll(dx,dy);
// kapp->syncX();
// scroll2(dx - dx/2,dy - dy/2);
// } else {
}
if (cursorOn) paintCursor();
if (bm.eXPos > bm.sXPos) paintBracketMark();
}
}
exposeCursor = false;
// updateState = 0;
}
void KateViewInternal::paintTextLines(int xPos, int yPos) {
// int xStart, xEnd;
int line;//, z;
int h;
LineRange *r;
if (!drawBuffer) return;
if (drawBuffer->isNull()) return;
QPainter paint;
paint.begin(drawBuffer);
h = myDoc->fontHeight;
r = lineRanges;
for (line = startLine; line <= endLine; line++) {
if (r->start < r->end) {
//debug("painttextline %d %d %d", line, r->start, r->end);
myDoc->paintTextLine(paint, line, r->start, r->end, myView->configFlags & KateView::cfShowTabs);
bitBlt(this, r->start - (xPos-2), line*h - yPos, drawBuffer, 0, 0,
r->end - r->start, h);
leftBorder->paintLine(line);
}
r++;
}
paint.end();
}
void KateViewInternal::paintCursor() {
int h, y, x;
static int cx = 0, cy = 0, ch = 0;
h = myDoc->fontHeight;
y = h*cursor.y - yPos;
x = cXPos - (xPos-2);
if(myDoc->myFont != font()) setFont(myDoc->myFont);
if(cx != x || cy != y || ch != h){
cx = x;
cy = y;
ch = h;
setMicroFocusHint(cx, cy, 0, ch - 2);
}
QPainter paint;
if (cursorOn) {
paint.begin(this);
paint.setClipping(false);
paint.setPen(myDoc->cursorCol(cursor.x,cursor.y));
h += y - 1;
paint.drawLine(x, y, x, h);
paint.end();
} else { if (drawBuffer && !drawBuffer->isNull()) {
paint.begin(drawBuffer);
myDoc->paintTextLine(paint, cursor.y, cXPos - 2, cXPos + 3, myView->configFlags & KateView::cfShowTabs);
bitBlt(this,x - 2,y, drawBuffer, 0, 0, 5, h);
paint.end(); }
}
}
void KateViewInternal::paintBracketMark() {
int y;
y = myDoc->fontHeight*(bm.cursor.y +1) - yPos -1;
QPainter paint;
paint.begin(this);
paint.setPen(myDoc->cursorCol(bm.cursor.x, bm.cursor.y));
paint.drawLine(bm.sXPos - (xPos-2), y, bm.eXPos - (xPos-2) -1, y);
paint.end();
}
void KateViewInternal::placeCursor(int x, int y, int flags) {
VConfig c;
getVConfig(c);
c.flags |= flags;
cursor.y = (yPos + y)/myDoc->fontHeight;
cXPos = cOldXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor,xPos-2 + x);
changeState(c);
}
// given physical coordinates, report whether the text there is selected
bool KateViewInternal::isTargetSelected(int x, int y) {
y = (yPos + y) / myDoc->fontHeight;
TextLine::Ptr line = myDoc->getTextLine(y);
if (!line)
return false;
x = myDoc->textPos(line, x);
return line->isSelected(x);
}
void KateViewInternal::focusInEvent(QFocusEvent *) {
// debug("got focus %d",cursorTimer);
if (!cursorTimer) {
cursorTimer = startTimer(KApplication::cursorFlashTime() / 2);
cursorOn = true;
paintCursor();
}
}
void KateViewInternal::focusOutEvent(QFocusEvent *) {
// debug("lost focus %d", cursorTimer);
if (cursorTimer) {
killTimer(cursorTimer);
cursorTimer = 0;
}
if (cursorOn) {
cursorOn = false;
paintCursor();
}
}
void KateViewInternal::keyPressEvent(QKeyEvent *e) {
VConfig c;
// int ascii;
/* if (e->state() & AltButton) {
e->ignore();
return;
}*/
// debug("ascii %i, key %i, state %i",e->ascii(), e->key(), e->state());
getVConfig(c);
// ascii = e->ascii();
if (!myView->isReadOnly()) {
if (c.flags & KateView::cfTabIndents && myDoc->hasMarkedText()) {
if (e->key() == Qt::Key_Tab) {
myDoc->indent(c);
myDoc->updateViews();
return;
}
if (e->key() == Qt::Key_Backtab) {
myDoc->unIndent(c);
myDoc->updateViews();
return;
}
}
if ( !(e->state() & ControlButton ) && myDoc->insertChars(c, e->text())) {
myDoc->updateViews();
e->accept();
return;
}
}
e->ignore();
}
void KateViewInternal::mousePressEvent(QMouseEvent *e) {
if (e->button() == LeftButton) {
int flags;
flags = 0;
if (e->state() & ShiftButton) {
flags |= KateView::cfMark;
if (e->state() & ControlButton) flags |= KateView::cfMark | KateView::cfKeepSelection;
}
placeCursor(e->x(), e->y(), flags);
scrollX = 0;
scrollY = 0;
if (!scrollTimer) scrollTimer = startTimer(50);
myDoc->updateViews();
}
if (e->button() == MidButton) {
placeCursor(e->x(), e->y());
if (! myView->isReadOnly())
myView->paste();
}
if (myView->rmbMenu && e->button() == RightButton) {
myView->rmbMenu->popup(mapToGlobal(e->pos()));
}
myView->mousePressEvent(e); // this doesn't do anything, does it?
// it does :-), we need this for KDevelop, so please don't uncomment it again -Sandy
}
void KateViewInternal::mouseDoubleClickEvent(QMouseEvent *e) {
if (e->button() == LeftButton) {
VConfig c;
getVConfig(c);
myDoc->selectWord(c.cursor, c.flags);
myDoc->updateViews();
}
}
void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) {
if (e->button() == LeftButton) {
if (myView->config() & KateView::cfMouseAutoCopy) myView->copy();
killTimer(scrollTimer);
scrollTimer = 0;
}
}
void KateViewInternal::mouseMoveEvent(QMouseEvent *e) {
if (e->state() & LeftButton) {
int flags;
int d;
int x = e->x(),
y = e->y();
mouseX = e->x();
mouseY = e->y();
scrollX = 0;
scrollY = 0;
d = myDoc->fontHeight;
if (mouseX < 0) {
mouseX = 0;
scrollX = -d;
}
if (mouseX > width()) {
mouseX = width();
scrollX = d;
}
if (mouseY < 0) {
mouseY = 0;
scrollY = -d;
}
if (mouseY > height()) {
mouseY = height();
scrollY = d;
}
//debug("modifiers %d", ((KGuiCmdApp *) kapp)->getModifiers());
flags = KateView::cfMark;
if (e->state() & ControlButton) flags |= KateView::cfKeepSelection;
placeCursor(mouseX, mouseY, flags);
myDoc->updateViews(/*ufNoScroll*/);
}
}
void KateViewInternal::wheelEvent( QWheelEvent *e )
{
if( yScroll->isVisible() == true )
{
QApplication::sendEvent( yScroll, e );
}
}
void KateViewInternal::paintEvent(QPaintEvent *e) {
int xStart, xEnd;
int h;
int line, y, yEnd;
QRect updateR = e->rect();
if (!drawBuffer) return;
if (drawBuffer->isNull()) return;
QPainter paint;
paint.begin(drawBuffer);
xStart = xPos-2 + updateR.x();
xEnd = xStart + updateR.width();
h = myDoc->fontHeight;
line = (yPos + updateR.y()) / h;
y = line*h - yPos;
yEnd = updateR.y() + updateR.height();
waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5);
while (y < yEnd)
{
TextLine *textLine;
int ctxNum = 0;
myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs);
bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h);
leftBorder->paintLine(line);
line++;
y += h;
}
paint.end();
if (cursorOn) paintCursor();
if (bm.eXPos > bm.sXPos) paintBracketMark();
}
void KateViewInternal::resizeEvent(QResizeEvent *)
{
drawBuffer->resize (width(), myDoc->fontHeight);
leftBorder->resize(iconBorderWidth, height());
}
void KateViewInternal::timerEvent(QTimerEvent *e) {
if (e->timerId() == cursorTimer) {
cursorOn = !cursorOn;
paintCursor();
}
if (e->timerId() == scrollTimer && (scrollX | scrollY)) {
xScroll->setValue(xPos + scrollX);
yScroll->setValue(yPos + scrollY);
placeCursor(mouseX, mouseY, KateView::cfMark);
myDoc->updateViews(/*ufNoScroll*/);
}
}
uint KateView::uniqueID = 0;
KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name)
{
myViewID = uniqueID;
uniqueID++;
active = false;
myIconBorder = false;
myDoc = doc;
myViewInternal = new KateViewInternal (this,doc);
myViewInternal->move(2, 2);
myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal);
myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight);
myViewInternal->leftBorder->hide();
doc->addView( this );
// some defaults
configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents
| KateView::cfTabIndents | KateView::cfKeepIndentProfile
| KateView::cfRemoveSpaces
| KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor
| KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome;
searchFlags = 0;
replacePrompt = 0L;
rmbMenu = 0L;
setFocusProxy( myViewInternal );
myViewInternal->setFocus();
resize(parent->width() -4, parent->height() -4);
myViewInternal->installEventFilter( this );
//setupActions();
connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) );
connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) );
connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) );
connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) );
readConfig();
// setHighlight->setCurrentItem(getHl());
slotUpdate();
}
KateView::~KateView()
{
writeConfig();
if (myDoc && !myDoc->m_bSingleViewMode)
myDoc->removeView( this );
delete myViewInternal;
}
#if 0
void KateView::setupActions()
{
#if 0
KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" );
KStdAction::save(this, SLOT(save()), actionCollection());
// setup edit menu
editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection());
editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection());
editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()),
actionCollection(), "edit_undoHistory");
KStdAction::cut(this, SLOT(cut()), actionCollection());
KStdAction::copy(this, SLOT(copy()), actionCollection());
KStdAction::paste(this, SLOT(paste()), actionCollection());
if ( myDoc->hasBrowserExtension() )
{
KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection());
KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find");
KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again");
KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev");
KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" );
new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg");
setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight");
KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all");
new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
myDoc->actionCollection(), "unselect_all");
new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
myDoc->actionCollection(), "invert_select");
new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
myDoc->actionCollection(), "incFontSizes");
new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
myDoc->actionCollection(), "decFontSizes");
}
else
{
KStdAction::saveAs(this, SLOT(saveAs()), actionCollection());
KStdAction::find(this, SLOT(find()), actionCollection());
KStdAction::findNext(this, SLOT(findAgain()), actionCollection());
KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev");
KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection());
new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg");
setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight");
KStdAction::selectAll(this, SLOT(selectAll()), actionCollection());
new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()),
actionCollection(), "edit_deselectAll");
new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()),
actionCollection(), "edit_invertSelection");
new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()),
actionCollection(), "incFontSizes");
new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()),
actionCollection(), "decFontSizes");
}
new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap");
KStdAction::replace(this, SLOT(replace()), actionCollection());
new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()),
actionCollection(), "edit_cmd");
// setup bookmark menu
bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle");
bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear");
// connect settings menu aboutToshow
bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks");
connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow()));
new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border");
// setup Tools menu
KStdAction::spelling(this, SLOT(spellcheck()), actionCollection());
new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()),
actionCollection(), "tools_indent");
new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()),
actionCollection(), "tools_unindent");
new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()),
actionCollection(), "tools_cleanIndent");
new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()),
actionCollection(), "tools_comment");
new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()),
actionCollection(), "tools_uncomment");
setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()),
actionCollection(), "set_verticalSelect");
connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int)));
QStringList list;
for (int z = 0; z < HlManager::self()->highlights(); z++)
list.append(HlManager::self()->hlName(z));
setHighlight->setItems(list);
setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol");
connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int)));
list.clear();
list.append("&Unix");
list.append("&Windows/Dos");
list.append("&Macintosh");
setEndOfLine->setItems(list);
#endif
}
#endif
void KateView::slotUpdate()
{
int cfg = config();
#warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect);
slotNewUndo();
}
void KateView::slotFileStatusChanged()
{
int eol = getEol();
eol = eol>=1 ? eol : 0;
#warning fixme setEndOfLine->setCurrentItem(eol);
}
void KateView::slotNewUndo()
{
#if 0
int state = undoState();
editUndoHist->setEnabled(state & 1 || state & 2);
QString t = i18n("Und&o"); // it would be nicer to fetch the original string
if (state & 1) {
editUndo->setEnabled(true);
t += ' ';
t += i18n(undoTypeName(nextUndoType()));
} else {
editUndo->setEnabled(false);
}
editUndo->setText(t);
t = i18n("Re&do"); // it would be nicer to fetch the original string
if (state & 2) {
editRedo->setEnabled(true);
t += ' ';
t += i18n(undoTypeName(nextRedoType()));
} else {
editRedo->setEnabled(false);
}
editRedo->setText(t);
#endif
}
void KateView::slotHighlightChanged()
{
// setHighlight->setCurrentItem(getHl());
}
void KateView::keyPressEvent( QKeyEvent *ev )
{
switch ( ev->key() )
{
case Key_Left:
if ( ev->state() & ShiftButton )
{
if ( ev->state() & ControlButton )
shiftWordLeft();
else
shiftCursorLeft();
}
else if ( ev->state() & ControlButton )
wordLeft();
else
cursorLeft();
break;
case Key_Right:
if ( ev->state() & ShiftButton )
{
if ( ev->state() & ControlButton )
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);
+ 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 );
+ 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->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 );
+ 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);
-
-
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(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;
+ bool shutDown;
- QAction *editCopy;
- QAction *editCut;
- QAction *editPaste;
- QAction *editUndo;
- QAction *editRedo;
- QAction *editFind;
- QAction *editFindReplace;
- QAction *viewIncFontSizes;
- QAction *viewDecFontSizes;
- QAction *utilSettings;
+ 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
+HEADERS = tinykate.h
+SOURCES = tinykate.cpp main.cpp
+INTERFACES =
INCLUDEPATH += $(OPIEDIR)/include \
$(OPIEDIR)/noncore/apps/tinykate/libkate \
$(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
$(OPIEDIR)/noncore/apps/tinykate/libkate/document \
$(OPIEDIR)/noncore/apps/tinykate/libkate/view \
$(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
$(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
$(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -ltinykate -lopie
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
@@ -1,1221 +1,1233 @@
/*
                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 <linux/limits.h>
#include <unistd.h>
#include <qpe/qcopenvelope_qws.h>
#include <qmenubar.h>
#include <qpe/qpeapplication.h>
#include <qtoolbar.h>
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qcombobox.h>
#include <qfile.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qprogressbar.h>
#include <qtimer.h>
#include <qwhatsthis.h>
#include <qwidgetstack.h>
#include "categoryfilterimpl.h"
#include "datamgr.h"
#include "global.h"
#include "inputdlg.h"
#include "ipkg.h"
#include "installdlgimpl.h"
#include "letterpushbutton.h"
#include "mainwin.h"
#include "packagewin.h"
#include "settingsimpl.h"
#include "utils.h"
extern int compareVersions( const char *v1, const char *v2 );
MainWindow :: MainWindow()
: QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
{
setCaption( tr( "AQPkg - Package Manager" ) );
// Create UI widgets
initMainWidget();
initProgressWidget();
// Build menu and tool bars
setToolBarsMovable( FALSE );
QToolBar *bar = new QToolBar( this );
bar->setHorizontalStretchable( TRUE );
QMenuBar *mb = new QMenuBar( bar );
mb->setMargin( 0 );
bar = new QToolBar( this );
// Find toolbar
findBar = new QToolBar( this );
addToolBar( findBar, QMainWindow::Top, true );
findBar->setHorizontalStretchable( true );
findEdit = new QLineEdit( findBar );
QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
findBar->setStretchableWidget( findEdit );
connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
// Quick jump toolbar
jumpBar = new QToolBar( this );
addToolBar( jumpBar, QMainWindow::Top, true );
jumpBar->setHorizontalStretchable( true );
QWidget *w = new QWidget( jumpBar );
jumpBar->setStretchableWidget( w );
QGridLayout *layout = new QGridLayout( w );
char text[2];
text[1] = '\0';
for ( int i = 0 ; i < 26 ; ++i )
{
text[0] = 'A' + i;
LetterPushButton *b = new LetterPushButton( text, w );
connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
layout->addWidget( b, i / 13, i % 13);
}
QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
a->addTo( jumpBar );
jumpBar->hide();
// Packages menu
QPopupMenu *popup = new QPopupMenu( this );
a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
a->addTo( popup );
a->addTo( bar );
actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( bar );
iconDownload = Resource::loadPixmap( "aqpkg/download" );
iconRemove = Resource::loadPixmap( "aqpkg/remove" );
actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
actionDownload->addTo( popup );
actionDownload->addTo( bar );
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
a->addTo( popup );
a->addTo( bar );
popup->insertSeparator();
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this application." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
a->addTo( popup );
mb->insertItem( tr( "Actions" ), popup );
// View menu
popup = new QPopupMenu( this );
actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
actionUninstalled->setToggleAction( TRUE );
actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
actionUninstalled->addTo( popup );
actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
actionInstalled->setToggleAction( TRUE );
actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
actionInstalled->addTo( popup );
actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
actionUpdated->setToggleAction( TRUE );
actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
actionUpdated->addTo( popup );
popup->insertSeparator();
actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
actionFilter->setToggleAction( TRUE );
actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
actionFilter->addTo( popup );
a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
a->addTo( popup );
popup->insertSeparator();
a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to search for text in package names." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
a->addTo( popup );
actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
actionFindNext->setEnabled( FALSE );
actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
actionFindNext->addTo( popup );
actionFindNext->addTo( findBar );
popup->insertSeparator();
a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
a->addTo( popup );
mb->insertItem( tr( "View" ), popup );
// Finish find toolbar creation
a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
a->addTo( findBar );
findBar->hide();
// Create widget stack and add UI widgets
stack = new QWidgetStack( this );
stack->addWidget( progressWindow, 2 );
stack->addWidget( networkPkgWindow, 1 );
setCentralWidget( stack );
stack->raiseWidget( progressWindow );
// Delayed call to finish initialization
QTimer::singleShot( 100, this, SLOT( init() ) );
}
MainWindow :: ~MainWindow()
{
delete mgr;
}
void MainWindow :: initMainWidget()
{
networkPkgWindow = new QWidget( this );
QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
serversList = new QComboBox( networkPkgWindow );
connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) );
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();
}