Skip to content

Commit

Permalink
Version 0.1.4.
Browse files Browse the repository at this point in the history
Added: menu actions to load a single client/scripts profile.
Added: search dialog now shows the last search parameters.
Fixed: on Windows, increased the delay between each keystroke, since sometimes the client didn't receive a letter.
Changed: set the focus on the object list view after searching an item.
Changed: automatic version string generator.
  • Loading branch information
cbnolok committed Jan 2, 2018
1 parent 21eb965 commit 32025a1
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 64 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ before_script:
- printf '#ifndef VERSION_H\n' > src/version.h
- printf '#define VERSION_H\n' >> src/version.h
- printf '#define LEVIATHAN_VERSION \\\n' >> src/version.h
- |
if [[ -z "$TRAVIS_TAG" ]]; then
printf "$TRAVIS_TAG - " >> src/version.h
fi
- git log -1 --format=%ci >> src/version.h
- printf '\n#endif // VERSION_H' >> src/version.h

Expand All @@ -59,7 +63,7 @@ script:

#after_success:
# Pack everything in a zip
- tar -czf LeviathanLinux64-automated-${TRAVIS_TAG}.zip Leviathan ../icons
- tar -czf LeviathanLinux64-automated-${TRAVIS_TAG}.zip Leviathan

deploy:
provider: releases
Expand Down
5 changes: 4 additions & 1 deletion appveyor_generateversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
f.write("#define VERSION_H\n")
f.write("#define LEVIATHAN_VERSION \\\n")
# date is in ISO 8601 format (like 2016-02-18T15:18:39.0000000Z), where Z is the time zone
f.write("%s\n" % environ.get("APPVEYOR_REPO_COMMIT_TIMESTAMP"))
if ("APPVEYOR_REPO_TAG_NAME" in environ):
f.write("%s - %s\n" % (environ.get("APPVEYOR_REPO_TAG_NAME"), environ.get("APPVEYOR_REPO_COMMIT_TIMESTAMP")))
else:
f.write("%s\n" % environ.get("APPVEYOR_REPO_COMMIT_TIMESTAMP"))
f.write("#endif // VERSION_H\n")

f.close()
22 changes: 14 additions & 8 deletions src/forms/maintab_chars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,36 +309,43 @@ void MainTab_Chars::doSearch(bool backwards)
return;
}

// look up the m_categoryMap map to see if we have loaded the QStandardItem corresponding to the ScriptCategory of the object
ScriptCategory* category = obj->m_category;
auto categoryIt = mapSearchByKey(m_categoryMap, category);
auto categoryIt = mapSearchByKey(m_categoryMap, category); // it's an iterator
if (categoryIt == m_categoryMap.end()) // not found? odd..
return;
//QStandardItem* categoryQ = categoryIt->first;

// look up the m_subsectionMap map to see if we have loaded the QStandardItem corresponding to the ScriptSubsection of the object
ScriptSubsection* subsection = obj->m_subsection;
auto subsectionIt = mapSearchByKey(m_subsectionMap, subsection);
auto subsectionIt = mapSearchByKey(m_subsectionMap, subsection); // it's an iterator
if (subsectionIt == m_subsectionMap.end()) // not found? odd..
return;
QStandardItem* subsectionQ = subsectionIt->first;

// now that i have the subsection's QStandardItem, get its QModelIndex
QModelIndex emptyIdx;
QModelIndex subsectionIdx = m_organizer_model->indexFromItem(subsectionQ);
//QModelIndex categoryIdx = m_organizer_model->indexFromItem(categoryQ);

// store the previous loaded subsection: if the current subsection is the same of the previous, there's no need to
// empty and load again the whole subsection list
static QModelIndex prevSubsectionIdx;

