Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / QtDialog / AddCacheEntry.cxx
blobfadfca1cd3bfda6d8b9a6b21f626002f709dc372
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: AddCacheEntry.cxx,v $
5 Language: C++
6 <<<<<<< AddCacheEntry.cxx
7 Date: $Date: 2007/11/17 02:18:48 $
8 Version: $Revision: 1.3 $
9 =======
10 Date: $Date: 2008-05-15 23:21:01 $
11 Version: $Revision: 1.4 $
12 >>>>>>> 1.4
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
23 #include "AddCacheEntry.h"
24 #include <QMetaProperty>
26 static const int NumTypes = 4;
27 static const QString TypeStrings[NumTypes] =
28 { "BOOL", "PATH", "FILEPATH", "STRING" };
29 static const QCMakeProperty::PropertyType Types[NumTypes] =
30 { QCMakeProperty::BOOL, QCMakeProperty::PATH,
31 QCMakeProperty::FILEPATH, QCMakeProperty::STRING};
33 AddCacheEntry::AddCacheEntry(QWidget* p)
34 : QWidget(p)
36 this->setupUi(this);
37 for(int i=0; i<NumTypes; i++)
39 this->Type->addItem(TypeStrings[i]);
41 QWidget* cb = new QCheckBox();
42 QWidget* path = new QCMakePathEditor();
43 QWidget* filepath = new QCMakeFilePathEditor();
44 QWidget* string = new QLineEdit();
45 this->StackedWidget->addWidget(cb);
46 this->StackedWidget->addWidget(path);
47 this->StackedWidget->addWidget(filepath);
48 this->StackedWidget->addWidget(string);
49 this->setTabOrder(this->Name, this->Type);
50 this->setTabOrder(this->Type, cb);
51 this->setTabOrder(cb, path);
52 this->setTabOrder(path, filepath);
53 this->setTabOrder(filepath, string);
54 this->setTabOrder(string, this->Description);
57 QString AddCacheEntry::name() const
59 return this->Name->text();
62 QVariant AddCacheEntry::value() const
64 QWidget* w = this->StackedWidget->currentWidget();
65 if(qobject_cast<QLineEdit*>(w))
67 return static_cast<QLineEdit*>(w)->text();
69 else if(qobject_cast<QCheckBox*>(w))
71 return static_cast<QCheckBox*>(w)->isChecked();
73 return QVariant();
76 QString AddCacheEntry::description() const
78 return this->Description->text();
81 QCMakeProperty::PropertyType AddCacheEntry::type() const
83 int idx = this->Type->currentIndex();
84 if(idx >= 0 && idx < NumTypes)
86 return Types[idx];
88 return QCMakeProperty::BOOL;