#!/bin/bash

# Getting me from convert_qt_itself8 is easy
# Just do this
# sed -i 's/\(\\\"TQ.*\"\)\/\(.*\)\/g/\2\/\1\/g/g' /kde/source/convert_qt_itself10
# Then replace "*" with "*.ui"

find ./ -type f -iname "*.ui" -exec sed -i 's/TQPOINT_OBJECT_NAME_STRING/\"TQPoint\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQBYTEARRAY_OBJECT_NAME_STRING/\"TQByteArray\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQPIXMAP_OBJECT_NAME_STRING/\"TQPixmap\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSTRING_OBJECT_NAME_STRING/\"TQString\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSTRINGLIST_OBJECT_NAME_STRING/\"TQStringList\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQLAYOUT_OBJECT_NAME_STRING/\"TQLayout\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQBOXLAYOUT_OBJECT_NAME_STRING/\"TQBoxLayout\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQHBOXLAYOUT_OBJECT_NAME_STRING/\"TQHBoxLayout\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQVBOXLAYOUT_OBJECT_NAME_STRING/\"TQVBoxLayout\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQGRIDLAYOUT_OBJECT_NAME_STRING/\"TQGridLayout\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQHBOX_OBJECT_NAME_STRING/\"TQHBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQVBOX_OBJECT_NAME_STRING/\"TQVBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQGRID_OBJECT_NAME_STRING/\"TQGrid\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTABWIDGET_OBJECT_NAME_STRING/\"TQTabWidget\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQCHECKBOX_OBJECT_NAME_STRING/\"TQCheckBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQLINEEDIT_OBJECT_NAME_STRING/\"TQLineEdit\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTEXTEDIT_OBJECT_NAME_STRING/\"TQTextEdit\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQOBJECT_OBJECT_NAME_STRING/\"TQObject\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQWIDGET_OBJECT_NAME_STRING/\"TQWidget\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQGLWIDGET_OBJECT_NAME_STRING/\"TQGLWidget\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQLABEL_OBJECT_NAME_STRING/\"TQLabel\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTIMER_OBJECT_NAME_STRING/\"TQTimer\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQFRAME_OBJECT_NAME_STRING/\"TQFrame\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQACCEL_OBJECT_NAME_STRING/\"TQAccel\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDIALOG_OBJECT_NAME_STRING/\"TQDialog\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDIAL_OBJECT_NAME_STRING/\"TQDial\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQACTION_OBJECT_NAME_STRING/\"TQAction\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQACTIONGROUP_OBJECT_NAME_STRING/\"TQActionGroup\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQLCDNUMBER_OBJECT_NAME_STRING/\"TQLCDNumber\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQPROGRESSBAR_OBJECT_NAME_STRING/\"TQProgressBar\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTABDIALOG_OBJECT_NAME_STRING/\"TQTabDialog\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTABWIDGET_OBJECT_NAME_STRING/\"TQTabWidget\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDOCKWINDOW_OBJECT_NAME_STRING/\"TQDockWindow\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQGROUPBOX_OBJECT_NAME_STRING/\"TQGroupBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQCOMBOBOX_OBJECT_NAME_STRING/\"TQComboBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSPINBOX_OBJECT_NAME_STRING/\"TQSpinBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSPINWIDGET_OBJECT_NAME_STRING/\"TQSpinWidget\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQLISTBOX_OBJECT_NAME_STRING/\"TQListBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTOOLBOX_OBJECT_NAME_STRING/\"TQToolBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTOOLBOXBUTTON_OBJECT_NAME_STRING/\"TQToolBoxButton\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQVGROUPBOX_OBJECT_NAME_STRING/\"TQVGroupBox\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSPLITTER_OBJECT_NAME_STRING/\"TQSplitter\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSPLITTERHANDLE_OBJECT_NAME_STRING/\"TQSplitterHandle\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQBUTTON_OBJECT_NAME_STRING/\"TQButton\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQGRIDVIEW_OBJECT_NAME_STRING/\"TQGridView\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSLIDER_OBJECT_NAME_STRING/\"TQSlider\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQPUSHBUTTON_OBJECT_NAME_STRING/\"TQPushButton\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTOOLBUTTON_OBJECT_NAME_STRING/\"TQToolButton\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQRADIOBUTTON_OBJECT_NAME_STRING/\"TQRadioButton\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQPOPUPMENU_OBJECT_NAME_STRING/\"TQPopupMenu\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTOOLBAR_OBJECT_NAME_STRING/\"TQToolBar\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQMENUBAR_OBJECT_NAME_STRING/\"TQMenuBar\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTABBAR_OBJECT_NAME_STRING/\"TQTabBar\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQLISTVIEW_OBJECT_NAME_STRING/\"TQListView\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSCROLLBAR_OBJECT_NAME_STRING/\"TQScrollBar\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSCROLLVIEW_OBJECT_NAME_STRING/\"TQScrollView\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQRANGECONTROL_OBJECT_NAME_STRING/\"TQRangeControl\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQCANVASITEM_OBJECT_NAME_STRING/\"TQCanvasItem\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQICONVIEW_OBJECT_NAME_STRING/\"TQIconView\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQMULTILINEEDIT_OBJECT_NAME_STRING/\"TQMultiLineEdit\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQINTVALIDATOR_OBJECT_NAME_STRING/\"TQIntValidator\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDATEEDIT_OBJECT_NAME_STRING/\"TQDateEdit\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTIMEEDIT_OBJECT_NAME_STRING/\"TQTimeEdit\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDATETIMEEDIT_OBJECT_NAME_STRING/\"TQDateTimeEdit\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQHEADER_OBJECT_NAME_STRING/\"TQHeader\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQSIZEGRIP_OBJECT_NAME_STRING/\"TQSizeGrip\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING/\"TQDockWindowHandle\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQHIDEDOCK_OBJECT_NAME_STRING/\"TQHideDock\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTABLE_OBJECT_NAME_STRING/\"TQTable\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQWIZARD_OBJECT_NAME_STRING/\"TQWizard\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDATATABLE_OBJECT_NAME_STRING/\"TQDataTable\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDATABROWSER_OBJECT_NAME_STRING/\"TQDataBrowser\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQDATAVIEW_OBJECT_NAME_STRING/\"TQDataView\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQMAINWINDOW_OBJECT_NAME_STRING/\"TQMainWindow\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQWIDGETSTACK_OBJECT_NAME_STRING/\"TQWidgetStack\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQBUTTONGROUP_OBJECT_NAME_STRING/\"TQButtonGroup\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTEXTVIEW_OBJECT_NAME_STRING/\"TQTextView\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQTEXTBROWSER_OBJECT_NAME_STRING/\"TQTextBrowser\"/g' {} \;
find ./ -type f -iname "*.ui" -exec sed -i 's/TQLAYOUTWIDGET_OBJECT_NAME_STRING/\"TQLayoutWidget\"/g' {} \;