ui->treeView_organizer->scrollTo(subsectionIdx, QAbstractItemView::PositionAtCenter);
//ui->treeView_organizer->setExpanded(categoryIdx, true); // automatically expanded by the select method
ui->treeView_organizer->selectionModel()->select(subsectionIdx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current);
if (subsectionIdx != prevSubsectionIdx)
{
onManual_treeView_organizer_selectionChanged(subsectionIdx, emptyIdx);
onManual_treeView_organizer_selectionChanged(subsectionIdx, emptyIdx); // load the new subsection into treeView_objList
prevSubsectionIdx = subsectionIdx;
}

QStandardItem* objQ = m_objMapScriptToQItem[obj]; // should check if found/not found?
QModelIndex objIdx = m_objList_model->indexFromItem(objQ);

onManual_treeView_objList_selectionChanged(objIdx, emptyIdx);
ui->treeView_objList->setFocus();
ui->treeView_objList->scrollTo(objIdx, QAbstractItemView::PositionAtCenter);
ui->treeView_objList->selectionModel()->select(objIdx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Toggle);
}
Expand All @@ -349,6 +356,8 @@ void MainTab_Chars::on_pushButton_search_clicked()
return;

SubDlg_SearchObj dlg(window());
if (m_lastSearchData.initialized)
dlg.setSearchData(m_lastSearchData);
if (!dlg.exec())
return;

Expand All @@ -358,11 +367,8 @@ void MainTab_Chars::on_pushButton_search_clicked()
objTree(SCRIPTOBJ_TYPE_SPAWN)
};

ScriptSearch::SearchBy_t searchBy;
bool caseSensitive;
std::string key;
dlg.getSearchData(searchBy, caseSensitive, key);
m_scriptSearch.reset(new ScriptSearch(trees, searchBy, caseSensitive, key));
m_lastSearchData = dlg.getSearchData();
m_scriptSearch.reset(new ScriptSearch(trees, m_lastSearchData));
doSearch(false);
}

Expand Down
1 change: 1 addition & 0 deletions src/forms/maintab_chars.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private slots:
QStandardItemModel *m_objList_model;

std::unique_ptr<ScriptSearch> m_scriptSearch;
ScriptSearch::SearchData_t m_lastSearchData;

void doSearch (bool backwards);
};
Expand Down
22 changes: 14 additions & 8 deletions src/forms/maintab_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,36 +350,43 @@ void MainTab_Items::doSearch(bool backwards)
return;
}

// look up the m_categoryMap map to see if we have loaded the QStandardItem corresponding to the ScriptCategory of the object
ScriptCategory* category = obj->m_category;
auto categoryIt = mapSearchByKey(m_categoryMap, category);
auto categoryIt = mapSearchByKey(m_categoryMap, category); // it's an iterator
if (categoryIt == m_categoryMap.end()) // not found? odd..
return;
//QStandardItem* categoryQ = categoryIt->first;

// look up the m_subsectionMap map to see if we have loaded the QStandardItem corresponding to the ScriptSubsection of the object
ScriptSubsection* subsection = obj->m_subsection;
auto subsectionIt = mapSearchByKey(m_subsectionMap, subsection);
auto subsectionIt = mapSearchByKey(m_subsectionMap, subsection); // it's an iterator
if (subsectionIt == m_subsectionMap.end()) // not found? odd..
return;
QStandardItem* subsectionQ = subsectionIt->first;

// now that i have the subsection's QStandardItem, get its QModelIndex
QModelIndex emptyIdx;
QModelIndex subsectionIdx = m_organizer_model->indexFromItem(subsectionQ);
//QModelIndex categoryIdx = m_organizer_model->indexFromItem(categoryQ);

// store the previous loaded subsection: if the current subsection is the same of the previous, there's no need to
// empty and load again the whole subsection list
static QModelIndex prevSubsectionIdx;

