summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/widgets/combobox.cc36
-rw-r--r--client/widgets/combobox.h44
-rw-r--r--client/widgets/label.cc41
-rw-r--r--client/widgets/label.h46
-rw-r--r--client/widgets/lineedit.cc15
-rw-r--r--client/widgets/lineedit.h4
-rw-r--r--client/widgets/main.cc42
-rw-r--r--client/widgets/pushbutton.cc39
-rw-r--r--client/widgets/pushbutton.h49
-rw-r--r--client/widgets/widget.cc32
-rw-r--r--client/widgets/widget.h41
11 files changed, 384 insertions, 5 deletions
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
new file mode 100644
index 0000000..6a4d8df
--- /dev/null
+++ b/client/widgets/combobox.cc
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * combobox.cc
+ *
+ * Wed Jul 18 09:39:40 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "combobox.h"
+
+ComboBox::ComboBox(QWidget *parent) : QComboBox(parent)
+{
+}
+
+QString ComboBox::getValue()
+{
+ return "combobox";
+}
diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h
new file mode 100644
index 0000000..7b705ad
--- /dev/null
+++ b/client/widgets/combobox.h
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * combobox.h
+ *
+ * Wed Jul 18 09:39:40 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_COMBOBOX_H__
+#define __PRACRO_COMBOBOX_H__
+
+#include "widget.h"
+#include <QComboBox>
+
+class ComboBox : public Widget, public QComboBox
+{
+
+public:
+ ComboBox(QWidget *parent);
+
+public slots:
+ QString getValue();
+
+};
+
+#endif/*__PRACRO_COMBOBOX_H__*/
diff --git a/client/widgets/label.cc b/client/widgets/label.cc
new file mode 100644
index 0000000..377fd10
--- /dev/null
+++ b/client/widgets/label.cc
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * label.cc
+ *
+ * Fri Jul 13 12:38:45 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "label.h"
+#include <stdio.h>
+
+Label::Label(QWidget *parent, QString text, QString align) : QLabel(parent)
+{
+ setText(text);
+
+ if(align == "left") {
+ setAlignment(Qt::AlignLeft);
+ } else if (align == "center") {
+ setAlignment(Qt::AlignHCenter);
+ } else if (align == "right") {
+ setAlignment(Qt::AlignRight);
+ }
+}
diff --git a/client/widgets/label.h b/client/widgets/label.h
new file mode 100644
index 0000000..3138ce1
--- /dev/null
+++ b/client/widgets/label.h
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * label.h
+ *
+ * Fri Jul 13 12:38:45 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_LABEL_H__
+#define __PRACRO_LABEL_H__
+
+#include <QWidget>
+#include <QLabel>
+
+class Label : public QLabel
+{
+
+Q_OBJECT
+
+public:
+ Label(QWidget *parent, QString text, QString align);
+
+public slots:
+
+private:
+
+};
+#endif/*__PRACRO_LABEL_H__*/
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc
index c7c04fa..992c0b2 100644
--- a/client/widgets/lineedit.cc
+++ b/client/widgets/lineedit.cc
@@ -29,9 +29,11 @@
LineEdit::LineEdit(QWidget *parent, QString reg_exp) : QLineEdit(parent)
{
+ widget_name = "widget_name";
+
QRegExp rx(reg_exp);
validator = new QRegExpValidator(rx, this);
-
+ //setValidator(validator);
changed("");
connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed(QString)));
@@ -40,15 +42,15 @@ LineEdit::LineEdit(QWidget *parent, QString reg_exp) : QLineEdit(parent)
void LineEdit::changed(QString text)
{
QPalette palette;
- int res;
+ int res = 0;
if(validator->validate(text, res) == QValidator::Acceptable) {
// valid string
- palette.setBrush(backgroundRole(), QBrush(QColor(0, 150, 0)));
+ palette.setBrush(backgroundRole(), QBrush(QColor(255, 255, 255)));
valid = true;
} else {
// invalid string
- palette.setBrush(backgroundRole(), QBrush(QColor(150, 0, 0)));
+ palette.setBrush(backgroundRole(), QBrush(QColor(220, 150, 150)));
valid = false;
}
setPalette(palette);
@@ -59,3 +61,8 @@ bool LineEdit::isValid()
{
return valid;
}
+
+QString LineEdit::getValue()
+{
+ return text();
+}
diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h
index bf66d06..551f08b 100644
--- a/client/widgets/lineedit.h
+++ b/client/widgets/lineedit.h
@@ -27,11 +27,12 @@
#ifndef __PRACRO_LINEEDIT_H__
#define __PRACRO_LINEEDIT_H__
+#include "widget.h"
#include <QLineEdit>
#include <QWidget>
#include <QValidator>
-class LineEdit : public QLineEdit
+class LineEdit : public QLineEdit, public Widget
{
Q_OBJECT
@@ -42,6 +43,7 @@ public:
public slots:
void changed(QString text);
+ QString getValue();
private:
QValidator *validator;
diff --git a/client/widgets/main.cc b/client/widgets/main.cc
new file mode 100644
index 0000000..fc4603d
--- /dev/null
+++ b/client/widgets/main.cc
@@ -0,0 +1,42 @@
+#include "widget.h"
+#include "label.h"
+#include "lineedit.h"
+#include "pushbutton.h"
+#include <QApplication>
+#include <QVBoxLayout>
+#include <vector>
+
+std::vector< Widget* > widgets;
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QWidget widget;
+ QVBoxLayout *layout = new QVBoxLayout();
+
+ Label *label = new Label(&widget, "Test label:", "center");
+ LineEdit *lineedit = new LineEdit(&widget, "[0-9]+");
+ widgets.push_back(lineedit);
+ LineEdit *lineedit2 = new LineEdit(&widget, "[0-9]+");
+ widgets.push_back(lineedit2);
+ PushButton *pushbutton = new PushButton(&widget, "Commit", "committer");
+ widgets.push_back(pushbutton);
+
+ layout->addWidget(label);
+ layout->addWidget(lineedit);
+ layout->addWidget(lineedit2);
+ layout->addWidget(pushbutton);
+
+ widget.setLayout(layout);
+ widget.show();
+
+ app.exec();
+
+ std::vector< Widget* >::iterator i=widgets.begin();
+ while (i != widgets.end()) {
+ Widget* w = *i;
+ printf("%s = %s\n", w->getName().toStdString().c_str(), w->getValue().toStdString().c_str());
+ i++;
+ }
+}
diff --git a/client/widgets/pushbutton.cc b/client/widgets/pushbutton.cc
new file mode 100644
index 0000000..88fcf61
--- /dev/null
+++ b/client/widgets/pushbutton.cc
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * pushbutton.cc
+ *
+ * Fri Jul 13 12:38:45 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "pushbutton.h"
+#include <stdio.h>
+
+PushButton::PushButton(QWidget *parent, QString caption, QString type) : QPushButton(parent)
+{
+ setText(caption);
+ //connect(this, SIGNAL(onClicked()), this, SLOT(clicked()));
+}
+
+QString PushButton::getValue()
+{
+ return text();
+}
diff --git a/client/widgets/pushbutton.h b/client/widgets/pushbutton.h
new file mode 100644
index 0000000..3fc334f
--- /dev/null
+++ b/client/widgets/pushbutton.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * pushbutton.h
+ *
+ * Fri Jul 13 12:38:45 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_PUSHBUTTON_H__
+#define __PRACRO_PUSHBUTTON_H__
+
+#include "widget.h"
+#include <QPushButton>
+#include <QWidget>
+//#include <QValidator>
+
+class PushButton : public QPushButton, public Widget
+{
+
+Q_OBJECT
+
+public:
+ PushButton(QWidget *parent, QString caption = "*", QString type = "*");
+ QString getValue();
+
+public slots:
+
+private:
+
+};
+#endif/*__PRACRO_PUSHBUTTON_H__*/
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
new file mode 100644
index 0000000..8bbb3a8
--- /dev/null
+++ b/client/widgets/widget.cc
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * widget.cc
+ *
+ * Tue Jul 17 12:15:59 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "widget.h"
+
+QString Widget::getName()
+{
+ return widget_name;
+}
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
new file mode 100644
index 0000000..a636c5e
--- /dev/null
+++ b/client/widgets/widget.h
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * widget.h
+ *
+ * Tue Jul 17 12:15:59 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_WIDGET_H__
+#define __PRACRO_WIDGET_H__
+
+#include <QString>
+
+class Widget {
+
+public:
+ virtual QString getValue() = 0;
+ QString getName();
+
+protected:
+ QString widget_name;
+};
+#endif/*__PRACRO_WIDGET_H__*/