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