ui->treeView_organizer->scrollTo(subsectionIdx, QAbstractItemView::PositionAtCenter);
//ui->treeView_organizer->setExpanded(categoryIdx, true); // automatically expanded by the select method
ui->treeView_organizer->selectionModel()->select(subsectionIdx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current);
if (subsectionIdx != prevSubsectionIdx)
{
onManual_treeView_organizer_selectionChanged(subsectionIdx, emptyIdx);
onManual_treeView_organizer_selectionChanged(subsectionIdx, emptyIdx); // load the new subsection into treeView_objList
prevSubsectionIdx = subsectionIdx;
}

QStandardItem* objQ = m_objMapScriptToQItem[obj]; // should check if found/not found?
QModelIndex objIdx = m_objList_model->indexFromItem(objQ);

onManual_treeView_objList_selectionChanged(objIdx, emptyIdx);
ui->treeView_objList->setFocus();
ui->treeView_objList->scrollTo(objIdx, QAbstractItemView::PositionAtCenter);
ui->treeView_objList->selectionModel()->select(objIdx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Toggle);
}
Expand All @@ -390,6 +397,8 @@ void MainTab_Items::on_pushButton_search_clicked()
return;

SubDlg_SearchObj dlg(window());
if (m_lastSearchData.initialized)
dlg.setSearchData(m_lastSearchData);
if (!dlg.exec())
return;

Expand All @@ -400,11 +409,8 @@ void MainTab_Items::on_pushButton_search_clicked()
objTree(SCRIPTOBJ_TYPE_MULTI)
};

ScriptSearch::SearchBy_t searchBy;
bool caseSensitive;
std::string key;
dlg.getSearchData(searchBy, caseSensitive, key);
m_scriptSearch.reset(new ScriptSearch(trees, searchBy, caseSensitive, key));
m_lastSearchData = dlg.getSearchData();
m_scriptSearch.reset(new ScriptSearch(trees, m_lastSearchData));
doSearch(false);
}

Expand Down
1 change: 1 addition & 0 deletions src/forms/maintab_items.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private slots:
QStandardItemModel *m_objList_model;

std::unique_ptr<ScriptSearch> m_scriptSearch;
ScriptSearch::SearchData_t m_lastSearchData;

void doSearch (bool backwards);
};
Expand Down
65 changes: 56 additions & 9 deletions src/forms/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "dlg_profileclient_options.h"
#include "dlg_profilescripts_options.h"
#include <QTimer>
#include <QSignalMapper>


MainWindow::MainWindow(QWidget *parent) :
Expand All @@ -20,10 +21,10 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);

// Setting version in the title bar
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define _STRINGIFY(x) #x
#define TOSTRING(x) _STRINGIFY(x)
QString version = TOSTRING(LEVIATHAN_VERSION);
#undef STRINGIFY
#undef _STRINGIFY
#undef TOSTRING
#ifndef BUILD_NOT_AUTOMATIC
version += "(automated)";
Expand All @@ -39,30 +40,62 @@ MainWindow::MainWindow(QWidget *parent) :
/* Setting up the menubar */

// Generate Client Profiles menu entries
QAction *actionEditClientProfiles = new QAction("Edit Client Profiles", this);
QAction *actionEditClientProfiles = new QAction("Edit Client Profiles", nullptr);
ui->menuProfiles->addAction(actionEditClientProfiles);
connect(actionEditClientProfiles, SIGNAL(triggered(bool)), this, SLOT(onManual_actionEditClientProfiles_triggered()));

QAction *actionLoadDefaultClientProfile = new QAction("Load default Client Profile", this);
QAction *actionLoadDefaultClientProfile = new QAction("Load default Client Profile", nullptr);
ui->menuProfiles->addAction(actionLoadDefaultClientProfile);
connect(actionLoadDefaultClientProfile, SIGNAL(triggered(bool)), this, SLOT(onManual_actionLoadDefaultClientProfile_triggered()));

