38
38
int gqbGridOrderTable::GetNumberRows()
40
return (columns->GetCount());
40
return (columns->GetCount());
44
44
int gqbGridOrderTable::GetNumberCols()
50
50
bool gqbGridOrderTable::IsEmptyCell( int row, int col )
52
int count=columns->GetCount();
52
int count = columns->GetCount();
60
60
wxString gqbGridOrderTable::GetValue( int row, int col )
64
wxString col = wxT("");
65
if(((gqbQueryObject *)colsParents->Item(row))->getAlias().length()>0)
67
col+=((gqbQueryObject *)colsParents->Item(row))->getAlias()+wxT(".");
71
col+=((gqbQueryObject *)colsParents->Item(row))->getName()+wxT(".");
73
col+=((gqbColumn *)columns->Item(row))->getName();
81
wxString ord = wxT("");
82
if(kindOfOrder->Item(row)=='A')
64
wxString col = wxT("");
65
if(((gqbQueryObject *)colsParents->Item(row))->getAlias().length() > 0)
67
col += ((gqbQueryObject *)colsParents->Item(row))->getAlias() + wxT(".");
71
col += ((gqbQueryObject *)colsParents->Item(row))->getName() + wxT(".");
73
col += ((gqbColumn *)columns->Item(row))->getName();
77
if(numberColumns == 2)
81
wxString ord = wxT("");
82
if(kindOfOrder->Item(row) == 'A')
94
94
wxString gqbGridOrderTable::GetColLabelValue(int col)
105
return _("Available Columns");
99
if(numberColumns == 2)
105
return _("Available Columns");
116
void gqbGridOrderTable::SetValue( int row, int col, const wxString& value )
116
void gqbGridOrderTable::SetValue( int row, int col, const wxString &value )
118
if(col==1 && numberColumns==2)
120
if(value.Contains(wxT("ASC")))
122
kindOfOrder->Item(row)='A';
126
kindOfOrder->Item(row)='D';
118
if(col == 1 && numberColumns == 2)
120
if(value.Contains(wxT("ASC")))
122
kindOfOrder->Item(row) = 'A';
126
kindOfOrder->Item(row) = 'D';
132
132
void gqbGridOrderTable::AppendItem(gqbColumn *column, gqbQueryObject *parent, char kindOrder)
134
columns->Add(column);
135
colsParents->Add(parent);
138
kindOfOrder->Add(kindOrder);
134
columns->Add(column);
135
colsParents->Add(parent);
136
if(numberColumns == 2)
138
kindOfOrder->Add(kindOrder);
143
wxGridTableMessage msg( this,
144
wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
145
(columns->GetCount()-1),
147
GetView()->ProcessTableMessage( msg );
143
wxGridTableMessage msg( this,
144
wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
145
(columns->GetCount() - 1),
147
GetView()->ProcessTableMessage( msg );
152
152
bool gqbGridOrderTable::removeFirstRow(gqbObject *itemTable)
155
int i,size=colsParents->GetCount();
159
if (colsParents->Item(i)==itemTable)
168
columns->RemoveAt(i);
169
colsParents->RemoveAt(i);
172
kindOfOrder->RemoveAt(i);
174
if ( GetView() ) // Notify Grid about the change
176
wxGridTableMessage msg( this,
177
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
180
GetView()->ProcessTableMessage( msg );
155
int i, size = colsParents->GetCount();
157
for(i = 0; i < size; i++)
159
if (colsParents->Item(i) == itemTable)
168
columns->RemoveAt(i);
169
colsParents->RemoveAt(i);
170
if(numberColumns == 2)
172
kindOfOrder->RemoveAt(i);
174
if ( GetView() ) // Notify Grid about the change
176
wxGridTableMessage msg( this,
177
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
180
GetView()->ProcessTableMessage( msg );
188
188
void gqbGridOrderTable::emptyTableData(gqbQueryObject *object)
190
// Because items positions on array changes when I delete one, I have to do the remove in this way
191
while(removeFirstRow(object));
190
// Because items positions on array changes when I delete one, I have to do the remove in this way
191
while(removeFirstRow(object));
195
195
void gqbGridOrderTable::removeRowAt(int i)
197
columns->RemoveAt(i);
198
colsParents->RemoveAt(i);
201
kindOfOrder->RemoveAt(i);
203
// Notify Grid about the change
206
wxGridTableMessage msg( this,
207
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
210
GetView()->ProcessTableMessage( msg );
197
columns->RemoveAt(i);
198
colsParents->RemoveAt(i);
199
if(numberColumns == 2)
201
kindOfOrder->RemoveAt(i);
203
// Notify Grid about the change
206
wxGridTableMessage msg( this,
207
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
210
GetView()->ProcessTableMessage( msg );
215
gqbObject* gqbGridOrderTable::getObjectAt(int pos, int col)
215
gqbObject *gqbGridOrderTable::getObjectAt(int pos, int col)
217
gqbObject *value = NULL;
221
value=columns->Item(pos);
224
value=colsParents->Item(pos);
217
gqbObject *value = NULL;
221
value = columns->Item(pos);
224
value = colsParents->Item(pos);
231
231
void gqbGridOrderTable::changesPositions(int sPos, int dPos)
234
int size=columns->GetCount();
235
gqbObject *tmpTable=NULL, *tmpColumn=NULL;
238
if( (sPos>=0 && sPos < size) && (dPos>=0 && dPos < size) )
240
tmpTable=colsParents->Item(sPos);
241
tmpColumn=columns->Item(sPos);
242
tmpKind=kindOfOrder->Item(sPos);
244
colsParents->Item(sPos)=colsParents->Item(dPos);
245
columns->Item(sPos)=columns->Item(dPos);
246
kindOfOrder->Item(sPos)=kindOfOrder->Item(dPos);
247
colsParents->Item(dPos)=tmpTable;
248
columns->Item(dPos)=tmpColumn;
249
kindOfOrder->Item(dPos)=tmpKind;
252
wxGridTableMessage msg( this,
253
wxGRIDTABLE_REQUEST_VIEW_GET_VALUES,
256
GetView()->ProcessTableMessage( msg );
234
int size = columns->GetCount();
235
gqbObject *tmpTable = NULL, *tmpColumn = NULL;
238
if( (sPos >= 0 && sPos < size) && (dPos >= 0 && dPos < size) )
240
tmpTable = colsParents->Item(sPos);
241
tmpColumn = columns->Item(sPos);
242
tmpKind = kindOfOrder->Item(sPos);
244
colsParents->Item(sPos) = colsParents->Item(dPos);
245
columns->Item(sPos) = columns->Item(dPos);
246
kindOfOrder->Item(sPos) = kindOfOrder->Item(dPos);
247
colsParents->Item(dPos) = tmpTable;
248
columns->Item(dPos) = tmpColumn;
249
kindOfOrder->Item(dPos) = tmpKind;
252
wxGridTableMessage msg( this,
253
wxGRIDTABLE_REQUEST_VIEW_GET_VALUES,
256
GetView()->ProcessTableMessage( msg );
262
262
// Change a single row or a range to one pos up or down (but no more than one position)
263
263
void gqbGridOrderTable::changesRangeOnePos(int topPos, int bottomPos, int newTop)
265
// Eliminate side effect of zero base array on calculations, but carefull newTop still it's zero based
268
int sizeRange=bottomPos-(topPos-1), size=GetNumberRows();
269
if(topPos>newTop) // Go Down
271
// Only if the movement don't create an overflow
272
if( (topPos > 1) && ((newTop+sizeRange) < size) )
274
for(int i=newTop ; i < (newTop+sizeRange) ; i++)
276
changesPositions(i,i+1);
265
// Eliminate side effect of zero base array on calculations, but carefull newTop still it's zero based
268
int sizeRange = bottomPos - (topPos - 1), size = GetNumberRows();
269
if(topPos > newTop) // Go Down
271
// Only if the movement don't create an overflow
272
if( (topPos > 1) && ((newTop + sizeRange) < size) )
274
for(int i = newTop ; i < (newTop + sizeRange) ; i++)
276
changesPositions(i, i + 1);
283
// Only if the movement don't create an overflow
284
if( (bottomPos < size) && ((newTop+sizeRange) <= size) )
287
for(int i=(newTop+sizeRange-1) ; i >= newTop ; i--)
289
changesPositions(i-1,i);
283
// Only if the movement don't create an overflow
284
if( (bottomPos < size) && ((newTop + sizeRange) <= size) )
287
for(int i = (newTop + sizeRange - 1) ; i >= newTop ; i--)
289
changesPositions(i - 1, i);