# HG changeset patch # User Markus Bröker # Date 1239879075 -7200 # Node ID 6cfca66d2f013179321226b1984e00b8adb92dae # Parent 5d7057a1b2027a51f04f55234aae697dc0f1468c A simple QT Demo I needed a playground to become familiar with the teamgit ui committer: Markus Bröker diff --git a/view/.gitignore b/view/.gitignore new file mode 100644 --- /dev/null +++ b/view/.gitignore @@ -0,0 +1,3 @@ +Makefile +moc_view.cpp +ui_maindialog.h diff --git a/view/main.cpp b/view/main.cpp new file mode 100644 --- /dev/null +++ b/view/main.cpp @@ -0,0 +1,87 @@ +/** + * Q3ListView Demo + */ + +#include +#include "view.hpp" + +void TView::down () +{ + Q3ListViewItem *item = listView->selectedItem (); + Q3ListViewItem *cur, *next; + + if ((cur = item) == NULL) + return; + if ((next = cur->itemBelow ()) == NULL) + return; + + /* + * move cur after next + */ + cur->moveItem (next); + + /* + * highlight the next item + */ + listView->setSelected (cur, true); +} + +void TView::up () +{ + Q3ListViewItem *item = listView->selectedItem (); + Q3ListViewItem *cur, *next; + + if ((cur = item) == NULL) + return; + if ((next = cur->itemAbove ()) == NULL) + return; + + /* + * move next after cur + */ + next->moveItem (cur); + + /* + * highlight the next item + */ + listView->setSelected (cur, true); +} + +TView::TView (QWidget * parent) +: QDialog (parent, 0) +{ + Q3ListViewItem *item = NULL; + + setupUi (this); + + listView->addColumn ("Picture"); + listView->addColumn ("Artist"); + listView->addColumn ("Price"); + + item = new Q3ListViewItem (listView, item, "Mona Lisa", "Leonardo da Vinci", "35.000.000"); + item = new Q3ListViewItem (listView, item, "The Thinker", "Auguste Rodin", "12.850.000"); + item = new Q3ListViewItem (listView, item, "Starnight", "Vincent van Gogh", "435.000"); + item = new Q3ListViewItem (listView, item, "The Kiss", "Gustav Klimt", "125.000"); + + connect (upButton, SIGNAL (clicked ()), this, SLOT (up ())); + connect (downButton, SIGNAL (clicked ()), this, SLOT (down ())); + + item = listView->firstChild (); + listView->setSelected (item, true); + listView->setSorting (-1, FALSE); +} + +TView::~TView () +{ + listView->clear (); +} + +int main (int argc, char **argv) +{ + QApplication app (argc, argv); + TView view; + + app.setMainWidget (&view); + view.show (); + return app.exec (); +} diff --git a/view/maindialog.ui b/view/maindialog.ui new file mode 100644 --- /dev/null +++ b/view/maindialog.ui @@ -0,0 +1,95 @@ + + Dialog + + + + 0 + 0 + 493 + 389 + + + + Dialog + + + + + + + + + + + + + up + + + + + + + down + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + Q3ListView + Q3Frame +
q3listview.h
+
+
+ + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/view/view.hpp b/view/view.hpp new file mode 100644 --- /dev/null +++ b/view/view.hpp @@ -0,0 +1,20 @@ +#ifndef VIEW_HPP +#define VIEW_HPP + +#include "ui_maindialog.h" + +class TView : public QDialog, Ui_Dialog { + Q_OBJECT + public: + TView (QWidget * parent = 0); + virtual ~TView (); + + protected slots: + void up (); + void down (); + + private: +}; + +#endif + diff --git a/view/view.pro b/view/view.pro new file mode 100644 --- /dev/null +++ b/view/view.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Mi Jan 7 01:07:54 2009 +###################################################################### + +TEMPLATE = app +QT = gui qt3support +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += view.hpp +FORMS += maindialog.ui +SOURCES += main.cpp