Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OpenMW/openmw into osg
Browse files Browse the repository at this point in the history
Conflicts:
	apps/opencs/view/render/cell.cpp
  • Loading branch information
scrawl committed Apr 19, 2015
2 parents edc5cad + 4607c4b commit 1699759
Show file tree
Hide file tree
Showing 52 changed files with 1,650 additions and 90 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-reorder -std=c++98 -pedantic -Wno-long-long")

if (CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT APPLE)
execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE CLANG_VERSION)
string(REGEX REPLACE ".*version ([0-9\\.]*).*" "\\1" CLANG_VERSION ${CLANG_VERSION})
if ("${CLANG_VERSION}" VERSION_GREATER 3.6 OR "${CLANG_VERSION}" VERSION_EQUAL 3.6)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression")
endif ("${CLANG_VERSION}" VERSION_GREATER 3.6 OR "${CLANG_VERSION}" VERSION_EQUAL 3.6)
endif(CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT APPLE)

execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (CMAKE_CXX_COMPILER_ID STREQUAL GNU AND "${GCC_VERSION}" VERSION_GREATER 4.6 OR "${GCC_VERSION}" VERSION_EQUAL 4.6)
Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ opencs_units (model/tools
opencs_units_noqt (model/tools
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
startscriptcheck
startscriptcheck search searchoperation searchstage
)


Expand Down Expand Up @@ -91,7 +91,7 @@ opencs_hdrs_noqt (view/render


opencs_units (view/tools
reportsubview reporttable
reportsubview reporttable searchsubview searchbox
)

opencs_units_noqt (view/tools
Expand Down
12 changes: 12 additions & 0 deletions apps/opencs/model/doc/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <cassert>
#include <fstream>
#include <iostream>

#include <boost/filesystem.hpp>

Expand Down Expand Up @@ -2377,6 +2378,17 @@ CSMWorld::UniversalId CSMDoc::Document::verify()
return id;
}


CSMWorld::UniversalId CSMDoc::Document::newSearch()
{
return mTools.newSearch();
}

void CSMDoc::Document::runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search)
{
return mTools.runSearch (searchId, search);
}

void CSMDoc::Document::abortOperation (int type)
{
if (type==State_Saving)
Expand Down
4 changes: 4 additions & 0 deletions apps/opencs/model/doc/document.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ namespace CSMDoc

CSMWorld::UniversalId verify();

CSMWorld::UniversalId newSearch();

void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);

void abortOperation (int type);

const CSMWorld::Data& getData() const;
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/model/doc/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace CSMDoc
State_Saving = 16,
State_Verifying = 32,
State_Compiling = 64, // not implemented yet
State_Searching = 128, // not implemented yet
State_Searching = 128,
State_Loading = 256 // pseudo-state; can not be encountered in a loaded document
};
}
Expand Down
15 changes: 15 additions & 0 deletions apps/opencs/model/settings/usersettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
shiftCtrlDoubleClick->setToolTip ("Action on shift control double click in table:<p>" + toolTip);
}

declareSection ("search", "Search & Replace");
{
Setting *before = createSetting (Type_SpinBox, "char-before",
"Characters before search string");
before->setDefaultValue (10);
before->setRange (0, 1000);
before->setToolTip ("Maximum number of character to display in search result before the searched text");

Setting *after = createSetting (Type_SpinBox, "char-after",
"Characters after search string");
after->setDefaultValue (10);
after->setRange (0, 1000);
after->setToolTip ("Maximum number of character to display in search result after the searched text");
}

