00001
00002
00003
00004
00005
00006
00007
00008 #ifndef TOOLFLAG_H
00009 #define TOOLFLAG_H
00010
00011
00012
00013 #include <QtGui>
00014
00015
00016
00017 class Slice;
00018 class ProcessSettings;
00019 class ToolFlagElement;
00020 class Tool;
00021 class VolumeIndex;
00022
00023 struct FlagDependency
00024 {
00025 FlagDependency( const QString &dependentFlag,const QString &value, int type )
00026 { this->dependentFlag = dependentFlag; this->value = value; this->type = type; }
00027 QString dependentFlag;
00028 QString value;
00029 int type;
00030 };
00031
00032 class ToolFlag : public QObject
00033 {
00034 Q_OBJECT
00035
00036 public:
00037 ToolFlag( const QString &flag );
00038 ToolFlag( const QString &flag, const QStringList ¶ms );
00039 ~ToolFlag();
00040 ToolFlag* Clone();
00041
00042 void Initialize( ProcessSettings *settings, const QHash<QString, QStringList> &possibleFiles );
00043 void DetachFromGui( ProcessSettings *settings );
00044
00045 static ToolFlag* CreateFromXml( QXmlStreamReader &xml, int &basicCount, int &advancedCount );
00046 void LoadFromXml( QXmlStreamReader &xml );
00047 void SaveToXml( QXmlStreamWriter &xml );
00048 bool AppendFlag( QStringList *args, VolumeIndex *index, const QString &fileNameOverride,
00049 Tool *tool, QHash<QString, QStringList> &outputFiles );
00050 void InitializeDependencies( QHash<QString, ToolFlag *> &flagList );
00051
00052 QString GetFlag() { return flag; }
00053 bool IsEnabled() { return enabled || required; }
00054 bool IsRequired() { return required; }
00055 bool IsAdvanced() { return advanced; }
00056 QPoint GetNextGridPos() { nextGridPos.rx()++; return nextGridPos; }
00057 QString GetDescription() { return description; }
00058 QString GetFullDescription() { return fullDescription; }
00059 int GetMaxControlCount();
00060
00061 void ClearElements();
00062 void UpdateStatus( int state, bool checkedState, bool enabledState );
00063
00064 public slots:
00065 void CheckedEnables( int state ) { UpdateStatus( state, true, true ); }
00066 void CheckedDisables( int state ) { UpdateStatus( state, true, false ); }
00067 void UncheckedEnables( int state ) { UpdateStatus( state, false, true ); }
00068 void UncheckedDisables( int state ) { UpdateStatus( state, false, false ); }
00069 void IndexChanged( const QString &text );
00070
00071 private:
00072 QString flag;
00073 QString flagValueWhenDisabled;
00074 QList<ToolFlagElement *> elements;
00075
00076 QString description;
00077 QString fullDescription;
00078 bool enabled;
00079 bool required;
00080 bool advanced;
00081 QPoint nextGridPos;
00082 QList<FlagDependency> dependenceList;
00083
00084 bool checkbox;
00085 int desiredRow;
00086 };
00087
00088 class ToolFlagElement : public QWidget
00089 {
00090 Q_OBJECT
00091
00092 friend ToolFlag* ToolFlag::Clone();
00093 friend int ToolFlag::GetMaxControlCount();
00094
00095 public:
00096
00097 enum ElementType
00098 {
00099 NONE,
00100 STATIC,
00101 PATH,
00102 INPUT_BOX,
00103 CHECK_BOX,
00104 LINE_EDIT,
00105 COMBO_BOX,
00106 COMBO_OPTION,
00107 IMAGES,
00108 DIR_BUTTON,
00109 END
00110 };
00111
00112 enum SliceCount
00113 {
00114 ALL_BUT_ONE = -2,
00115 ALL_SLICES = -1,
00116 NO_SLICES = 0,
00117 SINGLE_SLICE = 1,
00118 DOUBLE_SLICE = 2,
00119 };
00120
00121 ToolFlagElement( ToolFlag *parent, ToolFlagElement *guiParent );
00122 ToolFlagElement( ToolFlag *parent, const QString &staticText );
00123 ~ToolFlagElement();
00124 ToolFlagElement* Clone( ToolFlag *flag, ToolFlagElement *lastComboBox );
00125 void AppendArg( QStringList *args, VolumeIndex* slice, VolumeIndex* nextStack,
00126 const QString &fileName, bool first, Tool *tool, QHash<QString, QStringList> &outputFiles );
00127
00128 void Initialize( int &row, ProcessSettings *settings, const QHash<QString, QStringList> &possibleFiles );
00129 void InitializeInputBox( int &row, ProcessSettings *settings, const QStringList &possibleFiles, bool isDefault );
00130 void InitializeCheckBox( int &row, ProcessSettings *settings );
00131 void InitializeComboBox( int &row, ProcessSettings *settings );
00132 void InitializeComboOption();
00133 void InitializeLineEdit( int &row, ProcessSettings *settings );
00134 void InitializeDirButton( int &row, ProcessSettings *settings );
00135
00136 void DetachFromGui( ProcessSettings *settings );
00137 void UpdateEnabledStatus();
00138 void AddInputFilesToComboBox(const QStringList &inputFiles);
00139
00140 static ToolFlagElement* CreateFromXml( ToolFlag *parent, ToolFlagElement *guiParent, QXmlStreamReader &xml );
00141 void LoadFromXml( QXmlStreamReader &xml );
00142 void SaveToXml( QXmlStreamWriter &xml );
00143 bool AppendElement( QStringList *args, VolumeIndex *index, const QString &fileNameOverride,
00144 Tool *tool, QHash<QString, QStringList> &outputFiles );
00145
00146 int GetStartEndIndices( bool &ok, int &sliceIdx, const QList<VolumeIndex *> &slices );
00147 void ConnectCheckboxSignal( ToolFlag *flag, const QString &type );
00148 void ConnectInputBoxSignal( ToolFlag *flag, const QString &type );
00149 void DisableGuiObject();
00150 static bool ControlGreaterThan( int lhs, int rhs );
00151
00152 private:
00153 QString value;
00154 QString channel;
00155 QString other;
00156 ElementType type;
00157 int sliceCount;
00158 int controlCount;
00159
00160
00161 QWidgetItem *guiObject;
00162 ToolFlagElement *guiParent;
00163 QList<QObject *> extraObjects;
00164
00165 ToolFlag *parent;
00166 };
00167
00168 #endif