summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-28 15:05:31 (UTC)
committer llornkcor <llornkcor>2002-07-28 15:05:31 (UTC)
commit1619cf87bd1db9e991dd22f528798e1463344d4c (patch) (side-by-side diff)
tree0a8a4edc1967cf194a3ed0e974ad8ee17fcd9a86
parenta0e8d4d1d1e442b7d11723d055e49f46167d24c1 (diff)
downloadopie-1619cf87bd1db9e991dd22f528798e1463344d4c.zip
opie-1619cf87bd1db9e991dd22f528798e1463344d4c.tar.gz
opie-1619cf87bd1db9e991dd22f528798e1463344d4c.tar.bz2
added Insert Time adn Date to edit menu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp24
-rw-r--r--core/apps/textedit/textedit.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 9e6ba8d..107695a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,104 +1,108 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
// changes added by L. J. Potter Sun 02-17-2002 21:31:31
#include "textedit.h"
#include "filePermissions.h"
#include "fontDialog.h"
#include <opie/ofileselector.h>
#include <opie/ofiledialog.h>
#include <qpe/fontdatabase.h>
#include <qpe/global.h>
#include <qpe/fileselector.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/qcopenvelope_qws.h>
+#include <qdatetime.h>
+#include <qclipboard.h>
#include <qstringlist.h>
#include <qaction.h>
#include <qcolordialog.h>
#include <qfileinfo.h>
#include <qlineedit.h>
#include <qmessagebox.h>
#include <qobjectlist.h>
#include <qpopupmenu.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <qwidgetstack.h>
#include <qcheckbox.h>
#include <qcombo.h>
+
#include <unistd.h>
#include <sys/stat.h>
-
#include <stdlib.h> //getenv
+
+
/* 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",
@@ -245,96 +249,103 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
setIcon( Resource::loadPixmap( "TextEditor" ) );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
menu = bar;
QPEMenuBar *mb = new QPEMenuBar( bar );
QPopupMenu *file = new QPopupMenu( this );
QPopupMenu *edit = new QPopupMenu( this );
font = new QPopupMenu( this );
bar = new QPEToolBar( this );
editBar = bar;
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 );
a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
a->addTo( bar );
a->addTo( file );
a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
file->insertSeparator();
a->addTo( file );
a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
a->addTo( file );
a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( editBar );
a->addTo( edit );
a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
a->addTo( editBar );
a->addTo( edit );
a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( editBar );
a->addTo( edit );
+
+#ifndef QT_NO_CLIPBOARD
+ a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
+ a->addTo( edit );
+#endif
+
a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
edit->insertSeparator();
a->addTo( bar );
a->addTo( edit );
int defsize;
bool defb, defi, wrap;
Config cfg("TextEdit");
cfg.setGroup("View");
defsize = cfg.readNumEntry("FontSize",10);
defb = cfg.readBoolEntry("Bold",FALSE);
defi = cfg.readBoolEntry("Italic",FALSE);
wrap = cfg.readBoolEntry("Wrap",TRUE);
zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
zin->addTo( font );
zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
zout->addTo( font );
font->insertSeparator();
#if 0
QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 );
connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) );
ba->setToggleAction(TRUE);
ba->addTo( font );
QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 );
connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) );
ia->setToggleAction(TRUE);
ia->addTo( font );
ba->setOn(defb);
ia->setOn(defi);
font->insertSeparator();
#endif
QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
wa->setToggleAction(TRUE);
wa->addTo( font );
@@ -466,97 +477,97 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up)
if ( fontsize[i] > sz ) {
s = fontsize[i];
break;
}
}
}
QFont f = editor->font();
f.setPointSize(s);
editor->setFont(f);
zin->setEnabled(s != fontsize[nfontsizes-1]);
zout->setEnabled(s != fontsize[0]);
}
void TextEdit::setBold(bool y)
{
QFont f = editor->font();
f.setBold(y);
editor->setFont(f);
}
void TextEdit::setItalic(bool y)
{
QFont f = editor->font();
f.setItalic(y);
editor->setFont(f);
}
void TextEdit::setWordWrap(bool y)
{
bool state = editor->edited();
editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
editor->setEdited( state );
}
void TextEdit::fileNew()
{
// if( !bFromDocView ) {
// saveAs();
// }
newFile(DocLnk());
}
void TextEdit::fileOpen()
{
Config cfg("TextEdit");
cfg.setGroup("View");
- bool b=FALSE;
+ // bool b=FALSE;
QMap<QString, QStringList> map;
map.insert(tr("All"), QStringList() );
QStringList text;
text << "text/*";
map.insert(tr("Text"), text );
text << "*";
map.insert(tr("All"), text );
QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);
if(!str.isEmpty() )
openFile( str );
}
void TextEdit::doSearchBar()
{
Config cfg("TextEdit");
cfg.setGroup("View");
if(cfg.readEntry("SearchBar","Closed") != "Opened")
searchBar->hide();
}
#if 0
void TextEdit::slotFind()
{
FindDialog frmFind( tr("Text Editor"), this );
connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
editor, SLOT(slotDoFind( const QString&,bool,bool)));
//case sensitive, backwards, [category]
connect( editor, SIGNAL(notFound()),
&frmFind, SLOT(slotNotFound()) );
connect( editor, SIGNAL(searchWrapped()),
&frmFind, SLOT(slotWrapAround()) );
frmFind.exec();
}
#endif
void TextEdit::fileRevert()
{
clear();
fileOpen();
}
@@ -937,48 +948,57 @@ void TextEdit::editDelete()
break;
case 1:
// exit
break;
};
}
void TextEdit::changeStartConfig( bool b ) {
Config cfg("TextEdit");
cfg.setGroup("View");
if(b) {
qDebug("bool");
cfg.writeEntry("startNew","TRUE");
} else {
cfg.writeEntry("startNew","FALSE");
}
update();
}
void TextEdit::editorChanged() {
if(editor->edited() && edited && !edited1) {
setCaption( "*"+caption());
edited1=TRUE;
}
edited=TRUE;
}
void TextEdit::receive(const QCString&msg, const QByteArray&) {
qDebug("QCop "+msg);
if ( msg == "setDocument(QString)" ) {
qDebug("bugger all");
}
}
void TextEdit::doAbout() {
QMessageBox::about(0,"Text Edit","Text Edit is copyright\n"
"2000 Trolltech AS, and\n"
"2002 by L.J.Potter \nljp@llornkcor.com\n"
"and is licensed under the GPL");
}
void TextEdit::doAdvanced(bool b) {
useAdvancedFeatures=b;
Config cfg("TextEdit");
cfg.setGroup("View");
cfg.writeEntry("AdvancedFeatures",b);
}
+
+void TextEdit::editPasteTimeDate() {
+#ifndef QT_NO_CLIPBOARD
+ QClipboard *cb = QApplication::clipboard();
+ QDateTime dt = QDateTime::currentDateTime();
+ cb->setText( dt.toString());
+ editor->paste();
+#endif
+}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index aec6427..a2badaa 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -24,96 +24,97 @@
#define QTEXTEDIT_OPEN_API
//#include "fileBrowser.h"
//#include "fileSaver.h"
#include <qpe/filemanager.h>
#include <qpe/qcopenvelope_qws.h>
#include <opie/ofileselector.h>
#include <qmainwindow.h>
#include <qmultilineedit.h>
#include <qlist.h>
#include <qmap.h>
class QAction;
class QWidgetStack;
class QToolButton;
class QPopupMenu;
class QToolBar;
class QLineEdit;
class QAction;
class FileSelector;
class QpeEditor;
class QPopupMenu;
class TextEdit : public QMainWindow
{
Q_OBJECT
public:
TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~TextEdit();
QPopupMenu *font;
QAction *nStart, *nFileDlgOpt, *nAdvanced;
bool edited, edited1;
void openFile( const QString & );
QCopChannel * channel;
public slots:
void editorChanged();
void receive(const QCString&, const QByteArray&);
protected:
bool fileIs, useAdvancedFeatures;
void closeEvent( QCloseEvent *e );
void doSearchBar();
private slots:
+ void editPasteTimeDate();
void doAdvanced(bool);
void doAbout();
void setDocument(const QString&);
void changeFont();
void fileNew();
void fileRevert();
void fileOpen();
void changeStartConfig(bool);
bool save();
bool saveAs();
void cleanUp();
void editCut();
void editCopy();
void editPaste();
void editFind();
void editDelete();
void findNext();
void findClose();
void search();
void accept();
void newFile( const DocLnk & );
void openFile( const DocLnk & );
void showEditTools();
void zoomIn();
void zoomOut();
void setBold(bool y);
void setItalic(bool y);
void setWordWrap(bool y);
private:
void colorChanged( const QColor &c );
void clear();
void updateCaption( const QString &name=QString::null );
void setFontSize(int sz, bool round_down_not_up);
private:
// fileSaver *fileSaveDlg;
// fileBrowser *browseForFiles;
QpeEditor* editor;
QToolBar *menu, *editBar, *searchBar;
QLineEdit *searchEdit;
DocLnk *doc;