2 * This file is part of NeverNote
3 * Copyright 2009 Randy Baumgarte
5 * This file may be licensed under the terms of of the
6 * GNU General Public License Version 2 (the ``GPL'').
8 * Software distributed under the License is distributed
9 * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
10 * express or implied. See the GPL for the specific language
11 * governing rights and limitations.
13 * You should have received a copy of the GPL along with this
14 * program. If not, go to http://www.gnu.org/licenses/gpl.html
15 * or write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package cx.fbn.nevernote.dialog;
22 import java.util.List;
24 import com.trolltech.qt.gui.QComboBox;
25 import com.trolltech.qt.gui.QDialog;
26 import com.trolltech.qt.gui.QGridLayout;
27 import com.trolltech.qt.gui.QLabel;
28 import com.trolltech.qt.gui.QPushButton;
30 public class StackNotebook extends QDialog {
31 private boolean okPressed;
32 private final QComboBox stack;
34 List<String> currentStacks;
37 public StackNotebook() {
39 setWindowTitle(tr("Stack Notebook"));
40 QGridLayout grid = new QGridLayout();
43 QGridLayout textGrid = new QGridLayout();
44 stack = new QComboBox();
45 stack.setEditable(true);
46 textGrid.addWidget(new QLabel(tr("Stack Name")), 1,1);
47 textGrid.addWidget(stack, 1, 2);
48 textGrid.setContentsMargins(10, 10,-10, -10);
49 grid.addLayout(textGrid,1,1);
51 QGridLayout buttonGrid = new QGridLayout();
52 ok = new QPushButton(tr("OK"));
53 ok.clicked.connect(this, "okButtonPressed()");
55 QPushButton cancel = new QPushButton(tr("Cancel"));
56 cancel.clicked.connect(this, "cancelButtonPressed()");
57 stack.currentStringChanged.connect(this, "textChanged(String)");
58 buttonGrid.addWidget(ok, 3, 1);
59 buttonGrid.addWidget(cancel, 3,2);
60 grid.addLayout(buttonGrid,2,1);
63 // The OK button was pressed
64 @SuppressWarnings("unused")
65 private void okButtonPressed() {
70 // The CANCEL button was pressed
71 @SuppressWarnings("unused")
72 private void cancelButtonPressed() {
77 // Get the name from the field
78 public String getStackName() {
79 return stack.currentText();
82 public void setStackNames(List<String> names) {
83 currentStacks = names;
85 for (int i=0; i<names.size(); i++) {
86 stack.addItem(names.get(i));
91 public void setStackName(String name) {
92 stack.setEditText(name);
95 // Check if the OK button was pressed
96 public boolean okPressed() {
100 // Set the window title
101 public void setTitle(String s) {
104 // List of existing tags
105 public void setTagList(List<String> t) {
108 // Watch what text is being entered
109 @SuppressWarnings("unused")
110 private void textChanged(String text) {