diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2013-12-24 11:47:30 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2013-12-24 11:47:30 +0100 |
commit | ccbf341dc8d8e515d9cf918bff7ff9435c477847 (patch) | |
tree | 7ca5071ba6dcc52dd6e77e265ece4afafcac58f7 /main.cpp | |
download | MultiMC-ccbf341dc8d8e515d9cf918bff7ff9435c477847.tar MultiMC-ccbf341dc8d8e515d9cf918bff7ff9435c477847.tar.gz MultiMC-ccbf341dc8d8e515d9cf918bff7ff9435c477847.tar.lz MultiMC-ccbf341dc8d8e515d9cf918bff7ff9435c477847.tar.xz MultiMC-ccbf341dc8d8e515d9cf918bff7ff9435c477847.zip |
Initial commit. Basics work. Next: Drag and Drop
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp new file mode 100644 index 00000000..24d7075e --- /dev/null +++ b/main.cpp @@ -0,0 +1,53 @@ +#include "CategorizedView.h" +#include <QApplication> +#include <QStandardItemModel> + +#include "CategorizedProxyModel.h" + +QPixmap icon(const Qt::GlobalColor color) +{ + QPixmap p = QPixmap(32, 32); + p.fill(QColor(color)); + return p; +} +QStandardItem *createItem(const Qt::GlobalColor color, const QString &text, const QString &category) +{ + QStandardItem *item = new QStandardItem; + item->setText(text); + item->setData(icon(color), Qt::DecorationRole); + item->setData(category, CategorizedView::CategoryRole); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + return item; +} + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + QStandardItemModel model; + model.setRowCount(10); + model.setColumnCount(1); + + model.setItem(0, createItem(Qt::red, "Red", "Colorful")); + model.setItem(1, createItem(Qt::blue, "Blue", "Colorful")); + model.setItem(2, createItem(Qt::yellow, "Yellow", "Colorful")); + + model.setItem(3, createItem(Qt::black, "Black", "Not Colorful")); + model.setItem(4, createItem(Qt::darkGray, "Dark Gray", "Not Colorful")); + model.setItem(5, createItem(Qt::gray, "Gray", "Not Colorful")); + model.setItem(6, createItem(Qt::lightGray, "Light Gray", "Not Colorful")); + model.setItem(7, createItem(Qt::white, "White", "Not Colorful")); + + model.setItem(8, createItem(Qt::darkGreen, "Dark Green", "")); + model.setItem(9, createItem(Qt::green, "Green", "")); + + CategorizedProxyModel pModel; + pModel.setSourceModel(&model); + + CategorizedView w; + w.setModel(&pModel); + w.resize(640, 480); + w.show(); + + return a.exec(); +} |