diff --git a/CMakeLists.txt b/CMakeLists.txt index a30d946..e4be461 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ if (POLICY CMP0053) endif() project(libs) include(SDKMacros.cmake) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(LIBPROJECT 1) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/pip/") include_directories(${CMAKE_CURRENT_BINARY_DIR}/pip) @@ -53,7 +54,7 @@ endif () include(SDKMacros.cmake) set(PIP_LIBRARY pip) -set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection") +set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent") set(PIP_INCLUDES) if(LIB) diff --git a/qad/graphic/graphic.h b/qad/graphic/graphic.h index c2412dc..35d6679 100644 --- a/qad/graphic/graphic.h +++ b/qad/graphic/graphic.h @@ -29,6 +29,8 @@ namespace Ui { class UGLWidget; +Q_DECLARE_METATYPE(QVector) + class Graphic: public QFrame { Q_OBJECT @@ -443,6 +445,7 @@ inline QDataStream & operator >>(QDataStream & s, Graphic::Graduation & v) {s >> class __GraphicRegistrator__ { public: __GraphicRegistrator__() { + qRegisterMetaType >("QVector"); qRegisterMetaType("Graphic::GraphicsData"); qRegisterMetaTypeStreamOperators("Graphic::GraphicsData"); } diff --git a/qad/widgets/qcodeedit.cpp b/qad/widgets/qcodeedit.cpp index a88079e..4ee766f 100644 --- a/qad/widgets/qcodeedit.cpp +++ b/qad/widgets/qcodeedit.cpp @@ -347,6 +347,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) { pos_press = tc.anchor(); if (!tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor)) tc.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); + ui->textCode->setFocus(); ui->textCode->setTextCursor(tc); return true; case QEvent::MouseMove: diff --git a/qad/widgets/session_manager.cpp b/qad/widgets/session_manager.cpp index b6d1138..d027c36 100644 --- a/qad/widgets/session_manager.cpp +++ b/qad/widgets/session_manager.cpp @@ -67,6 +67,8 @@ void SessionManager::save() { sr.setValue(evals[i].first, evals[i].second->expression(), "s", false); for (int i = 0; i < tabs.size(); ++i) sr.setValue(tabs[i].first, tabs[i].second->currentIndex(), false); + for (int i = 0; i < groups.size(); ++i) + sr.setValue(groups[i].first, groups[i].second->isChecked(), false); for (int i = 0; i < buttons.size(); ++i) sr.setValue(buttons[i].first, buttons[i].second->isChecked(), false); for (int i = 0; i < stacks.size(); ++i) @@ -195,6 +197,8 @@ void SessionManager::load(bool onlyMainwindow) { if (v >= 0 && v < t->count()) t->setCurrentIndex(v); } + for (int i = 0; i < groups.size(); ++i) + groups[i].second->setChecked(sr.getValue(groups[i].first, groups[i].second->isChecked())); for (int i = 0; i < buttons.size(); ++i) buttons[i].second->setChecked(sr.getValue(buttons[i].first, buttons[i].second->isChecked())); for (int i = 0; i < stacks.size(); ++i) diff --git a/qad/widgets/session_manager.h b/qad/widgets/session_manager.h index 3a8a5aa..4340904 100644 --- a/qad/widgets/session_manager.h +++ b/qad/widgets/session_manager.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "spinslider.h" #include "evalspinbox.h" #include "qpiconfig.h" @@ -40,6 +41,7 @@ public: void addEntry(SpinSlider * e) {spinsliders.push_back(QPair(e->objectName(), e));} void addEntry(EvalSpinBox * e) {evals.push_back(QPair(e->objectName(), e));} void addEntry(QTabWidget * e) {tabs.push_back(QPair(e->objectName(), e));} + void addEntry(QGroupBox * e) {groups.push_back(QPair(e->objectName(), e));} void addEntry(QAction * e) {actions.push_back(QPair(e->objectName(), e));} void addEntry(QAbstractButton * e) {buttons.push_back(QPair(e->objectName(), e));} void addEntry(QStackedWidget * e) {stacks.push_back(QPair(e->objectName(), e));} @@ -55,6 +57,7 @@ public: void addEntry(const QString & name, SpinSlider * e) {spinsliders.push_back(QPair(name, e));} void addEntry(const QString & name, EvalSpinBox * e) {evals.push_back(QPair(name, e));} void addEntry(const QString & name, QTabWidget * e) {tabs.push_back(QPair(name, e));} + void addEntry(const QString & name, QGroupBox * e) {groups.push_back(QPair(name, e));} void addEntry(const QString & name, QAbstractButton * e) {buttons.push_back(QPair(name, e));} void addEntry(const QString & name, QStackedWidget * e) {stacks.push_back(QPair(name, e));} void addEntry(const QString & name, QAction * e) {actions.push_back(QPair(name, e));} @@ -79,6 +82,7 @@ private: QVector > spinsliders; QVector > evals; QVector > tabs; + QVector > groups; QVector > buttons; QVector > stacks; QVector > actions; diff --git a/qcd_utils/pult/main.cpp b/qcd_utils/pult/main.cpp index 80ed8e9..8f45b2b 100644 --- a/qcd_utils/pult/main.cpp +++ b/qcd_utils/pult/main.cpp @@ -1,10 +1,305 @@ #include #include "cdpultwindow.h" +template +class PIHash { + //template friend PIByteArray & operator >>(PIByteArray & s, PIHash & v); + //template friend PIByteArray & operator <<(PIByteArray & s, const PIHash & v); +public: + PIHash() {;} + PIHash(const PIHash & other) {*this = other;} + virtual ~PIHash() {;} -inline uint qHash(const PIString &t) { - return t.hash(); -} + PIHash & operator =(const PIHash & other) { + if (this == &other) return *this; + clear(); + pih_content = other.pih_content; + return *this; + } + + typedef T mapped_type; + typedef Key key_type; + typedef PIPair value_type; +/* + class iterator { + friend class PIHash; + private: + iterator(const PIHash * v, ssize_t p): parent(v), pos(p) {} + const PIHash * parent; + ssize_t pos; + public: + iterator(): parent(0), pos(0) {} + const Key & key() const {return const_cast * >(parent)->_key(pos);} + T & value() {return const_cast * >(parent)->_value(pos);} + void operator ++() {++pos;} + void operator ++(int) {++pos;} + void operator --() {--pos;} + void operator --(int) {--pos;} + bool operator ==(const iterator & it) const {return (pos == it.pos);} + bool operator !=(const iterator & it) const {return (pos != it.pos);} + }; + + class reverse_iterator { + friend class PIHash; + private: + reverse_iterator(const PIHash * v, ssize_t p): parent(v), pos(p) {} + const PIHash * parent; + ssize_t pos; + public: + reverse_iterator(): parent(0), pos(0) {} + const Key & key() const {return const_cast * >(parent)->_key(pos);} + T & value() const {return const_cast * >(parent)->_value(pos);} + void operator ++() {--pos;} + void operator ++(int) {--pos;} + void operator --() {++pos;} + void operator --(int) {++pos;} + bool operator ==(const reverse_iterator & it) const {return (pos == it.pos);} + bool operator !=(const reverse_iterator & it) const {return (pos != it.pos);} + }; +*/ + class const_iterator { + friend class PIHash; + private: + const_iterator(const PIHash * v, ssize_t p): parent(v), pos(p), bpos(0) { + if (pos == 0) { + pos = -1; + nextPos(); + } + } + void nextPos() { + while (++pos < parent->pih_content.size_s()) { + if (!parent->pih_content[pos].isEmpty()) + return; + } + } + const PIHash * parent; + ssize_t pos, bpos; + public: + const_iterator(): parent(0), pos(0) {} + //const value_type operator *() const {return parent->_pair(pos);} + //const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;} + const Key & key() const {return const_cast * >(parent)->pih_content[pos][bpos].key;} + const T & value() const {return const_cast * >(parent)->pih_content[pos][bpos].value;} + void operator ++() { + if (pos < parent->pih_content.size_s()) { + if (bpos >= parent->pih_content[pos].size_s() - 1) { + bpos = 0; + nextPos(); + } else + ++bpos; + } else { + bpos = 0; + ++pos; + } + printf(" ++: %d %d\n", pos, bpos); + } + //void operator ++(int) {++pos;} + void operator --() { + --pos; + } + //void operator --(int) {--pos;} + bool operator ==(const const_iterator & it) const {return (pos == it.pos && bpos == it.bpos);} + bool operator !=(const const_iterator & it) const {return !(*this == it);} + mutable value_type cval; + }; +/* + class const_reverse_iterator { + friend class PIHash; + private: + const_reverse_iterator(const PIHash * v, ssize_t p): parent(v), pos(p) {} + const PIHash * parent; + ssize_t pos; + public: + const_reverse_iterator(): parent(0), pos(0) {} + const value_type operator *() const {return parent->_pair(pos);} + const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;} + void operator ++() {--pos;} + void operator ++(int) {--pos;} + void operator --() {++pos;} + void operator --(int) {++pos;} + bool operator ==(const const_reverse_iterator & it) const {return (pos == it.pos);} + bool operator !=(const const_reverse_iterator & it) const {return (pos != it.pos);} + mutable value_type cval; + }; +*/ + //iterator begin() {return iterator(this, 0);} + //iterator end() {return iterator(this, size());} + const_iterator begin() const {return const_iterator(this, 0);} + const_iterator end() const {return const_iterator(this, size());} + const_iterator constBegin() const {return const_iterator(this, 0);} + const_iterator constEnd() const {return const_iterator(this, size());} + //reverse_iterator rbegin() {return reverse_iterator(this, size() - 1);} + //reverse_iterator rend() {return reverse_iterator(this, -1);} + //const_reverse_iterator rbegin() const {return const_reverse_iterator(this, size() - 1);} + //const_reverse_iterator rend() const {return const_reverse_iterator(this, -1);} + //const_reverse_iterator constRbegin() const {return const_reverse_iterator(this, size() - 1);} + //const_reverse_iterator constRend() const {return const_reverse_iterator(this, -1);} + + size_t size() const {return pih_content.size();} + int size_s() const {return pih_content.size_s();} + size_t length() const {return pih_content.size();} + size_t capacity() const {return pih_content.size();} + bool isEmpty() const {return (pih_content.size() == 0);} + + T & operator [](const Key & key) { + if (pih_content.isEmpty()) _rehash(1); + uint k = piHash(key); + int i = _index(k); + if (i < pih_content.size_s()) { + PIVector & hv(pih_content[i]); + if (hv.size_s() == 1) { + if (hv[0].key == k) + return hv[0].value; + } + for (int j = 0; j < hv.size_s(); ++j) + if (hv[j].key == k) + return hv[j].value; + } + if (pih_content[i].size_s() >= 4) + _rehash(pih_content.size_s() * 2); + i = _index(k); + pih_content[i] << HashEntry(k); + return pih_content[i].back().value; + } + const T operator [](const Key & key) const {return value(key);} + T & at(const Key & key) {return (*this)[key];} + const T at(const Key & key) const {return (*this)[key];} + + PIHash & operator <<(const PIHash & other) { + if (other.isEmpty()) return *this; + for (int i = 0; i < other.pih_content.size_s(); ++i) + for (int j = 0; j < other.pih_content[i].size_s(); ++j) + insert(other.pih_content[i][j].key, other.pih_content[i][j].value); + return *this; + } + + bool operator ==(const PIHash & t) const {return (pih_content == t.pih_content);} + bool operator !=(const PIHash & t) const {return (pih_content != t.pih_content);} + bool contains(const Key & key) const { + bool f(false); + _find(key, f); + return f; + } + + PIHash & reserve(size_t new_size) {_rehash(new_size); return *this;} + + PIHash & remove(const Key & key) { + uint k = piHash(key); + int i = _index(k); + if (i >= pih_content.size_s()) return *this; + PIVector & hv(pih_content[i]); + for (int j = 0; j < hv.size_s(); ++j) + if (hv[j].key == k) { + hv.remove(j); + --j; + } + return *this; + } + PIHash & erase(const Key & key) {return remove(key);} + PIHash & clear() {pih_content.clear(); return *this;} + + void swap(PIHash & other) { + piSwapBinary > >(pih_content, other.pih_content); + } + + PIHash & insert(const Key & key, const T & value) { + (*this)[key] = value; + return *this; + } + const T value(const Key & key, const T & default_ = T()) const { + uint k = piHash(key); + int i = _index(k); + if (i >= pih_content.size_s()) return default_; + const PIVector & hv(pih_content[i]); + for (int j = 0; j < hv.size_s(); ++j) + if (hv[j].key == k) + return hv[j].value; + return default_; + } + PIVector values() const { + PIVector ret; + for (int i = 0; i < pih_content.size_s(); ++i) + for (int j = 0; j < pih_content[i].size_s(); ++j) + ret << pih_content[i][j].value; + return ret; + } + /*Key key(const T & value_, const Key & default_ = Key()) const { + for (int i = 0; i < pih_content.size_s(); ++i) + for (int j = 0; j < pih_content[i].size_s(); ++j) + if (pih_content[i][j].value == value_) + return pih_content[i][j].key; + return default_; + } + PIVector keys() const { + PIVector ret; + for (int i = 0; i < pih_content.size_s(); ++i) + for (int j = 0; j < pih_content[i].size_s(); ++j) + ret << pih_content[i][j].key; + return ret; + }*/ + + /*void dump() { + piCout << "PIHash" << size() << "entries" << PICoutManipulators::NewLine << "content:"; + for (size_t i = 0; i < pih_content.size(); ++i) + piCout << PICoutManipulators::Tab << i << ":" << pih_content[i]; + piCout << "index:"; + for (size_t i = 0; i < pim_index.size(); ++i) + piCout << PICoutManipulators::Tab << i << ":" << pim_index[i].key << "->" << pim_index[i].index; + }*/ + +protected: + struct HashEntry { + HashEntry(uint k = 0, const T & v = T()): key(k), value(v) {;} + uint key; + T value; + bool operator ==(const HashEntry & s) const {return key == s.key;} + bool operator !=(const HashEntry & s) const {return key != s.key;} + bool operator <(const HashEntry & s) const {return key < s.key;} + bool operator >(const HashEntry & s) const {return key > s.key;} + }; + /*template friend PIByteArray & operator >>(PIByteArray & s, PIDeque::HashEntry> & v); + template friend PIByteArray & operator <<(PIByteArray & s, const PIDeque::HashEntry> & v); + + const value_type _pair(ssize_t index) const { + if (index < 0 || index >= pim_index.size_s()) + return value_type(); + //piCout << "_pair" << index << pim_index[index].index; + return value_type(pim_index[index].key, pih_content[pim_index[index].index]); + } + Key & _key(ssize_t index) {return pim_index[index].key;} + T & _value(ssize_t index) {return pih_content[pim_index[index].index];}*/ + + inline size_t asize(size_t s) { + if (s == 0) return 0; + if (pih_content.size() + pih_content.size() >= s && pih_content.size() < s) + return pih_content.size() + pih_content.size(); + ssize_t t = 0, s_ = s - 1; + while (s_ >> t) ++t; + return (1 << t); + } + int _index(const uint & k) const { + return k % pih_content.size_s(); + } + void _rehash(int ns) { + ns = asize(ns); + if (pih_content.size_s() == ns) return; + PIVector > nhc; + nhc.resize(ns); + for (int i = 0; i < pih_content.size_s(); ++i) { + for (int j = 0; j < pih_content[i].size_s(); ++j) { + HashEntry & e(pih_content[i][j]); + int ni = e.key % ns; + nhc[ni] << e; + } + } + pih_content.swap(nhc); + } + + PIVector > pih_content; +}; + + +uint qHash(const PIString & v, uint seed = 0) {return piHash(v);} int main(int argc, char *argv[]) { @@ -13,40 +308,39 @@ int main(int argc, char *argv[]) { a.setAttribute(Qt::AA_UseHighDpiPixmaps, true); #endif //################################ - QHash h2; - QMap m2; - PIVector keys; - PIString prefix = "1234567890fgbjyfjyjbghjkbgkbgjgsfh jhfgj ghfjhjfjf"; + QHash h2; + QMap m2; + PIString prefix = "1234567890"; PITimeMeasurer tm; double el = 0.; - for (int i=0; i<100000; ++i) keys << randomi(); - piCout << keys.size(); tm.reset(); - for (int i=0; i<100000; ++i) { - h2[keys[i]] = prefix; + for (int i=0; i<10000; ++i) { + h2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi()); } - el = tm.elapsed_m(); piCout << el << h2.capacity() << h2.size(); + el = tm.elapsed_m(); piCout << el << h2.capacity(); tm.reset(); - for (int i=0; i<100000; ++i) { - m2[keys[i]] = prefix; + for (int i=0; i<10000; ++i) { + m2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi()); } el = tm.elapsed_m(); piCout << el; piCout << "*********"; PIString _s; tm.reset(); - for (int i=0; i<100000; ++i) { - _s = h2.value(keys[i]); + for (int i=0; i<10000; ++i) { + _s = h2.value(prefix + PIString::fromNumber(i)+"1234567890"); } el = tm.elapsed_m(); piCout << el << h2.capacity(); tm.reset(); - for (int i=0; i<100000; ++i) { - _s = m2.value(keys[i]); + for (int i=0; i<10000; ++i) { + _s = m2.value(prefix + PIString::fromNumber(i)+"1234567890"); } el = tm.elapsed_m(); piCout << el; + + return 0; //################################ CDPultWindow w; w.show();