00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qmessagebox.h>
00013
#include "filepropertydlg.h"
00014
#include <kmessagebox.h>
00015
#include <kdebug.h>
00016
00017 ScopeItem::ScopeItem(
QListView *parent,
const QString &text,
QStringList *excludeList,
bool initialMode)
00018 :
QCheckListItem(parent,
text,
QCheckListItem::CheckBox)
00019 {
00020
m_excludeList = excludeList;
00021 setOn(initialMode);
00022
m_initialMode = initialMode;
00023 }
00024
00025 ScopeItem::ScopeItem(
QCheckListItem *parent,
const QString &text,
QStringList *excludeList,
bool initialMode)
00026 :
QCheckListItem(parent,
text,
QCheckListItem::CheckBox)
00027 {
00028
m_excludeList = excludeList;
00029 setOn(initialMode);
00030
m_initialMode = initialMode;
00031 }
00032
00033 bool ScopeItem::isDirty()
00034 {
00035
if (
m_initialMode==isOn())
00036
return false;
00037
return true;
00038 }
00039
00040 void ScopeItem::excludeFromScope(
const QString &fileName,
bool b)
00041 {
00042
if (!
m_excludeList)
00043
return;
00044
00045
m_excludeList->remove(fileName);
00046
if (b)
00047
m_excludeList->append(fileName);
00048 }
00049
00050 FilePropertyDlg::FilePropertyDlg(
SubqmakeprojectItem *spitem,
int grtype,
FileItem *fitem,
QStringList &dirtyScopes,
00051
QWidget *parent,
const char* name,
bool modal, WFlags fl)
00052 :
FilePropertyBase(parent,name,modal,fl),
00053 m_dirtyScopes(dirtyScopes)
00054 {
00055
if (grtype == GroupItem::InstallObject)
00056 {
00057
GroupItem* gitem = dynamic_cast<GroupItem*>(fitem->parent());
00058
if (gitem)
00059
m_installObjectName = gitem->
install_objectname;
00060 }
00061
m_gtype = grtype;
00062
m_subProjectItem = spitem;
00063
m_fileItem = fitem;
00064 ScopeTree->setRootIsDecorated(
true);
00065
createScopeTree(
m_subProjectItem);
00066 }
00067
00068 GroupItem*
FilePropertyDlg::getInstallRoot(
SubqmakeprojectItem* item)
00069 {
00070
QPtrListIterator<GroupItem> it(item->
groups);
00071
for (;it.current();++it)
00072 {
00073
if ((*it)->groupType == GroupItem::InstallRoot)
00074
return *it;
00075 }
00076
return 0;
00077 }
00078
00079 GroupItem*
FilePropertyDlg::getInstallObject(
SubqmakeprojectItem* item,
const QString& objectname)
00080 {
00081
GroupItem* instroot =
getInstallRoot(item);
00082
if (!instroot)
00083
return 0;
00084
QPtrListIterator<GroupItem> it(instroot->
installs);
00085
for (;it.current();++it)
00086 {
00087
if ((*it)->groupType == GroupItem::InstallObject &&
00088 (*it)->install_objectname == objectname )
00089
return *it;
00090 }
00091
return 0;
00092
00093 }
00094
00095
00096 QStringList*
FilePropertyDlg::getExcludeList(
SubqmakeprojectItem *spitem)
00097 {
00098
if (
m_gtype == GroupItem::Sources)
00099
return &(spitem->
sources_exclude);
00100
if (
m_gtype == GroupItem::Headers)
00101
return &(spitem->
headers_exclude);
00102
if (
m_gtype == GroupItem::Forms)
00103
return &(spitem->
forms_exclude);
00104
if (
m_gtype == GroupItem::Images)
00105
return &(spitem->
images_exclude);
00106
if (
m_gtype == GroupItem::IDLs)
00107
return &(spitem->
idls_exclude);
00108
if (
m_gtype == GroupItem::Translations)
00109
return &(spitem->
translations_exclude);
00110
if (
m_gtype == GroupItem::Yaccsources)
00111
return &(spitem->
yaccsources_exclude);
00112
if (
m_gtype == GroupItem::Lexsources)
00113
return &(spitem->
lexsources_exclude);
00114
if (
m_gtype == GroupItem::Distfiles)
00115
return &(spitem->
distfiles_exclude);
00116
if (
m_gtype == GroupItem::InstallObject)
00117 {
00118
GroupItem* gitem =
getInstallObject(spitem,
m_installObjectName);
00119
if (gitem)
00120
return &(gitem->
str_files_exclude);
00121
return &
m_dummy;
00122 }
00123
return NULL;
00124 }
00125
00126 void FilePropertyDlg::createScopeTree(
SubqmakeprojectItem *spitem,
ScopeItem *sitem)
00127 {
00128
QPtrListIterator<SubqmakeprojectItem> spit(spitem->
scopes);
00129
for (; spit.current(); ++spit)
00130 {
00131
SubqmakeprojectItem *nextSubproject = spit;
00132
QStringList *excludeList =
getExcludeList(nextSubproject);
00133
if (!excludeList)
00134
continue;
00135
00136
bool initiallyExcluded =
false;
00137
if (excludeList->find(
m_fileItem->
name)!=excludeList->end())
00138 initiallyExcluded =
true;
00139
ScopeItem *item;
00140
if (!sitem)
00141 item =
new ScopeItem(ScopeTree,nextSubproject->text(0),excludeList,initiallyExcluded);
00142
else
00143 item =
new ScopeItem(sitem,nextSubproject->text(0),excludeList,initiallyExcluded);
00144 item->
setScopeString(nextSubproject->
scopeString);
00145
if (!sitem)
00146 ScopeTree->insertItem(item);
00147
else
00148 sitem->insertItem(item);
00149
createScopeTree(nextSubproject,item);
00150 }
00151 }
00152
00153
00154 void FilePropertyDlg::updateFileProperties()
00155 {
00156
m_dirtyScopes =
getExcludedScopes();
00157 accept();
00158 }
00159
00160 QStringList FilePropertyDlg::getExcludedScopes(
ScopeItem *sitem)
00161 {
00162
QStringList scopes;
00163
if (!sitem)
00164 sitem = static_cast<ScopeItem*>(ScopeTree->firstChild());
00165
else
00166 sitem = static_cast<ScopeItem*>(sitem->firstChild());
00167
while (sitem)
00168 {
00169
if (sitem->
isDirty())
00170 {
00171
if (sitem->isOn())
00172 {
00173
if (
m_gtype != GroupItem::InstallObject)
00174 sitem->
excludeFromScope(
m_fileItem->
name,
true);
00175 }
00176
else
00177 {
00178
if (
m_gtype != GroupItem::InstallObject)
00179 sitem->
excludeFromScope(
m_fileItem->
name,
false);
00180 }
00181 scopes.append(sitem->
getScopeString());
00182
kdDebug(9024) <<
"dirty scope - " << sitem->
getScopeString() <<
endl;
00183 }
00184 scopes +=
getExcludedScopes(sitem);
00185 sitem = static_cast<ScopeItem*>(sitem->nextSibling());
00186 }
00187
return scopes;
00188 }
00189