Source Code (Use browser search to find items of interest.)
Class Index
kedit'TopLevel (./kdeutils/kedit/kedit.h:51)
class TopLevel : public KTMainWindow
{
Q_OBJECT
public:
enum { KEDIT_OK = 0,
KEDIT_OS_ERROR = 1,
KEDIT_USER_CANCEL = 2 ,
KEDIT_RETRY = 3,
KEDIT_NOPERMISSIONS = 4};
enum { OPEN_READWRITE = 1,
OPEN_READONLY = 2,
OPEN_INSERT = 4 };
TopLevel( QWidget *parent=0, const char *name=0 );
~TopLevel();
/**
* Reads a file into the edit widget.
*
* @return KEDIT_OK on success
*/
int openFile( const QString& _url, int _mode);
/**
* Saves the edit widget to a file.
*
* @return KEDIT_OK on success
*/
int saveFile( const QString& _url);
/**
* Works like openFile but is able to open remote files
*/
void openURL( const KURL& _url, int _mode );
/**
* Saves the current text to the URL '_url'.
*
* @return KEDIT::KEDIT_OK on success
*/
int saveURL( const KURL& _url );
/**
* Get the name of the current file
**/
QString name();
/**
* Only show the window when the following load action is succesfull.
**/
void setNewWindow() { newWindow = true; }
/// List of all windows
static QList<TopLevel> windowList;
QPopupMenu *right_mouse_button;
bool queryExit( void );
bool queryClose( void );
protected:
void setSensitivity();
void readSettings();
void writeSettings();
void setupEditWidget();
void setupStatusBar();
void setupActions();
private:
public: // Should not be!
KEdit *eframe;
private:
QString location;
bool newWindow;
int statusID, toolID, indentID;
QString url_location;
QTimer *statusbar_timer;
KRecentFilesAction *recent;
int open_mode;
int editor_width;
int editor_height;
int show_toolbar;
int show_statusbar;
struct printinfo pi;
SOptionState mOptionState;
KConfig *config;
KSpell *kspell; // Current spell checking object
/*
* The source, the destination of the copy, and the open mode
* for each job being run (job ptr is the dict key).
*/
QPtrDict <QString> m_sNet;
QPtrDict <QString> m_sLocal;
QPtrDict <int> m_openMode;
// Session management
void saveProperties(KConfig*);
void readProperties(KConfig*);
COptionDialog *mOptionDialog;
public slots:
void openRecent(const KURL&);
void set_colors();
void gotoLine();
void mail();
void setGeneralStatusField(const QString &string);
void undo();
void redo();
void copy();
void paste();
void cut();
void insertDate();
void print();
void select_all();
void clean_space();
void timer_slot();
void save_options();
void file_open();
void file_new();
void file_insert();
void setFileCaption();
void statusbar_slot();
void file_close();
void file_save();
void file_save_as();
void helpselected();
void search();
void replace();
void toggleStatusBar();
void toggleToolBar();
void search_again();
void toggle_overwrite();
void spellcheck();
void spell_started ( KSpell *);
void spell_progress (unsigned int percent);
void spell_done(const char *);
void spell_finished();
void urlDrop_slot(QDropEvent* e);
protected:
/// Drag and Drop
void dragEnterEvent(QDragEnterEvent* e);
void dropEvent(QDropEvent* e);
private slots:
void customize( void );
void setFontOption( const SFontState &font );
void setColorOption( const SColorState &color );
void setSpellOption( const SSpellState &spell );
void setMiscOption( const SMiscState &misc );
void editKeys();
void editToolbars();
};
kedit'TopLevel::TopLevel() (./kdeutils/kedit/kedit.cpp:65)
TopLevel::TopLevel (QWidget *, const char *name)
: KTMainWindow ( name)
{
mOptionDialog = 0;
kspell = 0;
newWindow = false;
windowList.setAutoDelete( FALSE );
windowList.append( this );
statusbar_timer = new QTimer(this);
connect(statusbar_timer, SIGNAL(timeout()),this,SLOT(timer_slot()));
connect(kapp,SIGNAL(kdisplayPaletteChanged()),this,SLOT(set_colors()));
setupStatusBar();
setupActions();
readSettings();
setupEditWidget();
set_colors();
setAcceptDrops(true);
resize(editor_width,editor_height);
setFileCaption();
}
kedit'TopLevel::~TopLevel() (./kdeutils/kedit/kedit.cpp:95)
TopLevel::~TopLevel ()
{
windowList.remove( this );
delete mOptionDialog;
}
kedit'TopLevel::name() (./kdeutils/kedit/kedit.cpp:101)
QString TopLevel::name()
{
if (location.isEmpty())
return "[New Document]";
return location;
}
kedit'TopLevel::setupEditWidget() (./kdeutils/kedit/kedit.cpp:109)
void TopLevel::setupEditWidget()
{
eframe = new KEdit (this, "eframe");
connect(eframe, SIGNAL(CursorPositionChanged()),this,
SLOT(statusbar_slot()));
connect(eframe, SIGNAL(toggle_overwrite_signal()),this,
SLOT(toggle_overwrite()));
connect(eframe, SIGNAL(gotUrlDrop(QDropEvent*)), this,
SLOT(urlDrop_slot(QDropEvent*)));
setView(eframe,FALSE);
eframe->setMinimumSize(200, 100);
if( mOptionState.misc.wrapMode == SMiscState::fixedColumnWrap )
{
eframe->setWordWrap(QMultiLineEdit::FixedColumnWidth);
eframe->setWrapColumnOrWidth(mOptionState.misc.wrapColumn);
}
else if( mOptionState.misc.wrapMode == SMiscState::dynamicWrap )
{
eframe->setWordWrap(QMultiLineEdit::WidgetWidth);
}
else
{
eframe->setWordWrap(QMultiLineEdit::NoWrap);
}
eframe->setFont( mOptionState.font.font );
eframe->setModified(false);
setSensitivity();
eframe->setFocus();
/*
right_mouse_button = new QPopupMenu;
right_mouse_button->insertItem (i18n("Open..."),
this, SLOT(file_open()));
right_mouse_button->insertItem (i18n("Save"),
this, SLOT(file_save()));
right_mouse_button->insertItem (i18n("Save as..."),
this, SLOT(file_save_as()));
right_mouse_button->insertSeparator(-1);
right_mouse_button->insertItem(i18n("Copy"),
this, SLOT(copy()));
right_mouse_button->insertItem(i18n("Paste"),
this, SLOT(paste()));
right_mouse_button->insertItem(i18n("Cut"),
this, SLOT(cut()));
right_mouse_button->insertItem(i18n("Select All"),
this, SLOT(select_all()));
eframe->installRBPopup(right_mouse_button);
*/
}
kedit'TopLevel::setupActions() (./kdeutils/kedit/kedit.cpp:166)
void TopLevel::setupActions()
{
// setup File menu
KStdAction::openNew(this, SLOT(file_new()), actionCollection());
KStdAction::open(this, SLOT(file_open()), actionCollection());
recent = KStdAction::openRecent(this, SLOT(openRecent(const KURL&)),
actionCollection());
KStdAction::save(this, SLOT(file_save()), actionCollection());
KStdAction::saveAs(this, SLOT(file_save_as()), actionCollection());
KStdAction::close(this, SLOT(file_close()), actionCollection());
KStdAction::print(this, SLOT(print()), actionCollection());
KStdAction::mail(this, SLOT(mail()), actionCollection());
KStdAction::quit(this, SLOT(close()), actionCollection());
// setup edit menu
KStdAction::undo(this, SLOT(undo()), actionCollection());
KStdAction::redo(this, SLOT(redo()), actionCollection());
KStdAction::cut(this, SLOT(cut()), actionCollection());
KStdAction::copy(this, SLOT(copy()), actionCollection());
KStdAction::paste(this, SLOT(paste()), actionCollection());
KStdAction::selectAll(this, SLOT(select_all()), actionCollection());
KStdAction::find(this, SLOT(search()), actionCollection());
KStdAction::findNext(this, SLOT(search_again()), actionCollection());
KStdAction::replace(this, SLOT(replace()), actionCollection());
(void)new KAction(i18n("&Insert File"), 0, this, SLOT(file_insert()),
actionCollection(), "insert_file");
(void)new KAction(i18n("I&nsert Date"), 0, this, SLOT(insertDate()),
actionCollection(), "insert_date");
(void)new KAction(i18n("Cl&ean Spaces"), 0, this, SLOT(clean_space()),
actionCollection(), "clean_spaces");
// setup Tools menu
KStdAction::spelling(this, SLOT(spellcheck()), actionCollection());
// setup Go menu
KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection());
// setup Settings menu
KStdAction::showToolbar(this, SLOT(toggleToolBar()), actionCollection());
KStdAction::showStatusbar(this, SLOT(toggleStatusBar()), actionCollection());
KStdAction::saveOptions(this, SLOT(save_options()), actionCollection());
KStdAction::preferences(this, SLOT(customize()), actionCollection());
KStdAction::keyBindings(this, SLOT(editKeys()), actionCollection());
KStdAction::configureToolbars(this, SLOT(editToolbars()), actionCollection());
createGUI();
}
kedit'TopLevel::setupStatusBar() (./kdeutils/kedit/kedit.cpp:218)
void TopLevel::setupStatusBar(){
KStatusBar *statusbar = new KStatusBar( this );
statusbar->insertItem("Line:000000 Col: 000", ID_LINE_COLUMN);
statusbar->insertItem("XXX", ID_INS_OVR);
statusbar->insertItem("", ID_GENERAL);
statusbar->changeItem("Line: 1 Col: 1", ID_LINE_COLUMN);
statusbar->changeItem("INS", ID_INS_OVR);
statusbar->changeItem("", ID_GENERAL);
//statusbar->setInsertOrder(KStatusBar::RightToLeft);
//statusbar->setAlignment(ID_INS_OVR,AlignCenter);
// statusbar->setInsertOrder(KStatusBar::LeftToRight);
// statusbar->setBorderWidth(1);
setStatusBar( statusbar );
}
kedit'TopLevel::saveProperties() (./kdeutils/kedit/kedit.cpp:242)
void TopLevel::saveProperties(KConfig* config)
{
if(location.isEmpty() && !eframe->isModified())
return;
config->writeEntry("filename",name());
config->writeEntry("modified",eframe->isModified());
if(eframe->isModified())
{
QString tmplocation = kapp->tempSaveName(name());
saveFile(tmplocation);
}
}
kedit'TopLevel::readProperties() (./kdeutils/kedit/kedit.cpp:258)
void TopLevel::readProperties(KConfig* config){
QString filename = config->readEntry("filename","");
int modified = config->readNumEntry("modified",0);
if(!filename.isEmpty() && modified){
bool ok;
QString fn = kapp->checkRecoverFile(filename,ok);
if(ok){
openFile(fn, OPEN_READWRITE);
location = filename;
eframe->setModified();
setFileCaption();
}
}
else{
if(!filename.isEmpty()){
openFile(filename, OPEN_READWRITE);
location = filename;
eframe->setModified(false);
setFileCaption();
}
}
}
kedit'TopLevel::undo() (./kdeutils/kedit/kedit.cpp:287)
void TopLevel::undo()
{
eframe->undo();
}
kedit'TopLevel::redo() (./kdeutils/kedit/kedit.cpp:293)
void TopLevel::redo()
{
eframe->redo();
}
kedit'TopLevel::copy() (./kdeutils/kedit/kedit.cpp:299)
void TopLevel::copy()
{
eframe->copyText();
}
kedit'TopLevel::select_all() (./kdeutils/kedit/kedit.cpp:305)
void TopLevel::select_all()
{
eframe->selectAll();
}
kedit'TopLevel::insertDate() (./kdeutils/kedit/kedit.cpp:313)
void TopLevel::insertDate(){
int line, column;
QString string;
QDate dt = QDate::currentDate();
string = KGlobal::locale()->formatDate(dt);
eframe->getCursorPosition(&line,&column);
eframe->insertAt(string,line,column);
eframe->setModified(TRUE);
statusbar_slot();
}
kedit'TopLevel::paste() (./kdeutils/kedit/kedit.cpp:328)
void TopLevel::paste(){
eframe->paste();
eframe->setModified(TRUE);
statusbar_slot();
}
kedit'TopLevel::cut() (./kdeutils/kedit/kedit.cpp:336)
void TopLevel::cut(){
eframe->cut();
eframe->setModified(TRUE);
statusbar_slot();
}
kedit'TopLevel::file_new() (./kdeutils/kedit/kedit.cpp:344)
void TopLevel::file_new()
{
if (!location.isEmpty() || eframe->isModified())
{
TopLevel *t = new TopLevel ();
t->show();
t->file_new();
return;
}
eframe->clear();
eframe->setModified(true);
location = QString::null;
setFileCaption();
statusbar_slot();
}
kedit'TopLevel::clean_space() (./kdeutils/kedit/kedit.cpp:360)
void TopLevel::clean_space()
{
if (!eframe);
eframe->cleanWhiteSpace();
}
kedit'TopLevel::spellcheck() (./kdeutils/kedit/kedit.cpp:366)
void TopLevel::spellcheck()
{
if (!eframe) return;
if (kspell) return; // In progress
statusBar()->changeItem("Spellcheck: Started.", ID_GENERAL);
kspell = new KSpell(this, i18n("Spellcheck"), this,
SLOT( spell_started(KSpell *)), &mOptionState.spell.config);
connect (kspell, SIGNAL ( death()),
this, SLOT ( spell_finished( )));
connect (kspell, SIGNAL (progress (unsigned int)),
this, SLOT (spell_progress (unsigned int)));
connect (kspell, SIGNAL (misspelling (QString, QStringList *, unsigned)),
eframe, SLOT (misspelling (QString, QStringList *, unsigned)));
connect (kspell, SIGNAL (corrected (QString, QString, unsigned)),
eframe, SLOT (corrected (QString, QString, unsigned)));
connect (kspell, SIGNAL (done(const char *)),
this, SLOT (spell_done(const char *)));
}
kedit'TopLevel::spell_started() (./kdeutils/kedit/kedit.cpp:390)
void TopLevel::spell_started( KSpell *)
{
eframe->spellcheck_start();
kspell->setProgressResolution(2);
kspell->check(eframe->text());
}
kedit'TopLevel::spell_progress() (./kdeutils/kedit/kedit.cpp:397)
void TopLevel::spell_progress (unsigned int percent)
{
QString s;
s = i18n("Spellcheck: %1% complete").arg(percent);
statusBar()->changeItem (s, ID_GENERAL);
}
kedit'TopLevel::spell_done() (./kdeutils/kedit/kedit.cpp:405)
void TopLevel::spell_done(const char *newtext)
{
eframe->spellcheck_stop();
if (kspell->dlgResult() == 0)
{
eframe->setText( newtext);
statusBar()->changeItem (i18n("Spellcheck: Aborted"), ID_GENERAL);
}
else
{
statusBar()->changeItem (i18n("Spellcheck: Complete"), ID_GENERAL);
}
kspell->cleanUp();
}
kedit'TopLevel::spell_finished() (./kdeutils/kedit/kedit.cpp:420)
void TopLevel::spell_finished( )
{
KSpell::spellStatus status = kspell->status();
delete kspell;
kspell = 0;
if (status == KSpell::Error)
{
KMessageBox::sorry(this, i18n("ISpell could not be started.\n"
"Please make sure you have ISpell properly configured and in your PATH."));
}
else if (status == KSpell::Crashed)
{
eframe->spellcheck_stop();
statusBar()->changeItem (i18n("Spellcheck: Crashed"), ID_GENERAL);
KMessageBox::sorry(this, i18n("ISpell seems to have crashed."));
}
}
kedit'TopLevel::file_open() (./kdeutils/kedit/kedit.cpp:438)
void TopLevel::file_open( void )
{
while( 1 )
{
KURL url = KFileDialog::getOpenURL( QString::null, "*", this );
if( url.isEmpty() )
{
return;
}
TopLevel *toplevel;
if( location.isEmpty() == false || eframe->isModified() == true )
{
toplevel = new TopLevel();
if( toplevel == 0 )
{
return;
}
}
else
{
toplevel = this;
}
QString tmpfile;
KIO::NetAccess::download( url, tmpfile );
int result = toplevel->openFile( tmpfile, 0 );
KIO::NetAccess::removeTempFile( tmpfile );
if( result == KEDIT_OK )
{
if( toplevel != this ) { toplevel->show(); }
toplevel->location = url.path();
toplevel->setFileCaption();
recent->addURL( url );
toplevel->eframe->setModified(false);
toplevel->setGeneralStatusField(i18n("Done"));
toplevel->statusbar_slot();
break;
}
else if( result == KEDIT_RETRY )
{
if( toplevel != this ) { delete toplevel; }
}
else
{
if( toplevel != this ) { delete toplevel; }
break;
}
}
}
kedit'TopLevel::file_insert() (./kdeutils/kedit/kedit.cpp:491)
void TopLevel::file_insert()
{
/*
#warning for now...
bool tryAgain = false;
do {
QString fname = KFileDialog::getOpenFileName(QString::null, "*");
if (fname.isEmpty())
return; // Cancel
loading_slot();
int result = openFile(fname, OPEN_INSERT);
switch (result)
{
case KEDIT_OK :
{
setGeneralStatusField(i18n("Done"));
eframe->setModified(false);
add_recent_file(fname);
break;
}
case KEDIT_RETRY :
{
tryAgain = true;
break;
}
case KEDIT_OS_ERROR :
{
break;
}
default:
break;
}
} while (!tryAgain);
statusbar_slot();
*/
}
kedit'TopLevel::queryExit() (./kdeutils/kedit/kedit.cpp:530)
bool TopLevel::queryExit()
{
writeSettings();
return true;
}
kedit'TopLevel::queryClose() (./kdeutils/kedit/kedit.cpp:536)
bool TopLevel::queryClose()
{
int result;
if( !eframe->isModified() )
{
return true;
}
QString msg = i18n(""
"This document has been modified.\n"
"Would you like to save it?" );
switch( KMessageBox::warningYesNoCancel( this, msg ) )
{
case KMessageBox::Yes: // Save, then exit
result = saveFile(location);
if( result == KEDIT_USER_CANCEL )
{
return false;
}
if( result != KEDIT_OK)
{
msg = i18n(""
"Could not save the file.\n"
"Exit anyways?");
switch( KMessageBox::warningYesNo( this, msg ) )
{
case KMessageBox::Yes:
return true;
case KMessageBox::No:
default:
return false;
}
}
return true;
case KMessageBox::No: // Don't save but exit.
return true;
case KMessageBox::Cancel: // Don't save and don't exit.
default:
break; // Don't exit...
}
return false;
}
kedit'TopLevel::openRecent() (./kdeutils/kedit/kedit.cpp:584)
void TopLevel::openRecent(const KURL& url)
{
if (!url.isEmpty() || eframe->isModified())
{
TopLevel *t = new TopLevel ();
t->show();
t->openRecent(url);
return;
}
openURL( url, OPEN_READWRITE );
}
kedit'TopLevel::file_close() (./kdeutils/kedit/kedit.cpp:596)
void TopLevel::file_close()
{
if( eframe->isModified() )
{
QString msg = i18n("This document has been modified.\n"
"Would you like to save it?" );
switch( KMessageBox::warningYesNoCancel( this, msg ) )
{
case KMessageBox::Yes: // Save, then close
file_save();
if (eframe->isModified())
return; // Error during save.
break;
case KMessageBox::No: // Don't save but close.
break;
case KMessageBox::Cancel: // Don't save and don't close.
return;
break;
}
}
eframe->clear();
eframe->setModified(true);
location = QString::null;
setFileCaption();
statusbar_slot();
}
kedit'TopLevel::file_save() (./kdeutils/kedit/kedit.cpp:626)
void TopLevel::file_save()
{
if (location.isEmpty())
{
file_save_as();
return;
}
if ( eframe->isModified() )
{
KURL u( location );
if ( !u.isMalformed() && u.protocol() != "file" )
{
url_location = location;
saveURL( u );
statusbar_slot();
return;
}
int result = KEDIT_OK;
result = saveFile(location); // error messages are handled by saveFile
if ( result == KEDIT_OK ){
QString string;
string = i18n("Wrote: %1").arg(location);
setGeneralStatusField(string);
}
}
else
{
setGeneralStatusField(i18n("No changes need to be saved"));
}
}
kedit'TopLevel::setGeneralStatusField() (./kdeutils/kedit/kedit.cpp:661)
void TopLevel::setGeneralStatusField(const QString &text){
statusbar_timer->stop();
statusBar()->changeItem(text,ID_GENERAL);
statusbar_timer->start(10000,TRUE); // single shot
}
kedit'TopLevel::file_save_as() (./kdeutils/kedit/kedit.cpp:671)
void TopLevel::file_save_as()
{
KURL u = KFileDialog::getSaveURL(location, "*");
if (u.isEmpty())
return;
int result = saveURL(u); // error messages are handled by saveFile
if ( result == KEDIT_OK )
{
location = u.url();
setFileCaption();
QString string = i18n("Saved as: %1").arg(location);
setGeneralStatusField(string);
}
}
kedit'TopLevel::mail() (./kdeutils/kedit/kedit.cpp:690)
void TopLevel::mail()
{
Mail *maildlg = new Mail(this,"maildialog");
if( maildlg->exec() == QDialog::Rejected )
{
delete maildlg;
return;
}
kapp->processEvents();
kapp->flushX();
QString cmd;
cmd = cmd.sprintf(mOptionState.misc.mailCommand.ascii(),
maildlg->getSubject().ascii(),maildlg->getRecipient().ascii());
delete maildlg;
FILE* mailpipe = popen(cmd.ascii(),"w");
if( mailpipe == NULL )
{
QString msg = i18n(""
"Could not pipe the contents"
"of this document into:\n %1").arg(cmd);
KMessageBox::sorry( this, msg );
return;
}
QTextStream t(mailpipe,IO_WriteOnly );
int line_count = eframe->numLines();
for(int i = 0 ; i < line_count ; i++){
t << eframe->textLine(i) << '\n';
}
pclose(mailpipe);
}
/*
void TopLevel::fancyprint(){
QPrinter prt;
char buf[200];
if ( prt.setup(0) ) {
int y =10;
QPainter p;
p.begin( &prt );
p.setFont( eframe->font() );
QFontMetrics fm = p.fontMetrics();
int numlines = eframe->numLines();
for(int i = 0; i< numlines; i++){
y += fm.ascent();
QString line;
line = eframe->textLine(i);
line.replace( QRegExp("\t"), " " );
strncpy(buf,line.local8Bit(),160);
for (int j = 0 ; j <150; j++){
if (!isprint(buf[j]))
buf[j] = ' ';
}
buf[line.length()] = '\0';
p.drawText( 10, y, buf );
y += fm.descent();
}
p.end();
}
return ;
}
*/
kedit'TopLevel::helpselected() (./kdeutils/kedit/kedit.cpp:762)
void TopLevel::helpselected(){
kapp->invokeHTMLHelp( "" , "" );
}
kedit'TopLevel::search() (./kdeutils/kedit/kedit.cpp:768)
void TopLevel::search(){
eframe->search();
statusbar_slot();
}
kedit'TopLevel::replace() (./kdeutils/kedit/kedit.cpp:774)
void TopLevel::replace(){
eframe->replace();
statusbar_slot();
}
kedit'TopLevel::customize() (./kdeutils/kedit/kedit.cpp:781)
void TopLevel::customize( void )
{
if( mOptionDialog == 0 )
{
mOptionDialog = new COptionDialog( topLevelWidget(), 0, false );
if( mOptionDialog == 0 ) { return; }
connect( mOptionDialog, SIGNAL(fontChoice(const SFontState &)),
this, SLOT(setFontOption(const SFontState &)) );
connect( mOptionDialog, SIGNAL(colorChoice(const SColorState &)),
this, SLOT(setColorOption(const SColorState &)) );
connect( mOptionDialog, SIGNAL(spellChoice(const SSpellState &)),
this, SLOT(setSpellOption(const SSpellState &)) );
connect( mOptionDialog, SIGNAL(miscChoice(const SMiscState &)),
this, SLOT(setMiscOption(const SMiscState &)) );
}
if( mOptionDialog->isVisible() == false )
{
mOptionDialog->setState( mOptionState );
}
mOptionDialog->show();
}
kedit'TopLevel::editKeys() (./kdeutils/kedit/kedit.cpp:804)
void TopLevel::editKeys()
{
KKeyDialog::configureKeys(actionCollection(), xmlFile());
}
kedit'TopLevel::editToolbars() (./kdeutils/kedit/kedit.cpp:809)
void TopLevel::editToolbars()
{
KEditToolbar dlg(actionCollection());
if (dlg.exec())
createGUI();
}
kedit'TopLevel::setFontOption() (./kdeutils/kedit/kedit.cpp:817)
void TopLevel::setFontOption( const SFontState &font )
{
mOptionState.font = font;
eframe->setFont( mOptionState.font.font );
}
kedit'TopLevel::setColorOption() (./kdeutils/kedit/kedit.cpp:824)
void TopLevel::setColorOption( const SColorState &color )
{
mOptionState.color = color;
set_colors();
}
kedit'TopLevel::setSpellOption() (./kdeutils/kedit/kedit.cpp:831)
void TopLevel::setSpellOption( const SSpellState &spell )
{
mOptionState.spell = spell;
}
kedit'TopLevel::setMiscOption() (./kdeutils/kedit/kedit.cpp:837)
void TopLevel::setMiscOption( const SMiscState &misc )
{
mOptionState.misc = misc;
if( mOptionState.misc.wrapMode == SMiscState::fixedColumnWrap )
{
eframe->setWordWrap(QMultiLineEdit::FixedColumnWidth);
eframe->setWrapColumnOrWidth(mOptionState.misc.wrapColumn);
}
else if( mOptionState.misc.wrapMode == SMiscState::dynamicWrap )
{
eframe->setWordWrap(QMultiLineEdit::WidgetWidth);
}
else
{
eframe->setWordWrap(QMultiLineEdit::NoWrap);
}
//eframe->saveBackupCopy(mOptionState.misc.backupCheck);
}
kedit'TopLevel::toggleToolBar() (./kdeutils/kedit/kedit.cpp:859)
void TopLevel::toggleToolBar()
{
if(toolBar()->isVisible())
toolBar()->hide();
else
toolBar()->show();
}
kedit'TopLevel::toggleStatusBar() (./kdeutils/kedit/kedit.cpp:868)
void TopLevel::toggleStatusBar()
{
if (statusBar()->isVisible())
statusBar()->hide();
else
statusBar()->show();
}
kedit'TopLevel::search_again() (./kdeutils/kedit/kedit.cpp:877)
void TopLevel::search_again()
{
eframe->repeatSearch();
statusbar_slot();
}
kedit'TopLevel::setFileCaption() (./kdeutils/kedit/kedit.cpp:884)
void TopLevel::setFileCaption(){
setCaption(name());
}
kedit'TopLevel::gotoLine() (./kdeutils/kedit/kedit.cpp:890)
void TopLevel::gotoLine() {
eframe->doGotoLine();
}
kedit'TopLevel::statusbar_slot() (./kdeutils/kedit/kedit.cpp:894)
void TopLevel::statusbar_slot(){
QString linenumber;
linenumber = i18n("Line: %1 Col: %2")
.arg(eframe->currentLine() + 1)
.arg(eframe->currentColumn() +1);
statusBar()->changeItem(linenumber,ID_LINE_COLUMN);
}
kedit'TopLevel::print() (./kdeutils/kedit/kedit.cpp:907)
void TopLevel::print()
{
QString command;
QString com;
QString file;
int result;
if( eframe->isModified() )
{
QString msg = i18n(""
"The current document has been modified.\n"
"Would you like to save the changes before\n"
"printing this document?");
switch( KMessageBox::warningYesNoCancel( this, msg ) )
{
case KMessageBox::Yes: // Save, then print
result = saveFile(location);
if( result == KEDIT_USER_CANCEL )
{
return;
}
if( result != KEDIT_OK)
{
msg = i18n(""
"Could not save the file.\n"
"Print anyways?");
switch( KMessageBox::warningYesNo( this, msg ) )
{
case KMessageBox::Yes:
break;
case KMessageBox::No:
return;
break;
}
}
break;
case KMessageBox::No: // Don't save but print.
break;
case KMessageBox::Cancel: // Don't save and don't print.
return;
break;
}
}
PrintDialog *printDialog = new PrintDialog(this,"print",true);
printDialog->setWidgets(pi);
if(printDialog->exec() == QDialog::Rejected )
{
delete printDialog;
return;
}
pi = printDialog->getCommand();
delete printDialog;
if( location.isEmpty() )
{
//
// we go through all of this so that we can print an "Untitled" document
// quickly without going through the hassle of saving it. This will
// however result in a temporary filename and your printout will
// usually show that temp name, such as /tmp/00432aaa
// for a non "untitled" document we don't want that to happen so
// we asked the user to save before we print the document.
//
// TODO find a smarter solution for the above!
//
QString tmpname = tmpnam(NULL);
QFile file(tmpname);
file.open(IO_WriteOnly);
if(pi.selection)
{
if(file.writeBlock(eframe->markedText().ascii(),
eframe->markedText().length()) == -1)
{
result = KEDIT_OS_ERROR;
}
else
{
result = KEDIT_OK;
}
}
else
{
if(file.writeBlock(eframe->text().ascii(),
eframe->text().length()) == -1)
{
result = KEDIT_OS_ERROR;
}
else
{
result = KEDIT_OK;
}
}
file.close();
// TODO error handling
if (pi.raw)
{
command = "lpr";
}
else
{
command = pi.command;
}
com = QString("%1 %2 ; rm %3 &").arg(command).arg(tmpname).arg(tmpname);
system(com.ascii());
QString string;
if(pi.selection)
string = i18n("Printing: %1 Untitled (Selection)").arg(command);
else
string = i18n("Printing: %1 Untitled").arg(command);
setGeneralStatusField(string);
}
else // document name != Untiteled
{
QString tmpname = tmpnam(NULL);
if( pi.selection )
{
// print only the selection
QFile file(tmpname);
file.open(IO_WriteOnly);
if(file.writeBlock(eframe->markedText().ascii(),
eframe->markedText().length()) == -1)
{
result = KEDIT_OS_ERROR;
}
file.close();
// TODO error handling
}
if(pi.raw)
{
command = "lpr";
}
else
{
command = pi.command;
}
if(!pi.selection) // print the whole file
{
com = QString ("%s '%s' &").arg(command).arg(location);
system(com.ascii());
QString string;
string = i18n("Printing: %1").arg(com);
setGeneralStatusField(string);
}
else // print only the selection
{
com = QString ("%1 %2 ; rm %3 &").arg(command).arg(tmpname).arg(tmpname);
system(com.ascii());
QString string = i18n("Printing: %1 %2 (Selection)")
.arg(command).arg(location);
setGeneralStatusField(string);
}
//kdebug(0, 0, com.ascii());
}
}
kedit'TopLevel::setSensitivity() (./kdeutils/kedit/kedit.cpp:1082)
void TopLevel::setSensitivity (){
}
kedit'TopLevel::save_options() (./kdeutils/kedit/kedit.cpp:1086)
void TopLevel::save_options(){
writeSettings();
}
kedit'TopLevel::saveURL() (./kdeutils/kedit/kedit.cpp:1092)
int TopLevel::saveURL( const KURL& _url )
{
if ( _url.isMalformed() )
{
KMessageBox::sorry(this, i18n("Malformed URL"));
return KEDIT_RETRY;
}
// Just a usual file ?
if ( _url.isLocalFile() )
{
return saveFile( _url.url() );
}
QString tmpFile;
tmpFile = QString("/tmp/kedit%1").arg(time( 0L ));
eframe->setModified( true );
saveFile( tmpFile );
if (KIO::NetAccess::upload( tmpFile, _url ) == false)
{
KMessageBox::error(this, "Could not save remote file");
return KEDIT_RETRY;
}
return true;
}
kedit'TopLevel::openFile() (./kdeutils/kedit/kedit.cpp:1120)
int TopLevel::openFile( const QString& _url, int _mode )
{
location=_url;
setFileCaption();
KURL *u = new KURL( _url );
if ( u->isMalformed() )
{
KMessageBox::sorry(this, i18n("This is not a valid filename.\n"));
return KEDIT_RETRY;
}
if ( !u->isLocalFile() )
{
KMessageBox::sorry(this, i18n("This is not a local file.\n"));
return KEDIT_RETRY;
}
QFileInfo info(u->path());
if(!info.exists())
{
KMessageBox::sorry(this, i18n("The specified file does not exist"));
return KEDIT_RETRY;
}
if(info.isDir())
{
KMessageBox::sorry(this, i18n("You have specified a directory"));
return KEDIT_RETRY;
}
QFile file(u->path());
if(!file.open(IO_ReadOnly))
{
KMessageBox::sorry(this, i18n("You do not have read permission to this file."));
return KEDIT_RETRY;
}
QTextStream stream(&file);
if ((_mode & OPEN_INSERT) == 0)
{
eframe->clear();
}
eframe->insertText( &stream );
eframe->setModified(false);
return KEDIT_OK;
}
kedit'TopLevel::saveFile() (./kdeutils/kedit/kedit.cpp:1169)
int TopLevel::saveFile( const QString& _url )
{
KURL *u = new KURL( _url );
if ( u->isMalformed() )
{
KMessageBox::sorry(this, i18n("This is not a valid filename.\n"));
return KEDIT_RETRY;
}
if ( !u->isLocalFile() )
{
KMessageBox::sorry(this, i18n("This is not a local file.\n"));
return KEDIT_RETRY;
}
QFileInfo info(u->path());
if(info.isDir())
{
KMessageBox::sorry(this, i18n("You have specified a directory"));
return KEDIT_RETRY;
}
KSaveFile file(u->path());
if(file.status() != 0)
{
KMessageBox::sorry(this, i18n("Unable to write to file."));
return KEDIT_RETRY;
}
eframe->saveText( file.textStream() );
if (!file.close())
if(file.status() != 0)
{
KMessageBox::sorry(this, i18n("Could not save file."));
return KEDIT_RETRY;
}
eframe->setModified(false);
return KEDIT_OK;
}
kedit'TopLevel::openURL() (./kdeutils/kedit/kedit.cpp:1211)
void TopLevel::openURL( const KURL& _url, int _mode )
{
qDebug("TopLevel::openURL: %s", _url.url().ascii());
QString netFile = _url.url();
if ( _url.isMalformed() )
{
QString string;
string = i18n( "Malformed URL\n%1").arg(netFile);
KMessageBox::sorry(this, string);
return;
}
QString target;
if (KIO::NetAccess::download(_url, target) == false)
{
// this needs to be handled within KIO sooooon
KMessageBox::error(this, i18n("Cannot download file!"));
return;
}
int result = openFile(target, 0);
if (result == KEDIT_OK)
{
location = netFile;
setFileCaption();
recent->addURL(_url);
eframe->setModified(false);
setGeneralStatusField(i18n("Done"));
}
}
kedit'TopLevel::urlDrop_slot() (./kdeutils/kedit/kedit.cpp:1243)
void TopLevel::urlDrop_slot(QDropEvent* e) {
dropEvent(e);
}
kedit'TopLevel::dragEnterEvent() (./kdeutils/kedit/kedit.cpp:1248)
void TopLevel::dragEnterEvent(QDragEnterEvent* e)
{
e->accept(QUriDrag::canDecode(e));
}
kedit'TopLevel::dropEvent() (./kdeutils/kedit/kedit.cpp:1253)
void TopLevel::dropEvent(QDropEvent* e)
{
QStrList list;
// This should never happen, but anyway...
if(!QUriDrag::decode(e, list))
return;
char *s;
for ( s = list.first(); s != 0L; s = list.next() )
{
// Load the first file in this window
if ( s == list.getFirst() && !eframe->isModified() )
{
openURL( KURL(s), OPEN_READWRITE );
}
else
{
setGeneralStatusField(i18n("New Window"));
TopLevel *t = new TopLevel ();
t->show ();
setGeneralStatusField(i18n("New Window Created"));
t->openURL( KURL(s), OPEN_READWRITE );
setGeneralStatusField(i18n("Load Command Done"));
}
}
}
kedit'TopLevel::timer_slot() (./kdeutils/kedit/kedit.cpp:1283)
void TopLevel::timer_slot(){
statusBar()->changeItem("",ID_GENERAL);
}
kedit'TopLevel::set_colors() (./kdeutils/kedit/kedit.cpp:1291)
void TopLevel::set_colors(){
QPalette mypalette = (eframe->palette()).copy();
QColorGroup cgrp = mypalette.normal();
QColorGroup ncgrp( mOptionState.color.textFg, cgrp.background(),
cgrp.light(),cgrp.dark(),cgrp.mid(), mOptionState.color.textFg,
mOptionState.color.textBg );
mypalette.setNormal(ncgrp);
mypalette.setDisabled(ncgrp);
mypalette.setActive(ncgrp);
eframe->setPalette(mypalette);
eframe->setBackgroundColor(mOptionState.color.textBg);
}
kedit'TopLevel::readSettings() (./kdeutils/kedit/kedit.cpp:1311)
void TopLevel::readSettings( void )
{
//
// Default settings. The values in mOptionState is defined in
// optionstate.h
//
editor_width = 550;
editor_height = 400;
show_statusbar = TRUE;
show_toolbar = TRUE;
pi.command = "enscript -2rG";
pi.raw = 1;
pi.selection = 0;
QString str;
config = kapp->config();
config->setGroup( "Text Font" );
mOptionState.font.font = config->readFontEntry("KEditFont",
&mOptionState.font.font);
recent->loadEntries( config );
config->setGroup("General Options");
url_location = config->readEntry( "default_url",
"ftp://localhost/welcome.msg" );
mOptionState.misc.mailCommand = config->readEntry("MailCmd",
mOptionState.misc.mailCommand );
str = config->readEntry("Width");
if( str.isNull() == false )
editor_width = str.toInt();
str = config->readEntry("Height");
if( str.isNull() == false )
editor_height = str.toInt();
str = config->readEntry( "StatusBar" );
if( str.isNull() == false && str.find( "off" ) == 0 )
{
show_statusbar = FALSE;
enableStatusBar( KStatusBar::Hide );
}
else
{
show_statusbar = TRUE;
enableStatusBar( KStatusBar::Show );
}
str = config->readEntry( "ToolBar" );
if( str.isNull() == false && str.find( "off" ) == 0 )
{
show_toolbar = FALSE;
enableToolBar( KToolBar::Hide );
}
else
{
show_toolbar = TRUE;
enableToolBar( KToolBar::Show );
}
str = config->readEntry("WrapMode");
if( str.isNull() == false )
mOptionState.misc.wrapMode = str.toInt();
str = config->readEntry("WrapColumn");
if( str.isNull() == false )
mOptionState.misc.wrapColumn = str.toInt();
str = config->readEntry("BackupCopies");
if( str.isNull() == false )
mOptionState.misc.backupCheck = (bool) str.toInt();
str = config->readEntry( "ForeColor" );
if( str.isNull() == false )
mOptionState.color.textFg.setNamedColor( str );
str = config->readEntry( "BackColor" );
if( str.isNull() == false )
mOptionState.color.textBg.setNamedColor( str );
///////////////////////////////////////////////////
config->setGroup("Printing");
str = config->readEntry("PrntCmd1");
if ( str.isNull() == false )
pi.command = str;
str = config->readEntry("PrintSelection");
if ( str.isNull() == false )
pi.selection = str.toInt();
str = config->readEntry("PrintRaw");
if ( str.isNull() == false )
pi.raw = str.toInt();
}
kedit'TopLevel::writeSettings() (./kdeutils/kedit/kedit.cpp:1410)
void TopLevel::writeSettings( void )
{
config = kapp->config();
config->setGroup( "Text Font" );
config->writeEntry("KEditFont", mOptionState.font.font );
recent->saveEntries( config );
config->setGroup("General Options");
config->writeEntry("default_url", url_location);
config->writeEntry("Width", QString().setNum(width()) );
config->writeEntry("Heigh", QString().setNum(height()) );
config->writeEntry( "StatusBar", show_statusbar ? "on" : "off" );
config->writeEntry( "ToolBar", show_toolbar ? "on" : "off" );
config->writeEntry("MailCmd", mOptionState.misc.mailCommand );
QString string;
string.setNum( mOptionState.misc.wrapMode );
config->writeEntry("WrapMode", string);
string.setNum( mOptionState.misc.wrapColumn );
config->writeEntry("WrapColumn", string);
string="";
string.setNum( (int) mOptionState.misc.backupCheck );
config->writeEntry("BackupCopies", string);
QColor &fg = mOptionState.color.textFg;
string.sprintf("#%02x%02x%02x", fg.red(), fg.green(), fg.blue() );
config->writeEntry( "ForeColor", string );
QColor &bg = mOptionState.color.textBg;
string.sprintf("#%02x%02x%02x", bg.red(),bg.green(), bg.blue());
config->writeEntry( "BackColor", string );
////////////////////////////////////////////////////
config->setGroup("Printing");
config->writeEntry("PrntCmd1", pi.command);
string.setNum( pi.selection );
config->writeEntry("PrintSelection", string);
string.setNum( pi.raw );
config->writeEntry("PrintRaw", string);
config->sync();
}
kedit'TopLevel::toggle_overwrite() (./kdeutils/kedit/kedit.cpp:1464)
void TopLevel::toggle_overwrite(){
if(eframe->isOverwriteMode()){
statusBar()->changeItem("OVR",ID_INS_OVR);
}
else{
statusBar()->changeItem("INS",ID_INS_OVR);
}
}