ff7tk  0.02
Toolkit for making FF7 Tools
LocationViewer.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // copyright 2013 -2016 Chris Rizzitello <sithlord48@gmail.com> //
3 // //
4 // This file is part of FF7tk //
5 // //
6 // FF7tk is free software: you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation, either version 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // FF7tk is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License for more details. //
15 /****************************************************************************/
16 #include "LocationViewer.h"
17 
18 LocationViewer::LocationViewer(qreal Scale,QWidget *parent) : QWidget(parent)
19 {
20  scale=Scale;
21  region="";
22  transBasePath="";
23  autoUpdate=false;
24  regExpSearch=false;
25  caseSensitive=false;
26  _advancedMode=false;
27  Locations = new FF7Location();
29  init_display();
31  actionNameSearch->setChecked(true);
32 }
33 void LocationViewer::setLocationChangesSaved(bool saveChanges){chkAutoUpdate->setChecked(saveChanges);}
35 void LocationViewer::resizeEvent(QResizeEvent *ev)
36 {
37  if(ev->type()==QResizeEvent::Resize)
38  {
39  QPixmap pix(QString(":/locations/%1_%2").arg(QString::number(sbMapID->value()),QString::number(sbLocID->value())));
40  if(pix.isNull()){return;}
41  else
42  {
43  lblLocationPreview->setPixmap(pix.scaledToWidth(lblLocationPreview->width(),Qt::SmoothTransformation));
44  }
45  }
46 }
47 
49 {
50 
51  lblLocationPreview = new QLabel;
52  //lblLocationPreview->setScaledContents(true);
53  lblLocationPreview->setMinimumSize(320*scale,240*scale);
54  lblLocationPreview->setBaseSize(640*scale,480*scale);
55  lblLocationPreview->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
56  QTableWidgetItem *newItem;
57 
58  //create and fill location list.
59 
60  locationTable = new QTableWidget;
61  locationTable->setColumnCount(3);
62  locationTable->setRowCount(Locations->len());
63  locationTable->verticalHeader()->setHidden(true);
64  locationTable->setSelectionBehavior(QAbstractItemView::SelectRows);
65  locationTable->setSelectionMode(QAbstractItemView::SingleSelection);
66  locationTable->setSortingEnabled(true);
67 
68  newItem = new QTableWidgetItem(tr("Filename"),0);
69  locationTable->setHorizontalHeaderItem(0,newItem);
70  locationTable->setColumnWidth(0,fontMetrics().width(QChar('W'))*6);
71  newItem = new QTableWidgetItem(tr("Location Name"),0);
72  locationTable->setHorizontalHeaderItem(1,newItem);
73  locationTable->setColumnWidth(1,fontMetrics().width(QChar('W'))*15);
74  newItem = new QTableWidgetItem(tr("LocID"),0);
75  locationTable->setColumnWidth(2,fontMetrics().width(QChar('W'))*4);
76  locationTable->setHorizontalHeaderItem(2,newItem);
77 
78  for (int i=0;i<locationTable->rowCount();i++)
79  {
80  //set the tooltip to the needed file
81  QString tooltip(QString("<html><head/><body><p><img src=\":/locations/%1_%2\" width=\"%3\" height\"%4\" /></p></body></html>").arg(Locations->mapID(i),Locations->locationID(i),QString::number(320*scale),QString::number(480*scale)));
82 
83  newItem = new QTableWidgetItem(Locations->fileName(i),0);
84  newItem->setFlags(newItem->flags()&=~Qt::ItemIsEditable);
85  newItem->setToolTip(tooltip);
86  newItem->setTextAlignment(Qt::AlignLeft);
87  locationTable->setItem(i,0,newItem);
88 
89  newItem = new QTableWidgetItem(Locations->locationString(i),0);
90  newItem->setFlags(newItem->flags()&=~Qt::ItemIsEditable);
91  newItem->setTextAlignment(Qt::AlignLeft);
92  newItem->setToolTip(tooltip);
93  locationTable->setItem(i,1,newItem);
94 
95  //To assure proper numerical sorting of location IDs they should all contain the same number of characters.
96  newItem = new QTableWidgetItem(QString("%1").arg(Locations->locationID(i).toInt(),3,10,QChar('0')).toUpper());//Pad so at least 3 chars. Leading 0's
97  newItem->setFlags(newItem->flags()&=~Qt::ItemIsEditable);
98  newItem->setTextAlignment(Qt::AlignHCenter);
99  locationTable->setItem(i,2,newItem);
100  locationTable->setRowHeight(i,(fontMetrics().height()+2));
101  }
102  locationTable->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
103  locationTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
104  locationTable->adjustSize();
105  locationTable->setFixedWidth(locationTable->columnWidth(0)+locationTable->columnWidth(1)+locationTable->columnWidth(2)+locationTable->verticalScrollBar()->widthMM()+fontMetrics().width(QChar('W')));
106  locationTable->setCurrentCell(-1,-1);
107  locationTable->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
108 
109  btnSearchOptions = new QToolButton;
110  btnSearchOptions->setLayoutDirection(Qt::RightToLeft);
111  btnSearchOptions->setIcon(QIcon::fromTheme(QString("edit-clear"),QPixmap(":/common/edit-clear")));
112  btnSearchOptions->setPopupMode(QToolButton::MenuButtonPopup);
113 
114  actionNameSearch = new QAction(tr("Filter Mode: Name / Location String"),btnSearchOptions);
115  actionNameSearch->setCheckable(true);
116 
117  actionItemSearch = new QAction(tr("Filter Mode: Items Found at Location"),btnSearchOptions);
118  actionItemSearch->setCheckable(true);
119 
120  actionRegExpSearch = new QAction(tr("Process Regular Expressions"),btnSearchOptions);
121  actionRegExpSearch->setCheckable(true);
122 
123  actionCaseSensitive = new QAction(tr("Case Sensitive"),btnSearchOptions);
124  actionCaseSensitive->setCheckable(true);
125 
126  QString menuStyle = QString("QCheckbox::indicator { width: %1px; height: %2px;}").arg(QString::number(16*scale),QString::number(16*scale));
127 
128  QMenu * newMenu=new QMenu;
129  newMenu->setStyleSheet(menuStyle);
130  newMenu->addAction(actionNameSearch);
131  newMenu->addAction(actionItemSearch);
132  newMenu->addSeparator();
133  newMenu->addAction(actionRegExpSearch);
134  newMenu->addAction(actionCaseSensitive);
135 
136  btnSearchOptions->setMenu(newMenu);
137  btnSearchOptions->setFixedWidth(36*scale);
138 
139  lineTableFilter = new QLineEdit;
140  lineTableFilter->setFixedWidth( locationTable->width() - btnSearchOptions->width());
141 
142  lineLocationName = new QLineEdit;
143  lineLocationName->setPlaceholderText(tr("Location Name"));
144 
145  sbMapID = new QSpinBox;
146  //sbMapID->setMaximum(3);
147  //setMax when varified
148  sbMapID->setWrapping(true);
149  sbMapID->setPrefix(tr("MapID: "));
150  sbMapID->setAlignment(Qt::AlignCenter);
151 
152  sbLocID = new QSpinBox;
153  sbLocID->setMaximum(786);
154  sbLocID->setWrapping(true);
155  sbLocID->setPrefix(tr("LocID: "));
156  sbLocID->setAlignment(Qt::AlignCenter);
157 
158  sbX= new QSpinBox;
159  sbX->setPrefix(tr("X: "));
160  sbX->setMinimum(-32767);
161  sbX->setMaximum(32767);
162  sbX->setWrapping(true);
163  sbX->setAlignment(Qt::AlignCenter);
164 
165  sbY= new QSpinBox;
166  sbY->setPrefix(tr("Y: "));
167  sbY->setMinimum(-32767);
168  sbY->setMaximum(32767);
169  sbY->setWrapping(true);
170  sbY->setAlignment(Qt::AlignCenter);
171 
172  sbT= new QSpinBox;
173  sbT->setPrefix(tr("T: "));
174  sbT->setMaximum(65565);
175  sbT->setWrapping(true);
176  sbT->setAlignment(Qt::AlignCenter);
177 
178  sbD = new QSpinBox;
179  sbD->setMaximum(255);
180  sbD->setPrefix(tr("D: "));
181  sbD->setWrapping(true);
182  sbD->setAlignment(Qt::AlignCenter);
183 
184  chkAutoUpdate = new QCheckBox;
185  chkAutoUpdate->setText(tr("Save &Location Changes"));
186  chkAutoUpdate->setFixedWidth(locationTable->width());
187  //connect now and forget it
188  connect(chkAutoUpdate,SIGNAL(clicked(bool)),this,SLOT(chkAutoUpdateChanged(bool)));
189 
190  fieldItemList = new QListWidget();
191  fieldItemList->setFixedHeight(0);
192  fieldItemList->setUniformItemSizes(true);
193  fieldItemList->setSelectionMode(QAbstractItemView::NoSelection);
194 
195  QVBoxLayout *fitemLayout = new QVBoxLayout();
196  fitemLayout->setContentsMargins(0,0,0,0);
197  fitemLayout->setSpacing(0);
198  fitemLayout->addWidget(fieldItemList);
199  groupFieldItems = new QGroupBox(tr("Field Items"));
200  groupFieldItems->setLayout(fitemLayout);
201  groupFieldItems->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
202 
203  QHBoxLayout *nameIDs = new QHBoxLayout;
204  nameIDs->addWidget(lineLocationName);
205  nameIDs->addWidget(sbMapID);
206  nameIDs->addWidget(sbLocID);
207 
208  QHBoxLayout *XYTD = new QHBoxLayout;
209  XYTD->addWidget(sbX);
210  XYTD->addWidget(sbY);
211  XYTD->addWidget(sbT);
212  XYTD->addWidget(sbD);
213 
214  QVBoxLayout *CoordsLayout = new QVBoxLayout;
215  CoordsLayout->setContentsMargins(3,3,3,3);
216  CoordsLayout->addLayout(nameIDs);
217  CoordsLayout->addLayout(XYTD);
218 
219 
220  QHBoxLayout *PreviewLayout = new QHBoxLayout;
221  PreviewLayout->setAlignment(Qt::AlignCenter);
222  PreviewLayout->addWidget(lblLocationPreview);
223 
224  QHBoxLayout *FilterLayout = new QHBoxLayout;
225  FilterLayout->setContentsMargins(0,0,0,0);
226  FilterLayout->setSpacing(0);
227  FilterLayout->addWidget(lineTableFilter);
228  FilterLayout->addWidget(btnSearchOptions);
229 
230  QVBoxLayout *LeftSideLayout = new QVBoxLayout;
231  LeftSideLayout->setSpacing(0);
232  LeftSideLayout->addWidget(chkAutoUpdate);
233  LeftSideLayout->addWidget(locationTable);
234  LeftSideLayout->addLayout(FilterLayout);
235 
236  QVBoxLayout *RightSideLayout = new QVBoxLayout;
237  RightSideLayout->addLayout(CoordsLayout);
238  RightSideLayout->addLayout(PreviewLayout);
239  RightSideLayout->addWidget(groupFieldItems);
241 
242  QHBoxLayout *FinalLayout = new QHBoxLayout;
243  FinalLayout->setContentsMargins(3,3,3,3);
244  FinalLayout->addLayout(LeftSideLayout);
245  FinalLayout->addLayout(RightSideLayout);
246  this->setLayout(FinalLayout);
247  this->adjustSize();
248 }
250 {
251  connect(locationTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(itemChanged(int,int,int,int)));
252  connect(lineTableFilter,SIGNAL(textChanged(QString)),this,SLOT(filterLocations(QString)));
253  connect(btnSearchOptions,SIGNAL(clicked()),this,SLOT(btnSearchOptionsClicked()));
254  connect(actionNameSearch,SIGNAL(toggled(bool)),this,SLOT(actionNameSearchToggled(bool)));
255  connect(actionItemSearch,SIGNAL(toggled(bool)),this,SLOT(actionItemSearchToggled(bool)));
256  connect(actionRegExpSearch,SIGNAL(toggled(bool)),this,SLOT(actionRegExpSearchToggled(bool)));
257  connect(actionCaseSensitive,SIGNAL(toggled(bool)),this,SLOT(actionCaseSensitiveToggled(bool)));
258  connect(sbMapID,SIGNAL(valueChanged(int)),this,SLOT(sbMapIdChanged(int)));
259  connect(sbLocID,SIGNAL(valueChanged(int)),this,SLOT(sbLocIdChanged(int)));
260  connect(sbX,SIGNAL(valueChanged(int)),this,SLOT(sbXChanged(int)));
261  connect(sbY,SIGNAL(valueChanged(int)),this,SLOT(sbYChanged(int)));
262  connect(sbT,SIGNAL(valueChanged(int)),this,SLOT(sbTChanged(int)));
263  connect(sbD,SIGNAL(valueChanged(int)),this,SLOT(sbDChanged(int)));
264  connect(lineLocationName,SIGNAL(textChanged(QString)),this,SLOT(lineLocationNameChanged(QString)));
265  connect(fieldItemList,SIGNAL(clicked(QModelIndex)),this,SLOT(fieldItemListItemChanged(QModelIndex)));
266 }
268 {
269  disconnect(locationTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(itemChanged(int,int,int,int)));
270  disconnect(lineTableFilter,SIGNAL(textChanged(QString)),this,SLOT(filterLocations(QString)));
271  disconnect(actionNameSearch,SIGNAL(toggled(bool)),this,SLOT(actionNameSearchToggled(bool)));
272  disconnect(actionItemSearch,SIGNAL(toggled(bool)),this,SLOT(actionItemSearchToggled(bool)));
273  disconnect(actionRegExpSearch,SIGNAL(toggled(bool)),this,SLOT(actionRegExpSearchToggled(bool)));
274  disconnect(actionCaseSensitive,SIGNAL(toggled(bool)),this,SLOT(actionCaseSensitiveToggled(bool)));
275  disconnect(sbMapID,SIGNAL(valueChanged(int)),this,SLOT(sbMapIdChanged(int)));
276  disconnect(sbLocID,SIGNAL(valueChanged(int)),this,SLOT(sbLocIdChanged(int)));
277  disconnect(sbX,SIGNAL(valueChanged(int)),this,SLOT(sbXChanged(int)));
278  disconnect(sbY,SIGNAL(valueChanged(int)),this,SLOT(sbYChanged(int)));
279  disconnect(sbT,SIGNAL(valueChanged(int)),this,SLOT(sbTChanged(int)));
280  disconnect(sbD,SIGNAL(valueChanged(int)),this,SLOT(sbDChanged(int)));
281  disconnect(lineLocationName,SIGNAL(textChanged(QString)),this,SLOT(lineLocationNameChanged(QString)));
282  disconnect(fieldItemList,SIGNAL(clicked(QModelIndex)),this,SLOT(fieldItemListItemChanged(QModelIndex)));
283 }
284 
285 void LocationViewer::itemChanged(int currentRow, int currentColumn, int prevRow, int prevColumn)
286 {
287  if(currentColumn == prevColumn){/*do nothing*/} //stop non use warning
288 
289  if(currentRow ==prevRow){return;}
290  else
291  {
292  int mapID = Locations->mapID(locationTable->item(currentRow,0)->text()).toInt();
293  int locID= Locations->locationID(locationTable->item(currentRow,0)->text()).toInt();
294  setLocation(mapID,locID);
295  if(autoUpdate){emit(locationChanged(Locations->fileName(mapID,locID)));}
296  }
297  //lblLocationPreview->adjustSize();
298 }
299 
300 void LocationViewer::setSelected(QString locFilename)
301 {
302  //if(locFilename == locationTable->item(locationTable->currentRow(),0)->text()){return;}
303  locationTable->setCurrentItem(locationTable->item(-1,-1));
304  for(int i=0;i<Locations->len();i++)
305  {
306  if(locationTable->item(i,0)->text()== locFilename)
307  {
308  bool u = autoUpdate; autoUpdate=true;
309  locationTable->setCurrentItem(locationTable->item(i,0));
310  autoUpdate=u;
311  break;
312  }
313  }
314 }
316 {
317  setLocation(mapId,sbLocID->value());
318  QString fileName = Locations->fileName(mapId,sbLocID->value());
319  if(fileName.isEmpty()){emit(mapIdChanged(mapId));}
320  else{emit(locationChanged(fileName));}
321 }
323 {
324  setLocation(sbMapID->value(),locId);
325  QString fileName = Locations->fileName(sbMapID->value(),locId);
326  if(fileName.isEmpty()){emit(locIdChanged(locId));}
327  else{emit(locationChanged(fileName));}
328 }
329 void LocationViewer::sbXChanged(int x){emit(xChanged(x));}
330 void LocationViewer::sbYChanged(int y){emit(yChanged(y));}
331 void LocationViewer::sbTChanged(int t){emit(tChanged(t));}
332 void LocationViewer::sbDChanged(int d){emit(dChanged(d));}
333 void LocationViewer::setLocation(int mapId,int locId)
334 {
335  init_disconnect();
336  QString fileName = Locations->fileName(mapId,locId);
337  setSelected(fileName);
338 
339  if(fileName.isEmpty()){lblLocationPreview->setPixmap(QString(""));}
340  else
341  {
342  lblLocationPreview->setPixmap(QPixmap(QString("://locations/%1_%2").arg(QString::number(mapId),QString::number(locId))).scaledToWidth(lblLocationPreview->width(),Qt::SmoothTransformation));
343  QString oldStr = Locations->locationString(fileName);
344  QString newStr = translate(oldStr);
345  if(oldStr !=newStr && autoUpdate)
346  {
347  emit(locationStringChanged(newStr));
348  qWarning()<<QString("LocationString Changed: %1").arg(newStr);
349  }
350  sbMapID->setValue(Locations->mapID(fileName).toInt());
351  sbLocID->setValue(Locations->locationID(fileName).toInt());
352  sbX->setValue(Locations->x(fileName).toInt());
353  sbY->setValue(Locations->y(fileName).toInt());
354  sbT->setValue(Locations->t(fileName).toInt());
355  sbD->setValue(Locations->d(fileName).toInt());
356  lineLocationName->setText(newStr);
357  init_fieldItems();
358  }
360 }
361 void LocationViewer::lineLocationNameChanged(QString locName){emit(locationStringChanged(locName));qWarning()<<QString("LocationString Changed: %1").arg(locName);}
366 void LocationViewer::setMapId(int mapId){sbMapID->setValue(mapId);}
367 void LocationViewer::setLocationId(int locId){sbLocID->setValue(locId);}
368 void LocationViewer::setLocationString(QString locString)
369 {
370  init_disconnect();
371  QString newStr = translate(locString);
372  lineLocationName->setText(newStr);
373  if(locString !=newStr && autoUpdate)
374  {
375  emit(locationStringChanged(newStr));
376  qWarning()<<QString("LocationString Changed: %1").arg(newStr);
377  }
379 }
381 {
382  autoUpdate=checked;
383  if(checked){emit locationChanged(Locations->fileName(sbMapID->value(),sbLocID->value()));}
384 }
385 void LocationViewer::setHorizontalHeaderStyle(QString styleSheet){locationTable->horizontalHeader()->setStyleSheet(styleSheet);}
386 void LocationViewer::setRegion(QString newRegion){region=newRegion;setLocation(sbMapID->value(),sbLocID->value());}
387 void LocationViewer::setTranslationBaseFile(QString basePathName){transBasePath= basePathName;}
388 QString LocationViewer::translate(QString text)
389 {
390  if(region ==""){qWarning()<<"Translate: No Region";return text;}
391  if(transBasePath==""){qWarning()<<"Translate: No Base Path";return text;}
392  else
393  {
394  QString lang = transBasePath;
395  QTranslator Translator;// will do the translating.
396  QString reg = region;// remove trailing FF7-SXX
397  reg.chop(7);
398  if(reg =="BASCUS-94163" || reg =="BESCES-00867"){lang.append("en.qm");}
399  else if(reg =="BESCES-00868"){lang.append("fr.qm");}
400  else if(reg =="BESCES-00869"){lang.append("de.qm");}
401  else if(reg =="BESCES-00900"){lang.append("es.qm");}
402  else if(reg =="BISLPS-00700" || reg =="BISLPS-01057"){lang.append("ja.qm");}
403  else{qWarning()<<QString("Unknown Region:%1").arg(reg);return text;}//unknown language.
404  Translator.load(lang);
405  QString newText = Translator.translate("Locations",text.toUtf8());
406  if(newText.isEmpty()){return text;}
407  else{return newText;}
408  }
409 }
411 {
412  QRegExp exp(filter);
413 
414  if(regExpSearch){exp.setPatternSyntax(QRegExp::Wildcard);}
415  else{exp.setPatternSyntax(QRegExp::FixedString);}
416  if(caseSensitive){exp.setCaseSensitivity(Qt::CaseSensitive);}
417  else{exp.setCaseSensitivity(Qt::CaseInsensitive);}
418 
419  switch(searchMode)
420  {
421  case NAME: searchName(exp); break;
422  case ITEM: searchItem(exp); break;
423  }
424 }
425 
427 
429 {
430  if(checked)
431  {
433  searchMode = NAME;
434  lineTableFilter->setPlaceholderText(actionNameSearch->text());
435  if(!lineTableFilter->text().isEmpty()){filterLocations(lineTableFilter->text());}
436  }
437  else{actionNameSearch->setChecked(false);}
438 }
439 
440 
442 {
443  if(checked)
444  {
446  searchMode = ITEM;
447  lineTableFilter->setPlaceholderText(actionItemSearch->text());
448  if(!lineTableFilter->text().isEmpty()){filterLocations(lineTableFilter->text());}
449  }
450  else{actionItemSearch->setChecked(false);}
451 }
452 
454 {
455  regExpSearch=checked;
456  if(!lineTableFilter->text().isEmpty()){filterLocations(lineTableFilter->text());}
457 }
459 {
460  caseSensitive=checked;
461  if(!lineTableFilter->text().isEmpty()){filterLocations(lineTableFilter->text());}
462 }
463 
464 
466 {
467  groupFieldItems->setVisible(false);
468  fieldItemList->clear();
469  QString fieldFileName = Locations->fileName(sbMapID->value(),sbLocID->value()); //store our current field's FileName
470  if(fieldFileName.isEmpty()){fieldItemList->setFixedHeight(0);return;}
471  else
472  {
473  for(int i=0;i<fieldItems->count();i++)
474  {
475  for(int j=0;j<fieldItems->maps(i).count();j++)
476  {
477  if(fieldItems->maps(i).at(j)== fieldFileName)
478  {
479  QListWidgetItem *newItem = new QListWidgetItem(fieldItems->text(i));
480  newItem->setCheckState(Qt::Unchecked);
481  fieldItemList->addItem(newItem);
483  //emit to check the item
484  emit fieldItemCheck(fieldItemList->count()-1);
485  }
486  }
487  }
488  if(fieldItemList->count()>0){groupFieldItems->setVisible(true);}
489 
490  if(fieldItemList->count()<=5)
491  {
492  fieldItemList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
493  fieldItemList->setFixedHeight(fieldItemList->sizeHintForRow(0)*fieldItemList->count() +fieldItemList->contentsMargins().top()+fieldItemList->contentsMargins().bottom());
494  }
495  else
496  {
497  fieldItemList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
498  fieldItemList->setFixedHeight(fieldItemList->sizeHintForRow(0)*5 +fieldItemList->contentsMargins().top()+fieldItemList->contentsMargins().bottom());
499  }
500  groupFieldItems->setFixedHeight(fieldItemList->contentsRect().height() + groupFieldItems->contentsMargins().bottom() + groupFieldItems->contentsMargins().top());
501  }
502 }
504 {
505  bool checked;
506  if(fieldItemList->item(index.row())->checkState() ==Qt::Checked){checked=true;}
507  else{checked=false;}
508  emit fieldItemChanged(index.row(),checked);
509 
510 }
511 void LocationViewer::setFieldItemChecked(int row,bool checked)
512 {
513  init_disconnect();
514  if(fieldItemList->count()>row)
515  {
516  if(checked){fieldItemList->item(row)->setCheckState(Qt::Checked);}
517  else{fieldItemList->item(row)->setCheckState(Qt::Unchecked);}
518  }
520 }
521 void LocationViewer::searchName(QRegExp exp)
522 {
523  for(int i=0;i<locationTable->rowCount();i++)
524  {
525  bool hidden=true;
526  for (int j=0;j<locationTable->columnCount();j++)
527  {
528  if(locationTable->item(i,j)->text().contains(exp)){hidden=false;break;}
529  }
530  locationTable->setRowHidden(i,hidden);
531  }
532 }
533 void LocationViewer::searchItem(QRegExp exp)
534 {
535  QStringList locationNames;
536  for (int i=0 ; i<fieldItems->count();i++)
537  {
538  for(int j=0;j<fieldItems->maps(i).length();j++)
539  {
540  if(fieldItems->text(i).contains(exp))
541  {
542  locationNames.append(fieldItems->maps(i).at(j));
543  }
544  }
545  }
546  for (int i=0; i<locationTable->rowCount();i++)
547  {
548  bool hidden=true;
549  for(int j=0;j<locationNames.count();j++)
550  {
551  if( locationTable->item(i,0)->text() == locationNames.at(j) ){hidden=false;break;}
552  }
553  locationTable->setRowHidden(i,hidden);
554  }
555 }
557 {
559  sbMapID->setVisible(_advancedMode);
560  sbLocID->setVisible(_advancedMode);
561  sbX->setVisible(_advancedMode);
562  sbY->setVisible(_advancedMode);
563  sbT->setVisible(_advancedMode);
564  sbD->setVisible(_advancedMode);
565 }
568 {
569  switch(mode)
570  {
571  case NAME: actionNameSearch->setChecked(true); break;
572  case ITEM: actionItemSearch->setChecked(true); break;
573  }
574  lineTableFilter->setText(filter);
576  for(int i=0;i<locationTable->rowCount();i++)
577  {
578  if(locationTable->isRowHidden(i)){}
579  else{locationTable->selectRow(i); return;}
580  }
581 
582 }
Info about field locations.
Definition: FF7Location.h:36
void init_disconnect(void)
bool advancedMode(void)
void setFieldItemChecked(int row, bool checked)
QList< quint8 > bit(int index)
bit list for an entry (one per offset)
void setRegion(QString region)
void searchItem(QRegExp exp)
QLineEdit * lineLocationName
QSpinBox * sbX
void sbXChanged(int x)
void resizeEvent(QResizeEvent *ev)
QSpinBox * sbMapID
void setY(int y)
QCheckBox * chkAutoUpdate
QAction * actionNameSearch
void setAdvancedMode(bool advancedMode)
QLabel * lblLocationPreview
void yChanged(int y)
void filterLocations(QString filter)
LocationViewer(qreal Scale=1, QWidget *parent=0)
QTableWidget * locationTable
void fieldItemConnectRequest(quint8 index, QList< quint16 > offset, QList< quint8 >bit)
void xChanged(int x)
void init_display(void)
void actionNameSearchToggled(bool checked)
void fieldItemChanged(int index, bool checked)
QString text(int index)
item or desc of item
void fieldItemListItemChanged(QModelIndex index)
FF7Location * Locations
QString mapID(int i)
get map id number
Definition: FF7Location.cpp:22
void init_fieldItems(void)
void chkAutoUpdateChanged(bool checked)
void searchName(QRegExp exp)
void setMapId(int mapId)
void init_connections(void)
QString fileName(int i)
get filename for location (flevel file)
Definition: FF7Location.cpp:20
Data Class to allow the tracking and changing of items being picked up on the field.
QSpinBox * sbLocID
void setFilterString(QString filter="", LocationViewer::filterMode mode=LocationViewer::NAME)
datatype for one item "kernel" style
Definition: FF7Item.h:25
QLineEdit * lineTableFilter
void btnSearchOptionsClicked(void)
void actionCaseSensitiveToggled(bool checked)
int count()
total entries in FILIST
QList< quint16 > offset(int index)
offset list for an entry (offset[x] bit[x] are pairs needed to read/write correctly ...
QAction * actionCaseSensitive
QSpinBox * sbY
FF7FieldItemList * fieldItems
void setHorizontalHeaderStyle(QString styleSheet)
QListWidget * fieldItemList
QString transBasePath
void setLocationId(int locId)
QString t(int i)
triangle of save or valid placment
Definition: FF7Location.cpp:26
QString x(int i)
x coord of save or valid placment
Definition: FF7Location.cpp:24
void itemChanged(int currentRow, int currentColumn, int prevRow, int prevColumn)
int len(void)
how many items on the location list do we have
Definition: FF7Location.h:156
void setD(int d)
QSpinBox * sbD
void setLocation(int mapId, int locId)
void setX(int x)
void locationStringChanged(QString)
void setSelected(QString)
void setTranslationBaseFile(QString)
void tChanged(int t)
void sbTChanged(int t)
bool locationChangesSaved(void)
void fieldItemCheck(int index)
QAction * actionItemSearch
void dChanged(int d)
void locationChanged(QString)
void sbMapIdChanged(int mapId)
QString locationID(int i)
get location id number
Definition: FF7Location.cpp:23
void sbDChanged(int d)
void mapIdChanged(int mapId)
QString d(int i)
direction your facing
Definition: FF7Location.cpp:27
void actionItemSearchToggled(bool checked)
QGroupBox * groupFieldItems
QAction * actionRegExpSearch
QString translate(QString text)
void setT(int t)
void sbYChanged(int y)
void locIdChanged(int locId)
QSpinBox * sbT
QString locationString(int i)
locations String showing menu
Definition: FF7Location.cpp:21
void sbLocIdChanged(int locId)
void setLocationString(QString)
QString y(int i)
y coord of save or valid placment
Definition: FF7Location.cpp:25
void lineLocationNameChanged(QString)
QStringList maps(int index)
map list for an entry.
void setLocationChangesSaved(bool saveChanges)
void actionRegExpSearchToggled(bool checked)
QToolButton * btnSearchOptions