{
/******************************************************************
* There are three types of values:
Expand Down
118 changes: 104 additions & 14 deletions apps/opencs/model/tools/reportmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
#include "reportmodel.hpp"

#include <stdexcept>
#include <sstream>

#include "../world/columns.hpp"

CSMTools::ReportModel::Line::Line (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint)
: mId (id), mMessage (message), mHint (hint)
{}

CSMTools::ReportModel::ReportModel (bool fieldColumn)
{
if (fieldColumn)
{
mColumnField = 3;
mColumnDescription = 4;
}
else
{
mColumnDescription = 3;

mColumnField = -1;
}
}

int CSMTools::ReportModel::rowCount (const QModelIndex & parent) const
{
Expand All @@ -16,21 +39,57 @@ int CSMTools::ReportModel::columnCount (const QModelIndex & parent) const
if (parent.isValid())
return 0;

return 3;
return mColumnDescription+1;
}

QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
{
if (role!=Qt::DisplayRole)
return QVariant();

if (index.column()==0)
return static_cast<int> (mRows.at (index.row()).first.getType());
switch (index.column())
{
case Column_Type:

return static_cast<int> (mRows.at (index.row()).mId.getType());

case Column_Id:
{
CSMWorld::UniversalId id = mRows.at (index.row()).mId;

if (id.getArgumentType()==CSMWorld::UniversalId::ArgumentType_Id)
return QString::fromUtf8 (id.getId().c_str());

return QString ("-");
}

case Column_Hint:

return QString::fromUtf8 (mRows.at (index.row()).mHint.c_str());
}

if (index.column()==mColumnDescription)
return QString::fromUtf8 (mRows.at (index.row()).mMessage.c_str());

if (index.column()==mColumnField)
{
std::string field;

std::istringstream stream (mRows.at (index.row()).mHint);

if (index.column()==1)
return QString::fromUtf8 (mRows.at (index.row()).second.first.c_str());
char type, ignore;
int fieldIndex;

return QString::fromUtf8 (mRows.at (index.row()).second.second.c_str());
if ((stream >> type >> ignore >> fieldIndex) && (type=='r' || type=='R'))
{
field = CSMWorld::Columns::getName (
static_cast<CSMWorld::Columns::ColumnId> (fieldIndex));
}

return QString::fromUtf8 (field.c_str());
}

return QVariant();
}

QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orientation, int role) const
Expand All @@ -41,13 +100,19 @@ QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orienta
if (orientation==Qt::Vertical)
return QVariant();

if (section==0)
return "Type";
switch (section)
{
case Column_Type: return "Type";
case Column_Id: return "ID";
}

if (section==1)
if (section==mColumnDescription)
return "Description";

return "Hint";
if (section==mColumnField)
return "Field";

return "-";
}

bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& parent)
Expand All @@ -64,18 +129,43 @@ void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::str
const std::string& hint)
{
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());

mRows.push_back (std::make_pair (id, std::make_pair (message, hint)));
mRows.push_back (Line (id, message, hint));

endInsertRows();
}

void CSMTools::ReportModel::flagAsReplaced (int index)
{
Line& line = mRows.at (index);
std::string hint = line.mHint;

if (hint.empty() || hint[0]!='R')
throw std::logic_error ("trying to flag message as replaced that is not replaceable");

hint[0] = 'r';

line.mHint = hint;

emit dataChanged (this->index (index, 0), this->index (index, columnCount()));
}

const CSMWorld::UniversalId& CSMTools::ReportModel::getUniversalId (int row) const
{
return mRows.at (row).first;
return mRows.at (row).mId;
}

std::string CSMTools::ReportModel::getHint (int row) const
{
return mRows.at (row).second.second;
return mRows.at (row).mHint;
}

void CSMTools::ReportModel::clear()
{
if (!mRows.empty())
{
beginRemoveRows (QModelIndex(), 0, mRows.size()-1);
mRows.clear();
endRemoveRows();
}
}
30 changes: 28 additions & 2 deletions apps/opencs/model/tools/reportmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,32 @@ namespace CSMTools
{
Q_OBJECT

std::vector<std::pair<CSMWorld::UniversalId, std::pair<std::string, std::string> > > mRows;
struct Line
{
Line (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint);

CSMWorld::UniversalId mId;
std::string mMessage;
std::string mHint;
};

std::vector<Line> mRows;

// Fixed columns
enum Columns
{
Column_Type = 0, Column_Id = 1, Column_Hint = 2
};

// Configurable columns
int mColumnDescription;
int mColumnField;

public:

ReportModel (bool fieldColumn = false);

virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;

virtual int columnCount (const QModelIndex & parent = QModelIndex()) const;
Expand All @@ -27,13 +49,17 @@ namespace CSMTools
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;

virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());

void add (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint = "");

void flagAsReplaced (int index);

const CSMWorld::UniversalId& getUniversalId (int row) const;

std::string getHint (int row) const;

void clear();
};
}

Expand Down
Loading

0 comments on commit 1699759

Please sign in to comment.