if (!g_clientProfiles.empty())
{
QMenu *menuLoadClientProfile = new QMenu("Load Client Profile...", nullptr);
QSignalMapper* clientProfilesSignalMapper = new QSignalMapper();
std::vector<QAction*> clientProfileActions;
for (size_t i = 0; i < g_clientProfiles.size(); ++i)
{
clientProfileActions.emplace_back(new QAction(g_clientProfiles[i].m_name.c_str(), nullptr));
menuLoadClientProfile->addAction(clientProfileActions[i]);
connect(clientProfileActions[i], SIGNAL(triggered()), clientProfilesSignalMapper, SLOT(map()));
clientProfilesSignalMapper->setMapping(clientProfileActions[i], (int)i);
}
connect(clientProfilesSignalMapper, SIGNAL(mapped(int)), this, SLOT(onManual_actionLoadClientProfile_mapped(int)));
ui->menuProfiles->addMenu(menuLoadClientProfile);
}

ui->menuProfiles->addSeparator();

// Generate Scripts Profiles menu entries
QAction *actionEditScriptsProfiles = new QAction("Edit Scripts Profiles", this);
QAction *actionEditScriptsProfiles = new QAction("Edit Scripts Profiles", nullptr);
ui->menuProfiles->addAction(actionEditScriptsProfiles);
connect(actionEditScriptsProfiles, SIGNAL(triggered(bool)), this, SLOT(onManual_actionEditScriptsProfiles_triggered()));

QAction *actionLoadDefaultScriptsProfile = new QAction("Load default Scripts Profile", this);
QAction *actionLoadDefaultScriptsProfile = new QAction("Load default Scripts Profile", nullptr);
ui->menuProfiles->addAction(actionLoadDefaultScriptsProfile);
connect(actionLoadDefaultScriptsProfile, SIGNAL(triggered(bool)), this, SLOT(onManual_actionLoadDefaultScriptsProfile_triggered()));

if (!g_scriptsProfiles.empty())
{
QMenu *menuLoadScriptsProfile = new QMenu("Load Scripts Profile...", nullptr);
QSignalMapper* scriptsProfilesSignalMapper = new QSignalMapper();
std::vector<QAction*> scriptsProfileActions;
for (size_t i = 0; i < g_scriptsProfiles.size(); ++i)
{
scriptsProfileActions.emplace_back(new QAction(g_scriptsProfiles[i].m_name.c_str(), nullptr));
menuLoadScriptsProfile->addAction(scriptsProfileActions[i]);
connect(scriptsProfileActions[i], SIGNAL(triggered()), scriptsProfilesSignalMapper, SLOT(map()));
scriptsProfilesSignalMapper->setMapping(scriptsProfileActions[i], (int)i);
}
connect(scriptsProfilesSignalMapper, SIGNAL(mapped(int)), this, SLOT(onManual_actionLoadScriptsProfile_mapped(int)));
ui->menuProfiles->addMenu(menuLoadScriptsProfile);
}

// TODO: add in a submenu the actions to load every single, stored profile

// Generate Settings entry
//ui->menuProfiles->addSeparator();
QAction *actionSettings = new QAction("Settings", this);
QAction *actionSettings = new QAction("Settings", nullptr);
//ui->menuProfiles->addAction(actionSettings);
ui->menuBar->addAction(actionSettings);
connect(actionSettings, SIGNAL(triggered(bool)), this, SLOT(onManual_actionSettings_triggered()));
Expand Down Expand Up @@ -93,6 +126,11 @@ MainWindow::~MainWindow()
}


void MainWindow::on_tabWidget_currentChanged(int /* UNUSED: index */)
{
ui->tabWidget->currentWidget()->setFocus(); // i need the keyboard focus to be able to use CTRL + F to start a search
}

/* Menu bar actions */

void MainWindow::onManual_actionEditClientProfiles_triggered()
Expand Down Expand Up @@ -128,6 +166,16 @@ void MainWindow::onManual_actionSettings_triggered()
dlg.exec();
}

void MainWindow::onManual_actionLoadClientProfile_mapped(int index)
{
loadClientProfile(index);
}