find ./ -type f -iname "*.ui" -exec sed -i 's/TQMOTIFPLUSSTYLE_OBJECT_NAME_STRING/\"TQMotifPlusStyle\"/g' {} \;

# Undo a few other problems









find ./ -type f -iname "*" -exec sed -i 's/layoutengine_p\.h/tqlayoutengine_p\.h/g' {} \;

find ./ -type f -iname "*" -exec sed -i 's/Qt::Orientation\"/Orientation\"/g' {} \;

# Undo some of the original changes that are no longer needed








# Replace all last occurrences of tqStatus within a quoted string
# find ./ -type f -iname "*" -exec sed -i 's/\(.*\)\"\([^"]*\)tqStatus\([^"]*\)\"\(.*\)/\1\"\2Status\3\"\4/g' {} \;
# Replace all first occurrences of tqStatus within a quoted string
# find ./ -type f -iname "*" -exec sed -i 's/\([^"]*\)\"\([^"]*\)tqStatus\([^"]*\)\"\(.*\)/\1\"\2Status\3\"\4/g' {} \;
# Replace all second occurrences of tqStatus within a quoted string
# find ./ -type f -iname "*" -exec sed -i 's/\([^"]*\)\"\([^"]*\)\"\([^"]*\)\"\([^"]*\)tqStatus\([^"]*\)\"\(.*\)/\1\"\2\"\3\"\4Status\5\"\6/g' {} \;
# Replace all third occurrences of tqStatus within a quoted string
# find ./ -type f -iname "*" -exec sed -i 's/\([^"]*\)\"\([^"]*\)\"\([^"]*\)\"\([^"]*\)\"\([^"]*\)\"\([^"]*\)\"\([^"]*\)tqStatus\([^"]*\)\"\(.*\)/\1\"\2\"\3\"\4\"\5\"\6\"\7Status\8\"\9/g' {} \;

find ./ -type f -iname "*" -exec sed -i 's/STQL/SQL/g' {} \;

# If "TQ ended up in a cpp file it is probably wrong
find ./ -type f -iname "*.c*" -not -iwholename '*.svn*' -exec sed -i 's/\"TQ\([ABCDEFGHIJKLMNOPQRSTUVWXYZ]\)\([ABCDEFGHIJKLMNOPQRSTUVWXYZ]\)\([ABCDEFGHIJKLMNOPQRSTUVWXYZ"]\)/\"Q\1\2\3/g' {} \;
find ./ -type f -iname "*.h*" -not -iwholename '*.svn*' -exec sed -i 's/\"TQ\([ABCDEFGHIJKLMNOPQRSTUVWXYZ]\)\([ABCDEFGHIJKLMNOPQRSTUVWXYZ]\)\([ABCDEFGHIJKLMNOPQRSTUVWXYZ"]\)/\"Q\1\2\3/g' {} \;
