summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp78
-rw-r--r--noncore/applets/notesapplet/notes.h6
2 files changed, 80 insertions, 4 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 81864c6..2d38e97 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -18,32 +18,35 @@
#include <qapplication.h>
#include <stdlib.h>
#include <qstringlist.h>
#include <qpe/filemanager.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qpe/timestring.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
-#include <qsocket.h>
+#include <qpe/ir.h>
+// #include <qsocket.h>
+// #include <qclipboard.h>
#include <qmultilineedit.h>
#include <qlistbox.h>
#include <qpopupmenu.h>
#include <qmessagebox.h>
#include <qdir.h>
+#include <qfile.h>
#include <qpoint.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qlayout.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qstring.h>
#include <qtimer.h>
/* XPM */
static char * notes_xpm[] = {
"16 16 11 1",
@@ -81,66 +84,84 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
loaded=false;
edited=false;
doPopulate=true;
QVBoxLayout *vbox = new QVBoxLayout( this,0, -1, "Vlayout" );
QHBoxLayout *hbox = new QHBoxLayout( this, 0, -1, "HLayout" );
view = new QMultiLineEdit(this, "OpieNotesView");
box = new QListBox(this, "OpieNotesBox");
+
QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold);
+
box->setFixedHeight(50);
vbox->setMargin( 6 );
vbox->setSpacing( 3 );
vbox->addWidget( view);
vbox->addWidget( box);
setFixedHeight(180);
QWidget *wid = QPEApplication::desktop();
setFixedWidth( wid->width()-10 /*200*/);
setFocusPolicy(QWidget::StrongFocus);
newButton= new QPushButton( this, "newButton" );
newButton->setText(tr("New"));
hbox->addWidget( newButton);
+ saveButton= new QPushButton( this, "saveButton" );
+ saveButton->setText(tr("Save"));
+ hbox->addWidget( saveButton);
+
deleteButton= new QPushButton( this, "deleteButton" );
deleteButton->setText(tr("Delete"));
hbox->addWidget( deleteButton);
vbox->addItem(hbox);
connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)),
this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) );
+
connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &)));
+
connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) );
connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) );
+
connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton()));
+ connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton()));
connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
populateBox();
load();
setCaption("Notes");
// parent->setFocus();
}
+void NotesControl::slotSaveButton() {
+ if(edited) {
+ save();
+ populateBox();
+ }
+}
+
void NotesControl::slotDeleteButtonClicked() {
- switch ( QMessageBox::warning(this,tr("Delete?"),tr("Do you really want to<BR><B> delete</B> this note ?")
+ switch ( QMessageBox::warning(this,tr("Delete?")
+ ,tr("Do you really want to<BR><B> delete</B> this note ?")
,tr("Yes"),tr("No"),0,1,1) ) {
case 0:
slotDeleteButton();
break;
};
}
void NotesControl::slotDeleteButton() {
QString selectedText = box->currentText();
qDebug("deleting "+selectedText);
@@ -171,50 +192,71 @@ void NotesControl::slotDeleteButton() {
}
}
populateBox();
}
}
void NotesControl::slotNewButton() {
if(edited) save();
view->clear();
view->setFocus();
}
-void NotesControl::boxPressed(int mouse, QListBoxItem *item, const QPoint&) {
+void NotesControl::slotBeamButton() {
+ Ir ir;
+ if(!ir.supported()){
+ } else {
+ this->hide();
+ QString selectedText = box->currentText();
+ if( !selectedText.isEmpty()) {
+ QString file = QDir::homeDirPath()+"/"+selectedText;
+ QFile f(file);
+ Ir *irFile = new Ir(this, "IR");
+ connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished( Ir * )));
+ irFile->send( file, "Note", "text/plain" );
+ }
+ }
+}
+
+void NotesControl::slotBeamFinished(Ir *) {
+ this->show();
+}
+
+void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) {
switch (mouse) {
case 1:{
}
break;
case 2:
menuTimer.start( 500, TRUE );
break;
};
}
void NotesControl::slotBoxSelected(const QString &itemString) {
if(edited) {
save();
}
loaded=false;
edited=false;
load(itemString);
}
void NotesControl::showMenu() {
QPopupMenu *m = new QPopupMenu(0);
+ m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() ));
+ m->insertSeparator();
m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() ));
-
m->setFocus();
m->exec( QCursor::pos() );
if(m) delete m;
}
void NotesControl::focusOutEvent ( QFocusEvent * e) {
if( e->reason() == QFocusEvent::Popup)
save();
else {
if(!loaded) {
@@ -247,24 +289,26 @@ void NotesControl::save() {
if ( docname.isEmpty() )
docname = "Empty Text";
qDebug(docname);
if( oldDocName != docname) {
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
cfg.writeEntry( entryName,docname );
cfg.writeEntry("NumberOfFiles", noOfFiles+1 );
cfg.write();
}
+ else
+ qDebug("oldname equals docname");
doc = new DocLnk(docname);
doc->setType("text/plain");
doc->setFile(docname);
doc->setName(docname);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
}
oldDocName=docname;
edited=false;
@@ -284,24 +328,25 @@ void NotesControl::populateBox() {
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QStringList list;
QString entryName;
for ( int i = 0; i < noOfFiles; i++ ) {
entryName.sprintf( "File%i", i + 1 );
list.append(cfg.readEntry( entryName ));
}
list.sort();
box->insertStringList(list,-1);
doPopulate=false;
+ update();
}
void NotesControl::load() {
if(!loaded) {
Config cfg("Notes");
cfg.setGroup("Docs");
QString lastDoc=cfg.readEntry( "LastDoc","");
DocLnk nf;
nf.setType("text/plain");
nf.setFile(lastDoc);
@@ -337,24 +382,49 @@ void NotesControl::loadDoc( const DocLnk &f) {
if ( !fm.loadFile( f, txt ) ) {
return;
}
view->setText(txt);
}
void NotesControl::slotViewEdited() {
if(loaded) {
edited=true;
}
}
+// void NotesControl::keyReleaseEvent( QKeyEvent *e) {
+
+// switch ( e->state() ) {
+// case ControlButton:
+// if(e->key() == Key_C) { //copy
+// qDebug("copy");
+// QClipboard *cb = QApplication::clipboard();
+// QString text;
+
+// // Copy text from the clipboard (paste)
+// text = cb->text();
+// }
+// if(e->key() == Key_X) { //cut
+// }
+// if(e->key() == Key_V) { //paste
+// QClipboard *cb = QApplication::clipboard();
+// QString text;
+// view
+// cb->setText();
+// }
+// break;
+// };
+// QWidget::keyReleaseEvent(e);
+// }
+
//===========================================================================
NotesApplet::NotesApplet( QWidget *parent, const char *name )
: QWidget( parent, name ) {
setFixedHeight( 18 );
setFixedWidth( 14 );
vc = new NotesControl;
}
NotesApplet::~NotesApplet() {
}
diff --git a/noncore/applets/notesapplet/notes.h b/noncore/applets/notesapplet/notes.h
index 473a89a..a593881 100644
--- a/noncore/applets/notesapplet/notes.h
+++ b/noncore/applets/notesapplet/notes.h
@@ -12,24 +12,25 @@
**
**********************************************************************/
#ifndef __NOTES_APPLET_H__
#define __NOTES_APPLET_H__
#include <qwidget.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qguardedptr.h>
#include <qtimer.h>
#include <qpe/filemanager.h>
+#include <qpe/ir.h>
#include <qstring.h>
class QComboBox;
class QCheckBox;
class QSpinBox;
class QPushButton;
class QMultiLineEdit;
class QListBox;
class QListBoxItem;
class NotesControl : public QFrame {
Q_OBJECT
public:
@@ -44,32 +45,37 @@ public:
bool loaded, edited, doPopulate;
void save();
void populateBox();
void load();
private:
QTimer menuTimer;
DocLnk *doc;
QString oldDocName;
void focusOutEvent( QFocusEvent * );
void load(const QString&);
private slots:
+ void slotBeamButton();
+ void slotBeamFinished( Ir*);
void slotDeleteButton();
+ void slotSaveButton();
void slotDeleteButtonClicked();
void slotNewButton();
void boxPressed(int, QListBoxItem *, const QPoint&);
void showMenu();
void loadDoc( const DocLnk &);
void slotViewEdited();
void slotBoxSelected(const QString &);
+// void keyReleaseEvent( QKeyEvent *);
+
};
class NotesApplet : public QWidget {
Q_OBJECT
public:
NotesApplet( QWidget *parent = 0, const char *name=0 );
~NotesApplet();
NotesControl *vc;
public slots:
private:
void mousePressEvent( QMouseEvent * );
void paintEvent( QPaintEvent* );