@ -15,8 +15,6 @@
// You should have received a copy of the GNU Affero General Public License
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "editor_worksheet.h"
# include <set>
// Qt includes
// Qt includes
# include <QtGui/QErrorMessage>
# include <QtGui/QErrorMessage>
# include <QtGui/QTableWidgetItem>
# include <QtGui/QTableWidgetItem>
@ -24,8 +22,11 @@
# include <QtGui/QMessageBox>
# include <QtGui/QMessageBox>
# include <QtGui/QCloseEvent>
# include <QtGui/QCloseEvent>
// Project includes
# include "editor_worksheet.h"
# include "extract_bot_names.h"
# include "extract_bot_names.h"
# include "translation_manager_constants.h"
# include "translation_manager_constants.h"
# include <set>
using namespace std ;
using namespace std ;
@ -206,12 +207,7 @@ void CEditorWorksheet::saveAs(QString filename)
void CEditorWorksheet : : insertRow ( )
void CEditorWorksheet : : insertRow ( )
{
{
int last_row = table_editor - > rowCount ( ) ;
int last_row = table_editor - > rowCount ( ) ;
table_editor - > setRowCount ( last_row + 1 ) ;
current_stack - > push ( new CUndoWorksheetNewCommand ( table_editor , last_row ) ) ;
for ( int j = 0 ; j < table_editor - > columnCount ( ) ; j + + )
{
QTableWidgetItem * item = new QTableWidgetItem ( ) ;
table_editor - > setItem ( last_row , j , item ) ;
}
}
}
void CEditorWorksheet : : deleteRow ( )
void CEditorWorksheet : : deleteRow ( )
@ -223,10 +219,9 @@ void CEditorWorksheet::deleteRow()
msgBox . setStandardButtons ( QMessageBox : : No | QMessageBox : : Yes ) ;
msgBox . setStandardButtons ( QMessageBox : : No | QMessageBox : : Yes ) ;
msgBox . setDefaultButton ( QMessageBox : : No ) ;
msgBox . setDefaultButton ( QMessageBox : : No ) ;
int ret = msgBox . exec ( ) ;
int ret = msgBox . exec ( ) ;
if ( ret = = QMessageBox : : Yes )
if ( ret = = QMessageBox : : Yes )
{
{
table_editor- > removeRow ( selected_row ) ;
current_stack- > push ( new CUndoWorksheetDeleteCommand ( table_editor , selected_row ) ) ;
}
}
table_editor - > clearFocus ( ) ;
table_editor - > clearFocus ( ) ;
@ -237,6 +232,7 @@ void CEditorWorksheet::deleteRow()
void CEditorWorksheet : : worksheetEditorCellEntered ( QTableWidgetItem * item )
void CEditorWorksheet : : worksheetEditorCellEntered ( QTableWidgetItem * item )
{
{
temp_content = item - > text ( ) ;
temp_content = item - > text ( ) ;
current_stack - > push ( new CUndoWorksheetCommand ( table_editor , item , temp_content ) ) ;
}
}
void CEditorWorksheet : : worksheetEditorChanged ( QTableWidgetItem * item )
void CEditorWorksheet : : worksheetEditorChanged ( QTableWidgetItem * item )
@ -250,9 +246,12 @@ void CEditorWorksheet::worksheetEditorChanged(QTableWidgetItem * item)
setWindowModified ( true ) ;
setWindowModified ( true ) ;
}
}
void CEditorWorksheet : : extractBotNames ( list < string > filters , string level_design_path , NLLIGO : : CLigoConfig ligoConfig )
void CEditorWorksheet : : extractBotNames ( list < string > filters , string level_design_path , NLLIGO : : CLigoConfig ligoConfig )
{
{
bool modified = false ;
bool modified = false ;
QList < CTableWidgetItemStore > new_items ;
ExtractBotNames ebn ;
ExtractBotNames ebn ;
ebn . setRequiredSettings ( filters , level_design_path ) ;
ebn . setRequiredSettings ( filters , level_design_path ) ;
ebn . extractBotNamesFromPrimitives ( ligoConfig ) ;
ebn . extractBotNamesFromPrimitives ( ligoConfig ) ;
@ -281,6 +280,12 @@ void CEditorWorksheet::extractBotNames(list<string> filters, string level_design
sheet_name_row - > setBackgroundColor ( QColor ( " #F75D59 " ) ) ;
sheet_name_row - > setBackgroundColor ( QColor ( " #F75D59 " ) ) ;
table_editor - > setItem ( currentRow , 2 , sheet_name_row ) ;
table_editor - > setItem ( currentRow , 2 , sheet_name_row ) ;
if ( ! modified ) modified = true ;
if ( ! modified ) modified = true ;
CTableWidgetItemStore bot_name_row_s ( bot_name_row , currentRow , 0 ) ;
new_items . push_back ( bot_name_row_s ) ;
CTableWidgetItemStore translation_name_row_s ( translation_name_row , currentRow , 1 ) ;
new_items . push_back ( translation_name_row_s ) ;
CTableWidgetItemStore sheet_name_row_s ( sheet_name_row , currentRow , 2 ) ;
new_items . push_back ( sheet_name_row_s ) ;
}
}
}
}
ebn . cleanSimpleNames ( ) ;
ebn . cleanSimpleNames ( ) ;
@ -310,10 +315,18 @@ void CEditorWorksheet::extractBotNames(list<string> filters, string level_design
sheet_name_row - > setBackgroundColor ( QColor ( " #F75D59 " ) ) ;
sheet_name_row - > setBackgroundColor ( QColor ( " #F75D59 " ) ) ;
table_editor - > setItem ( currentRow , 2 , sheet_name_row ) ;
table_editor - > setItem ( currentRow , 2 , sheet_name_row ) ;
if ( ! modified ) modified = true ;
if ( ! modified ) modified = true ;
CTableWidgetItemStore bot_name_row_s ( bot_name_row , currentRow , 0 ) ;
new_items . push_back ( bot_name_row_s ) ;
CTableWidgetItemStore translation_name_row_s ( translation_name_row , currentRow , 1 ) ;
new_items . push_back ( translation_name_row_s ) ;
CTableWidgetItemStore sheet_name_row_s ( sheet_name_row , currentRow , 2 ) ;
new_items . push_back ( sheet_name_row_s ) ;
}
}
}
}
ebn . cleanGenericNames ( ) ;
ebn . cleanGenericNames ( ) ;
}
}
current_stack - > push ( new CUndoWorksheetExtraction ( new_items , table_editor ) ) ;
if ( modified )
if ( modified )
{
{
setWindowModified ( true ) ;
setWindowModified ( true ) ;
@ -355,6 +368,7 @@ void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordLis
return ;
return ;
}
}
bool modified = false ;
bool modified = false ;
QList < CTableWidgetItemStore > new_items ;
for ( i = 0 ; i < allWords . size ( ) ; i + + )
for ( i = 0 ; i < allWords . size ( ) ; i + + )
{
{
string keyName = allWords [ i ] ;
string keyName = allWords [ i ] ;
@ -384,8 +398,14 @@ void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordLis
name_row - > setBackgroundColor ( QColor ( " #F75D59 " ) ) ;
name_row - > setBackgroundColor ( QColor ( " #F75D59 " ) ) ;
table_editor - > setItem ( currentRow , nPos , name_row ) ;
table_editor - > setItem ( currentRow , nPos , name_row ) ;
if ( ! modified ) modified = true ;
if ( ! modified ) modified = true ;
CTableWidgetItemStore key_name_row_s ( key_name_row , currentRow , knPos ) ;
new_items . push_back ( key_name_row_s ) ;
CTableWidgetItemStore name_row_s ( name_row , currentRow , nPos ) ;
new_items . push_back ( name_row_s ) ;
}
}
}
}
current_stack - > push ( new CUndoWorksheetExtraction ( new_items , table_editor ) ) ;
if ( modified )
if ( modified )
{
{
setWindowModified ( true ) ;
setWindowModified ( true ) ;