summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-27 20:19:09 (UTC)
committer llornkcor <llornkcor>2002-09-27 20:19:09 (UTC)
commitd7bcdda1857ff31830705921d8248200d881cf93 (patch) (unidiff)
treefe75820a9ffa1e2340e4dcb02ffafed36a585a46
parentf9712865139ba9831ef188d4e00d1b75dda4f261 (diff)
downloadopie-d7bcdda1857ff31830705921d8248200d881cf93.zip
opie-d7bcdda1857ff31830705921d8248200d881cf93.tar.gz
opie-d7bcdda1857ff31830705921d8248200d881cf93.tar.bz2
save makes new
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 76cb6c1..f2dbabf 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -99,100 +99,98 @@ NotesControl::NotesControl( QWidget *parent, const char *name )
99 box->setFixedHeight(50); 99 box->setFixedHeight(50);
100 100
101 vbox->setMargin( 6 ); 101 vbox->setMargin( 6 );
102 vbox->setSpacing( 3 ); 102 vbox->setSpacing( 3 );
103 103
104 vbox->addWidget( view); 104 vbox->addWidget( view);
105 vbox->addWidget( box); 105 vbox->addWidget( box);
106 106
107 setFixedHeight(180); 107 setFixedHeight(180);
108 QWidget *wid = QPEApplication::desktop(); 108 QWidget *wid = QPEApplication::desktop();
109 setFixedWidth( wid->width()-10 /*200*/); 109 setFixedWidth( wid->width()-10 /*200*/);
110 110
111 setFocusPolicy(QWidget::StrongFocus); 111 setFocusPolicy(QWidget::StrongFocus);
112 112
113 newButton= new QPushButton( this, "newButton" ); 113 newButton= new QPushButton( this, "newButton" );
114 newButton->setText(tr("New")); 114 newButton->setText(tr("New"));
115 hbox->addWidget( newButton); 115 hbox->addWidget( newButton);
116 116
117 saveButton= new QPushButton( this, "saveButton" ); 117 saveButton= new QPushButton( this, "saveButton" );
118 saveButton->setText(tr("Save")); 118 saveButton->setText(tr("Save"));
119 hbox->addWidget( saveButton); 119 hbox->addWidget( saveButton);
120 120
121 deleteButton= new QPushButton( this, "deleteButton" ); 121 deleteButton= new QPushButton( this, "deleteButton" );
122 deleteButton->setText(tr("Delete")); 122 deleteButton->setText(tr("Delete"));
123 hbox->addWidget( deleteButton); 123 hbox->addWidget( deleteButton);
124 124
125 vbox->addItem(hbox); 125 vbox->addItem(hbox);
126 126
127 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)), 127 connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)),
128 this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) ); 128 this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) );
129 129
130 connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &))); 130 connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &)));
131 131
132 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); 132 connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) );
133 133
134 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); 134 connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) );
135 135
136 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); 136 connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton()));
137 connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); 137 connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton()));
138 connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); 138 connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
139 139
140 populateBox(); 140 populateBox();
141 load(); 141 load();
142 setCaption("Notes"); 142 setCaption("Notes");
143 // parent->setFocus(); 143 // parent->setFocus();
144} 144}
145 145
146void NotesControl::slotSaveButton() { 146void NotesControl::slotSaveButton() {
147 if(edited) { 147 slotNewButton();
148 save(); 148 populateBox();
149 populateBox();
150 }
151} 149}
152 150
153void NotesControl::slotDeleteButtonClicked() { 151void NotesControl::slotDeleteButtonClicked() {
154 switch ( QMessageBox::warning(this,tr("Delete?") 152 switch ( QMessageBox::warning(this,tr("Delete?")
155 ,tr("Do you really want to<BR><B> delete</B> this note ?") 153 ,tr("Do you really want to<BR><B> delete</B> this note ?")
156 ,tr("Yes"),tr("No"),0,1,1) ) { 154 ,tr("Yes"),tr("No"),0,1,1) ) {
157 case 0: 155 case 0:
158 slotDeleteButton(); 156 slotDeleteButton();
159 break; 157 break;
160 }; 158 };
161} 159}
162 160
163void NotesControl::slotDeleteButton() { 161void NotesControl::slotDeleteButton() {
164 162
165 QString selectedText = box->currentText(); 163 QString selectedText = box->currentText();
166 qDebug("deleting "+selectedText); 164 qDebug("deleting "+selectedText);
167 165
168 if( !selectedText.isEmpty()) { 166 if( !selectedText.isEmpty()) {
169 167
170 Config cfg("Notes"); 168 Config cfg("Notes");
171 cfg.setGroup("Docs"); 169 cfg.setGroup("Docs");
172 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 170 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
173 QString entryName, entryName2;; 171 QString entryName, entryName2;;
174 for ( int i = 0; i < noOfFiles; i++ ) { 172 for ( int i = 0; i < noOfFiles; i++ ) {
175 entryName.sprintf( "File%i", i + 1 ); 173 entryName.sprintf( "File%i", i + 1 );
176 if(selectedText == cfg.readEntry( entryName )) { 174 if(selectedText == cfg.readEntry( entryName )) {
177 qDebug("removing %s, %d", selectedText.latin1(), i); 175 qDebug("removing %s, %d", selectedText.latin1(), i);
178 for ( int j = i; j < noOfFiles; j++ ) { 176 for ( int j = i; j < noOfFiles; j++ ) {
179 entryName.sprintf( "File%i", i + 1 ); 177 entryName.sprintf( "File%i", i + 1 );
180 entryName2.sprintf( "File%i", i + 2 ); 178 entryName2.sprintf( "File%i", i + 2 );
181 QString temp = cfg.readEntry(entryName2); 179 QString temp = cfg.readEntry(entryName2);
182 qDebug("move "+temp); 180 qDebug("move "+temp);
183 cfg.writeEntry(entryName, temp); 181 cfg.writeEntry(entryName, temp);
184 i++; 182 i++;
185 } 183 }
186 cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); 184 cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
187 entryName.sprintf( "File%i", noOfFiles ); 185 entryName.sprintf( "File%i", noOfFiles );
188 cfg.removeEntry(entryName); 186 cfg.removeEntry(entryName);
189 cfg.write(); 187 cfg.write();
190 DocLnk nf(selectedText); 188 DocLnk nf(selectedText);
191 nf.removeFiles(); 189 nf.removeFiles();
192 } 190 }
193 } 191 }
194 populateBox(); 192 populateBox();
195 } 193 }
196} 194}
197 195
198void NotesControl::slotNewButton() { 196void NotesControl::slotNewButton() {