void MainWindow::onManual_actionLoadScriptsProfile_mapped(int index)
{
loadScriptProfile(index);
}

void MainWindow::on_checkBox_onTop_toggled(bool checked)
{
if (checked)
Expand Down Expand Up @@ -225,4 +273,3 @@ void MainWindow::loadScriptProfile(int index)
m_MainTab_Items_inst->updateViews();
}


5 changes: 4 additions & 1 deletion src/forms/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ class MainWindow : public QMainWindow
~MainWindow();

private slots:
void on_tabWidget_currentChanged(int /* UNUSED: index */);
void onManual_actionEditScriptsProfiles_triggered();
void onManual_actionLoadDefaultScriptsProfile_triggered();
void onManual_actionEditClientProfiles_triggered();
void onManual_actionLoadDefaultClientProfile_triggered();
void onManual_actionSettings_triggered();
void onManual_actionLoadClientProfile_mapped(int index);
void onManual_actionLoadScriptsProfile_mapped(int index);
void on_checkBox_onTop_toggled(bool checked);
void on_checkBox_focus_toggled(bool checked);
void loadDefaultProfiles();
void loadDefaultProfiles();

private:
Ui::MainWindow *ui;
Expand Down
37 changes: 31 additions & 6 deletions src/forms/subdlg_searchobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,45 @@ SubDlg_SearchObj::SubDlg_SearchObj(QWidget *parent) :
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

ui->setupUi(this);
ui->radioButton_description->setChecked(true); // default
QTimer::singleShot(50, ui->lineEdit_value, SLOT(setFocus()));
}

void SubDlg_SearchObj::getSearchData(ScriptSearch::SearchBy_t &searchBy, bool &caseSensitive, std::string &key)
ScriptSearch::SearchData_t SubDlg_SearchObj::getSearchData()
{
ScriptSearch::SearchData_t ret;

using s_t = ScriptSearch::SearchBy_t;
if (ui->radioButton_id->isChecked())
searchBy = s_t::ID;
ret.searchBy = s_t::ID;
else if (ui->radioButton_defname->isChecked())
searchBy = s_t::Defname;
ret.searchBy = s_t::Defname;
else //if (ui->radioButton_description->isChecked())
searchBy = s_t::Description;
caseSensitive = ui->checkBox_casesensitive->isChecked();
key = ui->lineEdit_value->text().toStdString();
ret.searchBy = s_t::Description;

ret.caseSensitive = ui->checkBox_casesensitive->isChecked();
ret.key = ui->lineEdit_value->text().toStdString();

ret.initialized = true;
return ret;
}

void SubDlg_SearchObj::setSearchData(ScriptSearch::SearchData_t data)
{
if (!data.initialized)
return;

ui->checkBox_casesensitive->setChecked(data.caseSensitive);
ui->lineEdit_value->setText(data.key.c_str());

using s_t = ScriptSearch::SearchBy_t;
switch (data.searchBy)
{
case s_t::ID: ui->radioButton_id->setChecked(true); break;
case s_t::Defname: ui->radioButton_defname->setChecked(true); break;
//case s_t::Description:
default: ui->radioButton_description->setChecked(true); break;
}
}

SubDlg_SearchObj::~SubDlg_SearchObj()
Expand Down
5 changes: 4 additions & 1 deletion src/forms/subdlg_searchobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class SubDlg_SearchObj : public QDialog
public:
explicit SubDlg_SearchObj(QWidget *parent = 0);
~SubDlg_SearchObj();
void getSearchData(ScriptSearch::SearchBy_t &searchBy, bool &caseSensitive, std::string &key);

ScriptSearch::SearchData_t getSearchData();
void setSearchData(ScriptSearch::SearchData_t data);


private slots:
void on_pushButton_ok_clicked();
Expand Down
Loading

0 comments on commit 32025a1

Please sign in to comment.