mirror of https://github.com/vitalif/openscad
de-Qt'ified printutils
parent
759446d6c3
commit
cb56f700b1
|
@ -79,8 +79,8 @@ private:
|
|||
bool maybeSave();
|
||||
bool checkModified();
|
||||
QString dumpCSGTree(AbstractNode *root);
|
||||
static void consoleOutput(const QString &msg, void *userdata) {
|
||||
static_cast<MainWindow*>(userdata)->console->append(msg);
|
||||
static void consoleOutput(const std::string &msg, void *userdata) {
|
||||
static_cast<MainWindow*>(userdata)->console->append(QString::fromStdString(msg));
|
||||
}
|
||||
void loadViewSettings();
|
||||
void loadDesignSettings();
|
||||
|
|
|
@ -17,5 +17,5 @@ void PolySetCache::print()
|
|||
|
||||
PolySetCache::cache_entry::cache_entry(const shared_ptr<PolySet> &ps) : ps(ps)
|
||||
{
|
||||
if (print_messages_stack.size() > 0) this->msg = print_messages_stack.last();
|
||||
if (print_messages_stack.size() > 0) this->msg = print_messages_stack.back();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ private:
|
|||
|
||||
struct cache_entry {
|
||||
shared_ptr<class PolySet> ps;
|
||||
QString msg;
|
||||
std::string msg;
|
||||
cache_entry(const shared_ptr<PolySet> &ps);
|
||||
~cache_entry() { }
|
||||
};
|
||||
|
|
|
@ -649,7 +649,7 @@ Module *Module::compile_library(std::string filename)
|
|||
|
||||
if (lib_mod) {
|
||||
libs_cache[filename].mod = lib_mod;
|
||||
libs_cache[filename].msg = print_messages_stack.last().toStdString();
|
||||
libs_cache[filename].msg = print_messages_stack.back();
|
||||
} else {
|
||||
libs_cache.erase(filename);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdio.h>
|
||||
#include <QDate>
|
||||
|
||||
QList<QString> print_messages_stack;
|
||||
std::list<std::string> print_messages_stack;
|
||||
OutputHandlerFunc *outputhandler = NULL;
|
||||
void *outputhandler_data = NULL;
|
||||
|
||||
|
@ -14,37 +14,38 @@ void set_output_handler(OutputHandlerFunc *newhandler, void *userdata)
|
|||
|
||||
void print_messages_push()
|
||||
{
|
||||
print_messages_stack.append(QString());
|
||||
print_messages_stack.push_back(std::string());
|
||||
}
|
||||
|
||||
void print_messages_pop()
|
||||
{
|
||||
QString msg = print_messages_stack.takeLast();
|
||||
if (print_messages_stack.size() > 0 && !msg.isNull()) {
|
||||
if (!print_messages_stack.last().isEmpty())
|
||||
print_messages_stack.last() += "\n";
|
||||
print_messages_stack.last() += msg;
|
||||
std::string msg = print_messages_stack.back();
|
||||
print_messages_stack.pop_back();
|
||||
if (print_messages_stack.size() > 0 && !msg.empty()) {
|
||||
if (!print_messages_stack.back().empty()) {
|
||||
print_messages_stack.back() += "\n";
|
||||
}
|
||||
print_messages_stack.back() += msg;
|
||||
}
|
||||
}
|
||||
|
||||
void PRINT(const QString &msg)
|
||||
void PRINT(const std::string &msg)
|
||||
{
|
||||
if (msg.isNull())
|
||||
return;
|
||||
if (msg.empty()) return;
|
||||
if (print_messages_stack.size() > 0) {
|
||||
if (!print_messages_stack.last().isEmpty())
|
||||
print_messages_stack.last() += "\n";
|
||||
print_messages_stack.last() += msg;
|
||||
if (!print_messages_stack.back().empty()) {
|
||||
print_messages_stack.back() += "\n";
|
||||
}
|
||||
print_messages_stack.back() += msg;
|
||||
}
|
||||
PRINT_NOCACHE(msg);
|
||||
}
|
||||
|
||||
void PRINT_NOCACHE(const QString &msg)
|
||||
void PRINT_NOCACHE(const std::string &msg)
|
||||
{
|
||||
if (msg.isNull())
|
||||
return;
|
||||
if (msg.empty()) return;
|
||||
if (!outputhandler) {
|
||||
fprintf(stderr, "%s\n", msg.toUtf8().data());
|
||||
fprintf(stderr, "%s\n", msg.c_str());
|
||||
} else {
|
||||
outputhandler(msg, outputhandler_data);
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
#ifndef PRINTUTILS_H_
|
||||
#define PRINTUTILS_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <QFileInfo>
|
||||
|
||||
typedef void (OutputHandlerFunc)(const QString &msg, void *userdata);
|
||||
typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata);
|
||||
extern OutputHandlerFunc *outputhandler;
|
||||
extern void *outputhandler_data;
|
||||
|
||||
void set_output_handler(OutputHandlerFunc *newhandler, void *userdata);
|
||||
|
||||
extern QList<QString> print_messages_stack;
|
||||
extern std::list<std::string> print_messages_stack;
|
||||
void print_messages_push();
|
||||
void print_messages_pop();
|
||||
|
||||
void PRINT(const QString &msg);
|
||||
#define PRINTF(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT(_m); } while (0)
|
||||
#define PRINTA(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT(_m); } while (0)
|
||||
void PRINT(const std::string &msg);
|
||||
#define PRINTF(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT(_m.toStdString()); } while (0)
|
||||
#define PRINTA(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT(_m.toStdString()); } while (0)
|
||||
|
||||
void PRINT_NOCACHE(const QString &msg);
|
||||
#define PRINTF_NOCACHE(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT_NOCACHE(_m); } while (0)
|
||||
#define PRINTA_NOCACHE(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT_NOCACHE(_m); } while (0)
|
||||
void PRINT_NOCACHE(const std::string &msg);
|
||||
#define PRINTF_NOCACHE(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT_NOCACHE(_m.toStdString()); } while (0)
|
||||
#define PRINTA_NOCACHE(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT_NOCACHE(_m.toStdString()); } while (0)
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const QFileInfo &fi);
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ QString currentdir;
|
|||
QString examplesdir;
|
||||
QString librarydir;
|
||||
|
||||
static void outfile_handler(const QString &msg, void *userdata) {
|
||||
static void outfile_handler(const std::string &msg, void *userdata) {
|
||||
std::ostream *str = static_cast<std::ostream*>(userdata);
|
||||
*str << msg.toUtf8().data() << std::endl;
|
||||
*str << msg << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Reference in New Issue