summaryrefslogtreecommitdiffstats
path: root/src/gui/collectiontypecombo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/collectiontypecombo.cpp')
-rw-r--r--src/gui/collectiontypecombo.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/gui/collectiontypecombo.cpp b/src/gui/collectiontypecombo.cpp
new file mode 100644
index 0000000..66749a3
--- /dev/null
+++ b/src/gui/collectiontypecombo.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ copyright : (C) 2006 by Robby Stephenson
+ email : robby@periapsis.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of version 2 of the GNU General Public License as *
+ * published by the Free Software Foundation; *
+ * *
+ ***************************************************************************/
+
+#include "collectiontypecombo.h"
+#include "../collection.h"
+#include "../collectionfactory.h"
+
+using Tellico::GUI::CollectionTypeCombo;
+
+CollectionTypeCombo::CollectionTypeCombo(QWidget* parent_) : ComboBox(parent_) {
+ reset();
+}
+
+void CollectionTypeCombo::reset() {
+ clear();
+ // I want to sort the collection names
+ const CollectionNameMap nameMap = CollectionFactory::nameMap();
+ QMap<QString, int> rNameMap;
+ for(CollectionNameMap::ConstIterator it = nameMap.begin(); it != nameMap.end(); ++it) {
+ rNameMap.insert(it.data(), it.key());
+ }
+ const QValueList<int> collTypes = rNameMap.values();
+ const QStringList collNames = rNameMap.keys();
+ int custom = -1;
+ const int total = collTypes.count();
+ // when i equals the size, then go back and do custom
+ for(int i = 0; i <= total; ++i) {
+ // put custom last
+ if(custom > -1 && count() >= total) {
+ break; // already done it!
+ } else if(i == total) {
+ i = custom;
+ } else if(collTypes[i] == Data::Collection::Base) {
+ custom = i;
+ continue;
+ }
+ insertItem(collNames[i], collTypes[i]);
+ }
+}
+
+void CollectionTypeCombo::setCurrentType(int type_) {
+ setCurrentData(type_);
+}