diff --git a/MM.o b/MM.o
new file mode 100644
index 0000000..b71227a
Binary files /dev/null and b/MM.o differ
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f3e3389
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,329 @@
+#############################################################################
+# Makefile for building: Ps
+# Generated by qmake (2.01a) (Qt 4.8.3) on: Mon Jan 7 11:33:36 2013
+# Project: Ps.pro
+# Template: app
+# Command: /home/yuri/下载/qt-everywhere-commercial-src-4.8.3/bin/qmake -spec /usr/local/Trolltech/Qt-4.8.3/mkspecs/linux-g++ -o Makefile Ps.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+INCPATH = -I/usr/local/Trolltech/Qt-4.8.3/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.8.3/include/QtCore -I/usr/local/Trolltech/Qt-4.8.3/include/QtGui -I/usr/local/Trolltech/Qt-4.8.3/include -I.
+LINK = g++
+LFLAGS = -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt-4.8.3/lib
+LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-4.8.3/lib -lpython2.6 -lcurl -lQtGui -L/usr/local/Trolltech/Qt-4.8.3/lib -L/usr/X11R6/lib -lQtCore -lpthread
+AR = ar cqs
+RANLIB =
+QMAKE = /home/yuri/下载/qt-everywhere-commercial-src-4.8.3/bin/qmake
+TAR = tar -cf
+COMPRESS = gzip -9f
+COPY = cp -f
+SED = sed
+COPY_FILE = $(COPY)
+COPY_DIR = $(COPY) -r
+STRIP = strip
+INSTALL_FILE = install -m 644 -p
+INSTALL_DIR = $(COPY_DIR)
+INSTALL_PROGRAM = install -m 755 -p
+DEL_FILE = rm -f
+SYMLINK = ln -f -s
+DEL_DIR = rmdir
+MOVE = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR = ./
+
+####### Files
+
+SOURCES = src/browser/main.cpp \
+ src/browser/browser.cpp \
+ src/browser/MM.cpp \
+ src/browser/filemenu.cpp \
+ src/browser/menubar.cpp \
+ src/lib/mm.c \
+ src/util/log.c \
+ src/lib/web.c moc_browser.cpp \
+ moc_filemenu.cpp \
+ moc_menubar.cpp
+OBJECTS = main.o \
+ browser.o \
+ MM.o \
+ filemenu.o \
+ menubar.o \
+ mm.o \
+ log.o \
+ web.o \
+ moc_browser.o \
+ moc_filemenu.o \
+ moc_menubar.o
+DIST = /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/unix.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/linux.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/gcc-base.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/gcc-base-unix.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/g++-base.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/g++-unix.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/qconfig.pri \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/modules/qt_webkit_version.pri \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt_functions.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt_config.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/exclusive_builds.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/default_pre.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/release.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/default_post.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/unix/gdb_dwarf_index.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/warn_on.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/unix/thread.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/moc.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/resources.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/uic.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/yacc.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/lex.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/include_source_dir.prf \
+ Ps.pro
+QMAKE_TARGET = Ps
+DESTDIR =
+TARGET = Ps
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .o .c .cpp .cc .cxx .C
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
+
+####### Build rules
+
+all: Makefile $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
+
+Makefile: Ps.pro /usr/local/Trolltech/Qt-4.8.3/mkspecs/linux-g++/qmake.conf /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/unix.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/linux.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/gcc-base.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/gcc-base-unix.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/g++-base.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/common/g++-unix.conf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/qconfig.pri \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/modules/qt_webkit_version.pri \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt_functions.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt_config.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/exclusive_builds.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/default_pre.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/release.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/default_post.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/unix/gdb_dwarf_index.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/warn_on.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/unix/thread.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/moc.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/resources.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/uic.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/yacc.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/lex.prf \
+ /usr/local/Trolltech/Qt-4.8.3/mkspecs/features/include_source_dir.prf \
+ /usr/local/Trolltech/Qt-4.8.3/lib/libQtGui.prl \
+ /usr/local/Trolltech/Qt-4.8.3/lib/libQtCore.prl
+ $(QMAKE) -spec /usr/local/Trolltech/Qt-4.8.3/mkspecs/linux-g++ -o Makefile Ps.pro
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/common/unix.conf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/common/linux.conf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/common/gcc-base.conf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/common/gcc-base-unix.conf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/common/g++-base.conf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/common/g++-unix.conf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/qconfig.pri:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/modules/qt_webkit_version.pri:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt_functions.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt_config.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/exclusive_builds.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/default_pre.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/release.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/default_post.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/unix/gdb_dwarf_index.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/warn_on.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/qt.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/unix/thread.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/moc.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/resources.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/uic.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/yacc.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/lex.prf:
+/usr/local/Trolltech/Qt-4.8.3/mkspecs/features/include_source_dir.prf:
+/usr/local/Trolltech/Qt-4.8.3/lib/libQtGui.prl:
+/usr/local/Trolltech/Qt-4.8.3/lib/libQtCore.prl:
+qmake: FORCE
+ @$(QMAKE) -spec /usr/local/Trolltech/Qt-4.8.3/mkspecs/linux-g++ -o Makefile Ps.pro
+
+dist:
+ @$(CHK_DIR_EXISTS) .tmp/Ps1.0.0 || $(MKDIR) .tmp/Ps1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Ps1.0.0/ && $(COPY_FILE) --parents src/browser/browser.h src/browser/MM.h src/browser/filemenu.h src/browser/menubar.h src/include/config.h src/include/init_clear.h src/include/log.h src/include/mm.h src/include/web.h .tmp/Ps1.0.0/ && $(COPY_FILE) --parents src/browser/main.cpp src/browser/browser.cpp src/browser/MM.cpp src/browser/filemenu.cpp src/browser/menubar.cpp src/lib/mm.c src/util/log.c src/lib/web.c .tmp/Ps1.0.0/ && (cd `dirname .tmp/Ps1.0.0` && $(TAR) Ps1.0.0.tar Ps1.0.0 && $(COMPRESS) Ps1.0.0.tar) && $(MOVE) `dirname .tmp/Ps1.0.0`/Ps1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Ps1.0.0
+
+
+clean:compiler_clean
+ -$(DEL_FILE) $(OBJECTS)
+ -$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+ -$(DEL_FILE) $(TARGET)
+ -$(DEL_FILE) Makefile
+
+
+check: first
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: moc_browser.cpp moc_filemenu.cpp moc_menubar.cpp
+compiler_moc_header_clean:
+ -$(DEL_FILE) moc_browser.cpp moc_filemenu.cpp moc_menubar.cpp
+moc_browser.cpp: src/browser/menubar.h \
+ src/browser/filemenu.h \
+ src/browser/MM.h \
+ src/include/mm.h \
+ src/include/size.h \
+ src/include/log.h \
+ src/include/config.h \
+ src/browser/browser.h
+ /usr/local/Trolltech/Qt-4.8.3/bin/moc $(DEFINES) $(INCPATH) src/browser/browser.h -o moc_browser.cpp
+
+moc_filemenu.cpp: src/browser/MM.h \
+ src/include/mm.h \
+ src/include/size.h \
+ src/include/log.h \
+ src/include/config.h \
+ src/browser/filemenu.h
+ /usr/local/Trolltech/Qt-4.8.3/bin/moc $(DEFINES) $(INCPATH) src/browser/filemenu.h -o moc_filemenu.cpp
+
+moc_menubar.cpp: src/browser/filemenu.h \
+ src/browser/MM.h \
+ src/include/mm.h \
+ src/include/size.h \
+ src/include/log.h \
+ src/include/config.h \
+ src/browser/menubar.h
+ /usr/local/Trolltech/Qt-4.8.3/bin/moc $(DEFINES) $(INCPATH) src/browser/menubar.h -o moc_menubar.cpp
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+ -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all:
+compiler_uic_clean:
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean
+
+####### Compile
+
+main.o: src/browser/main.cpp src/include/init_clear.h \
+ src/include/log.h \
+ src/include/size.h \
+ src/include/mm.h \
+ src/include/web.h \
+ src/include/config.h \
+ src/browser/browser.h \
+ src/browser/menubar.h \
+ src/browser/filemenu.h \
+ src/browser/MM.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o src/browser/main.cpp
+
+browser.o: src/browser/browser.cpp src/browser/browser.h \
+ src/browser/menubar.h \
+ src/browser/filemenu.h \
+ src/browser/MM.h \
+ src/include/mm.h \
+ src/include/size.h \
+ src/include/log.h \
+ src/include/config.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o browser.o src/browser/browser.cpp
+
+MM.o: src/browser/MM.cpp src/browser/MM.h \
+ src/include/mm.h \
+ src/include/size.h \
+ src/include/log.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o MM.o src/browser/MM.cpp
+
+filemenu.o: src/browser/filemenu.cpp src/browser/filemenu.h \
+ src/browser/MM.h \
+ src/include/mm.h \
+ src/include/size.h \
+ src/include/log.h \
+ src/include/config.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o filemenu.o src/browser/filemenu.cpp
+
+menubar.o: src/browser/menubar.cpp src/browser/menubar.h \
+ src/browser/filemenu.h \
+ src/browser/MM.h \
+ src/include/mm.h \
+ src/include/size.h \
+ src/include/log.h \
+ src/include/config.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o menubar.o src/browser/menubar.cpp
+
+mm.o: src/lib/mm.c src/include/log.h \
+ src/include/size.h \
+ src/include/mm.h
+ $(CC) -c $(CFLAGS) $(INCPATH) -o mm.o src/lib/mm.c
+
+log.o: src/util/log.c src/include/log.h \
+ src/include/size.h
+ $(CC) -c $(CFLAGS) $(INCPATH) -o log.o src/util/log.c
+
+web.o: src/lib/web.c src/include/web.h \
+ src/include/config.h \
+ src/include/log.h \
+ src/include/size.h \
+ src/include/init_clear.h \
+ src/include/mm.h
+ $(CC) -c $(CFLAGS) $(INCPATH) -o web.o src/lib/web.c
+
+moc_browser.o: moc_browser.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_browser.o moc_browser.cpp
+
+moc_filemenu.o: moc_filemenu.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_filemenu.o moc_filemenu.cpp
+
+moc_menubar.o: moc_menubar.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_menubar.o moc_menubar.cpp
+
+####### Install
+
+install: FORCE
+
+uninstall: FORCE
+
+FORCE:
+
diff --git a/Ps b/Ps
new file mode 100755
index 0000000..0d66815
Binary files /dev/null and b/Ps differ
diff --git a/Ps.pro b/Ps.pro
index e69de29..192fd23 100644
--- a/Ps.pro
+++ b/Ps.pro
@@ -0,0 +1,49 @@
+QT += core gui
+QT += webkit webkitwidgets
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = Ps
+TEMPLATE = app
+
+LIBS += -lpython2.6 -lcurl
+
+SOURCES += \
+ src/browser/main.cpp \
+ src/browser/browser.cpp \
+ src/browser/MM.cpp \
+ src/browser/filemenu.cpp \
+ src/browser/menubar.cpp \
+ src/lib/mm.c \
+ src/util/log.c \
+ src/lib/web.c \
+ src/browser/toolbar.cpp \
+ src/browser/arraylist.cpp \
+ src/browser/tab.cpp \
+ src/browser/webpage.cpp \
+ src/browser/pythonparser.cpp \
+ src/browser/tabs.cpp \
+ src/browser/centerlinear.cpp \
+ src/lib/exception.cpp
+
+HEADERS += \
+ src/browser/browser.h \
+ src/browser/MM.h \
+ src/browser/filemenu.h \
+ src/browser/menubar.h \
+ src/include/config.h \
+ src/include/init_clear.h \
+ src/include/log.h \
+ src/include/mm.h \
+ src/include/web.h \
+ src/browser/toolbar.h \
+ src/browser/arraylist.h \
+ src/browser/tab.h \
+ src/browser/webpage.h \
+ src/browser/pythonparser.h \
+ src/browser/tabs.h \
+ src/browser/centerlinear.h \
+ src/include/exception.h
+
+
+
diff --git a/Ps.pro.user b/Ps.pro.user
index 3b440ed..a836d9f 100644
--- a/Ps.pro.user
+++ b/Ps.pro.user
@@ -1,6 +1,6 @@
-
+
ProjectExplorer.Project.ActiveTarget
@@ -11,6 +11,7 @@
true
false
+ true
Cpp
@@ -27,6 +28,7 @@
UTF-8
false
4
+ false
true
1
true
@@ -49,28 +51,29 @@
ProjectExplorer.Project.Target.0
- 桌面
- 桌面
- Qt4ProjectManager.Target.DesktopTarget
- 0
+ Desktop Qt 5.0.0 GCC 32bit (SDK)
+ Desktop Qt 5.0.0 GCC 32bit (SDK)
+ qt.500.gcc.essentials_kit
+ 1
0
0
- ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./home/yuri/QtSDK/debugger/Desktop/bin/gdb
+ true
qmake
- QtProjectManager.QMakeBuildStep
+ QtProjectManager.QMakeBuildStep
false
true
false
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
false
@@ -78,13 +81,14 @@
2
构建
- ProjectExplorer.BuildSteps.Build
+ ProjectExplorer.BuildSteps.Build
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
true
clean
@@ -92,35 +96,35 @@
1
清理
- ProjectExplorer.BuildSteps.Clean
+ ProjectExplorer.BuildSteps.Clean
2
false
- Qt 4.8.3 (qt-everywhere-commercial-src-4.8.3) 发布
+ Debug
- Qt4ProjectManager.Qt4BuildConfiguration
- 0
- /home/yuri/development/Ps/Ps
- 7
- false
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ /home/yuri/development/Ps/Ps-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Debug
+ true
- ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./home/yuri/QtSDK/debugger/Desktop/bin/gdb
+ true
qmake
- QtProjectManager.QMakeBuildStep
+ QtProjectManager.QMakeBuildStep
false
true
false
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
false
@@ -128,13 +132,14 @@
2
构建
- ProjectExplorer.BuildSteps.Build
+ ProjectExplorer.BuildSteps.Build
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
true
clean
@@ -142,35 +147,109 @@
1
清理
- ProjectExplorer.BuildSteps.Clean
+ ProjectExplorer.BuildSteps.Clean
2
false
- Qt 4.8.3 (qt-everywhere-commercial-src-4.8.3) 调试
+ Release
- Qt4ProjectManager.Qt4BuildConfiguration
- 2
- /home/yuri/development/Ps/Ps
- 7
- false
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ /home/yuri/development/Ps/Ps-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Release
+ true
+
+ 2
+
+
+ 0
+ 部署
+
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ 在本地部署
+
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ 25
+
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ Ps
+
+ Qt4ProjectManager.Qt4RunConfiguration:/home/yuri/development/Ps/Ps/Ps.pro
+ 2
+
+ Ps.pro
+ false
+ false
+
+
+ 3768
+ true
+ false
+ false
+ true
-
- ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./home/yuri/QtSDK/debugger/Desktop/bin/gdb
+ 1
+
+
+
+ ProjectExplorer.Project.Target.1
+
+ 桌面-Qt 4.8.3 (qt-everywhere-commercial-src-4.8.3)
+ 桌面-Qt 4.8.3 (qt-everywhere-commercial-src-4.8.3)
+ {af445c4a-f675-4cc0-bbee-246c9fe02c53}
+ 0
+ 0
+ 0
+
+ true
qmake
- QtProjectManager.QMakeBuildStep
+ QtProjectManager.QMakeBuildStep
false
- true
+ false
false
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
false
@@ -178,13 +257,14 @@
2
构建
- ProjectExplorer.BuildSteps.Build
+ ProjectExplorer.BuildSteps.Build
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
true
clean
@@ -192,35 +272,109 @@
1
清理
- ProjectExplorer.BuildSteps.Clean
+ ProjectExplorer.BuildSteps.Clean
2
false
- Desktop Qt 4.8.1 for GCC (Qt SDK) 发布
+ Release
- Qt4ProjectManager.Qt4BuildConfiguration
+ Qt4ProjectManager.Qt4BuildConfiguration
0
/home/yuri/development/Ps/Ps
- 4
false
-
- ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./home/yuri/QtSDK/debugger/Desktop/bin/gdb
+ 1
+
+
+ 0
+ 部署
+
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ 在本地部署
+
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ 25
+
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ Ps
+
+ Qt4ProjectManager.Qt4RunConfiguration:/home/yuri/development/Ps/Ps/Ps.pro
+ 2
+
+ Ps.pro
+ false
+ false
+
+
+ 3768
+ true
+ false
+ false
+ true
+
+ 1
+
+
+
+ ProjectExplorer.Project.Target.2
+
+ Qt in PATH
+ Qt in PATH
+ {4766b14d-6f6e-4032-b762-0538e648bf30}
+ 0
+ 0
+ 0
+
+ true
qmake
- QtProjectManager.QMakeBuildStep
- false
- true
+ QtProjectManager.QMakeBuildStep
+ true
+ false
false
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
false
@@ -228,13 +382,14 @@
2
构建
- ProjectExplorer.BuildSteps.Build
+ ProjectExplorer.BuildSteps.Build
+ true
Make
- Qt4ProjectManager.MakeStep
+ Qt4ProjectManager.MakeStep
true
clean
@@ -242,61 +397,97 @@
1
清理
- ProjectExplorer.BuildSteps.Clean
+ ProjectExplorer.BuildSteps.Clean
2
false
- Desktop Qt 4.8.1 for GCC (Qt SDK) 调试
+ Debug
- Qt4ProjectManager.Qt4BuildConfiguration
+ Qt4ProjectManager.Qt4BuildConfiguration
2
- /home/yuri/development/Ps/Ps
- 4
- false
+ /home/yuri/development/Ps/Ps-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Debug
+ true
- 4
+
+
+
+ true
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+ false
+
+ false
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+ false
+
+
+
+ 2
+ 构建
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Make
+
+ Qt4ProjectManager.MakeStep
+ true
+ clean
+
+
+ 1
+ 清理
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ /home/yuri/development/Ps/Ps-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Release
+ true
+
+ 2
0
部署
- ProjectExplorer.BuildSteps.Deploy
+ ProjectExplorer.BuildSteps.Deploy
1
- 当前无部署
+ 在本地部署
- ProjectExplorer.DefaultDeployConfiguration
+ ProjectExplorer.DefaultDeployConfiguration
1
true
- true
-
false
- false
- false
false
false
- false
false
- false
- true
true
0.01
- 0.01
- 10
10
true
- true
- 25
25
-
true
- true
- valgrind
valgrind
0
@@ -315,26 +506,9 @@
13
14
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
Ps
- Qt4ProjectManager.Qt4RunConfiguration
+ Qt4ProjectManager.Qt4RunConfiguration:/home/yuri/development/Ps/Ps/Ps.pro
2
Ps.pro
@@ -344,15 +518,16 @@
3768
true
+ false
false
- false
+ true
1
ProjectExplorer.Project.TargetCount
- 1
+ 3
ProjectExplorer.Project.Updater.EnvironmentId
@@ -360,6 +535,6 @@
ProjectExplorer.Project.Updater.FileVersion
- 10
+ 12
diff --git a/browser.o b/browser.o
new file mode 100644
index 0000000..50010f2
Binary files /dev/null and b/browser.o differ
diff --git a/filemenu.o b/filemenu.o
new file mode 100644
index 0000000..65f4fae
Binary files /dev/null and b/filemenu.o differ
diff --git a/log.o b/log.o
new file mode 100644
index 0000000..6b26768
Binary files /dev/null and b/log.o differ
diff --git a/main.o b/main.o
new file mode 100644
index 0000000..63b5201
Binary files /dev/null and b/main.o differ
diff --git a/menubar.o b/menubar.o
new file mode 100644
index 0000000..285dd20
Binary files /dev/null and b/menubar.o differ
diff --git a/mm.o b/mm.o
new file mode 100644
index 0000000..b9eb341
Binary files /dev/null and b/mm.o differ
diff --git a/moc_browser.cpp b/moc_browser.cpp
new file mode 100644
index 0000000..becc309
--- /dev/null
+++ b/moc_browser.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'browser.h'
+**
+** Created: Mon Jan 7 11:45:30 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "src/browser/browser.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'browser.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Browser[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_Browser[] = {
+ "Browser\0"
+};
+
+void Browser::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ Q_UNUSED(_o);
+ Q_UNUSED(_id);
+ Q_UNUSED(_c);
+ Q_UNUSED(_a);
+}
+
+const QMetaObjectExtraData Browser::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject Browser::staticMetaObject = {
+ { &QMainWindow::staticMetaObject, qt_meta_stringdata_Browser,
+ qt_meta_data_Browser, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &Browser::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *Browser::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *Browser::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_Browser))
+ return static_cast(const_cast< Browser*>(this));
+ return QMainWindow::qt_metacast(_clname);
+}
+
+int Browser::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QMainWindow::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/moc_browser.o b/moc_browser.o
new file mode 100644
index 0000000..c411f51
Binary files /dev/null and b/moc_browser.o differ
diff --git a/moc_filemenu.cpp b/moc_filemenu.cpp
new file mode 100644
index 0000000..2f767f6
--- /dev/null
+++ b/moc_filemenu.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'filemenu.h'
+**
+** Created: Mon Jan 7 11:39:05 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "src/browser/filemenu.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'filemenu.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_FileChooser[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_FileChooser[] = {
+ "FileChooser\0"
+};
+
+void FileChooser::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ Q_UNUSED(_o);
+ Q_UNUSED(_id);
+ Q_UNUSED(_c);
+ Q_UNUSED(_a);
+}
+
+const QMetaObjectExtraData FileChooser::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject FileChooser::staticMetaObject = {
+ { &QFileDialog::staticMetaObject, qt_meta_stringdata_FileChooser,
+ qt_meta_data_FileChooser, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &FileChooser::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *FileChooser::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *FileChooser::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_FileChooser))
+ return static_cast(const_cast< FileChooser*>(this));
+ return QFileDialog::qt_metacast(_clname);
+}
+
+int FileChooser::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QFileDialog::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
+static const uint qt_meta_data_FileMenu[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 5, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 4, // signalCount
+
+ // signals: signature, parameters, type, tag, flags
+ 19, 10, 9, 9, 0x05,
+ 59, 50, 9, 9, 0x05,
+ 86, 9, 9, 9, 0x05,
+ 110, 9, 9, 9, 0x05,
+
+ // slots: signature, parameters, type, tag, flags
+ 124, 9, 9, 9, 0x08,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_FileMenu[] = {
+ "FileMenu\0\0location\0open_location_signal(QString&)\0"
+ "filename\0open_file_signal(QString&)\0"
+ "create_new_tab_signal()\0exit_signal()\0"
+ "open_file_slot()\0"
+};
+
+void FileMenu::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ Q_ASSERT(staticMetaObject.cast(_o));
+ FileMenu *_t = static_cast(_o);
+ switch (_id) {
+ case 0: _t->open_location_signal((*reinterpret_cast< QString(*)>(_a[1]))); break;
+ case 1: _t->open_file_signal((*reinterpret_cast< QString(*)>(_a[1]))); break;
+ case 2: _t->create_new_tab_signal(); break;
+ case 3: _t->exit_signal(); break;
+ case 4: _t->open_file_slot(); break;
+ default: ;
+ }
+ }
+}
+
+const QMetaObjectExtraData FileMenu::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject FileMenu::staticMetaObject = {
+ { &QMenu::staticMetaObject, qt_meta_stringdata_FileMenu,
+ qt_meta_data_FileMenu, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &FileMenu::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *FileMenu::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *FileMenu::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_FileMenu))
+ return static_cast(const_cast< FileMenu*>(this));
+ return QMenu::qt_metacast(_clname);
+}
+
+int FileMenu::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QMenu::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ if (_id < 5)
+ qt_static_metacall(this, _c, _id, _a);
+ _id -= 5;
+ }
+ return _id;
+}
+
+// SIGNAL 0
+void FileMenu::open_location_signal(QString & _t1)
+{
+ void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) };
+ QMetaObject::activate(this, &staticMetaObject, 0, _a);
+}
+
+// SIGNAL 1
+void FileMenu::open_file_signal(QString & _t1)
+{
+ void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) };
+ QMetaObject::activate(this, &staticMetaObject, 1, _a);
+}
+
+// SIGNAL 2
+void FileMenu::create_new_tab_signal()
+{
+ QMetaObject::activate(this, &staticMetaObject, 2, 0);
+}
+
+// SIGNAL 3
+void FileMenu::exit_signal()
+{
+ QMetaObject::activate(this, &staticMetaObject, 3, 0);
+}
+QT_END_MOC_NAMESPACE
diff --git a/moc_filemenu.o b/moc_filemenu.o
new file mode 100644
index 0000000..12772b5
Binary files /dev/null and b/moc_filemenu.o differ
diff --git a/moc_menubar.cpp b/moc_menubar.cpp
new file mode 100644
index 0000000..f6fcea0
--- /dev/null
+++ b/moc_menubar.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'menubar.h'
+**
+** Created: Mon Jan 7 11:45:31 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.3)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "src/browser/menubar.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'menubar.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.3. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_MenuBar[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 4, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 4, // signalCount
+
+ // signals: signature, parameters, type, tag, flags
+ 18, 9, 8, 8, 0x05,
+ 58, 49, 8, 8, 0x05,
+ 85, 8, 8, 8, 0x05,
+ 109, 8, 8, 8, 0x05,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_MenuBar[] = {
+ "MenuBar\0\0location\0open_location_signal(QString&)\0"
+ "filename\0open_file_signal(QString&)\0"
+ "create_new_tab_signal()\0exit_signal()\0"
+};
+
+void MenuBar::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ Q_ASSERT(staticMetaObject.cast(_o));
+ MenuBar *_t = static_cast(_o);
+ switch (_id) {
+ case 0: _t->open_location_signal((*reinterpret_cast< QString(*)>(_a[1]))); break;
+ case 1: _t->open_file_signal((*reinterpret_cast< QString(*)>(_a[1]))); break;
+ case 2: _t->create_new_tab_signal(); break;
+ case 3: _t->exit_signal(); break;
+ default: ;
+ }
+ }
+}
+
+const QMetaObjectExtraData MenuBar::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject MenuBar::staticMetaObject = {
+ { &QMenuBar::staticMetaObject, qt_meta_stringdata_MenuBar,
+ qt_meta_data_MenuBar, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &MenuBar::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *MenuBar::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *MenuBar::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_MenuBar))
+ return static_cast(const_cast< MenuBar*>(this));
+ return QMenuBar::qt_metacast(_clname);
+}
+
+int MenuBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QMenuBar::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ if (_id < 4)
+ qt_static_metacall(this, _c, _id, _a);
+ _id -= 4;
+ }
+ return _id;
+}
+
+// SIGNAL 0
+void MenuBar::open_location_signal(QString & _t1)
+{
+ void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) };
+ QMetaObject::activate(this, &staticMetaObject, 0, _a);
+}
+
+// SIGNAL 1
+void MenuBar::open_file_signal(QString & _t1)
+{
+ void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) };
+ QMetaObject::activate(this, &staticMetaObject, 1, _a);
+}
+
+// SIGNAL 2
+void MenuBar::create_new_tab_signal()
+{
+ QMetaObject::activate(this, &staticMetaObject, 2, 0);
+}
+
+// SIGNAL 3
+void MenuBar::exit_signal()
+{
+ QMetaObject::activate(this, &staticMetaObject, 3, 0);
+}
+QT_END_MOC_NAMESPACE
diff --git a/moc_menubar.o b/moc_menubar.o
new file mode 100644
index 0000000..772cbee
Binary files /dev/null and b/moc_menubar.o differ
diff --git a/src/browser/MM.cpp b/src/browser/MM.cpp
new file mode 100644
index 0000000..f024ac2
--- /dev/null
+++ b/src/browser/MM.cpp
@@ -0,0 +1,44 @@
+/**
+ * 用于C++的内存管理
+ * 调试选项:g++ -o __MM__ MM.cpp ../lib/mm.c -lpython2.6
+ */
+#include "MM.h"
+
+/*template
+T*
+Ps_New()
+{
+ int size = sizeof(T);
+ void *p = Ps_Malloc(size);
+ return (T*)p;
+}
+
+template
+T*
+Ps_New(int number)
+{
+ int size = sizeof(T) * number;
+ void *p = Ps_Malloc(size);
+ return (T*)p;
+}*/
+
+void Ps_Delete(void *p)
+{
+ Ps_Free(p);
+}
+
+#ifdef MM_CPP_DEBUG
+#include
+#include
+using namespace std;
+int main(int argc, char **argv)
+{
+ int *i = Ps_New();
+ string *s = Ps_New();
+ new(s) string("hello world");
+ *i = 10;
+ cout << *i << " " << i << "\n" << *s << endl;
+ Ps_Delete(s);
+ Ps_Delete(i);
+}
+#endif
diff --git a/src/browser/MM.h b/src/browser/MM.h
new file mode 100644
index 0000000..9c7c881
--- /dev/null
+++ b/src/browser/MM.h
@@ -0,0 +1,34 @@
+#ifndef MM_CPP_H
+#define MM_CPP_H
+#include "../include/mm.h"
+#include "../include/log.h"
+#include "../include/exception.h"
+//#define MM_CPP_DEBUG
+
+
+template
+T*
+Ps_New()
+{
+ int size = sizeof(T);
+ void *p = Ps_Malloc(size);
+ if(!p)
+ throw Ps_NoMemeryException();
+ return (T*)p;
+}
+
+template
+T*
+Ps_New(int number)
+{
+ int size = sizeof(T) * number;
+ void *p = Ps_Malloc(size);
+ if(!p)
+ throw Ps_NoMemeryException();
+ return (T*)p;
+}
+
+void Ps_Delete(void *p);
+
+
+#endif // MM_H
diff --git a/src/browser/arraylist.cpp b/src/browser/arraylist.cpp
new file mode 100644
index 0000000..1a370cc
--- /dev/null
+++ b/src/browser/arraylist.cpp
@@ -0,0 +1,211 @@
+/**
+ * g++ -o __arraylist__ arraylist.cpp MM.cpp ../lib/mm.c ../util/log.c -lpython2.6 -lcurl
+ */
+#include "arraylist.h"
+
+/*template
+ArrayList::ArrayList() :
+ size(0), capacipy(FIRST_SIZE)
+{
+ values = Ps_New(FIRST_SIZE);
+}
+
+template
+ArrayList::ArrayList(T value) :
+ size(1), capacipy(FIRST_SIZE)
+{
+ values = Ps_New(FIRST_SIZE);
+ values[0] = value;
+}
+
+template
+ArrayList::ArrayList(ArrayList &a)
+{
+ size = a.size;
+ capacipy = a.capacipy;
+ values = Ps_New(capacipy);
+ memcpy(values, a.values, sizeof(T) * size);
+}
+
+template
+ArrayList::~ArrayList()
+{
+ Ps_Delete(values);
+}
+
+template
+bool ArrayList::at(int location, T value)
+{
+ T* temp;
+ if(location < 0 || location > size)
+ return false;
+ if(location == capacipy)
+ {
+ temp = Ps_New(ENLARGE_FACTOR * capacipy);
+ memcpy(temp, values, sizeof(T) * capacipy);
+ capacipy *= ENLARGE_FACTOR;
+ values = temp;
+
+ }
+ if(location == size)
+ size ++;
+ values[location] = value;
+ return true;
+}
+
+template
+bool ArrayList::at(int location, T *ret)
+{
+ if(location < 0 || location >= size)
+ {
+ ret = NULL;
+ return false;
+ }
+ *ret = values[location];
+ return true;
+}
+
+template
+T
+ArrayList::at(int location)
+{
+ return values[location];
+}
+
+template
+bool
+ArrayList::insert(int location, T value)
+{
+ T *temp;
+ int i = size - 1;
+ if(location < 0 || location > size)
+ {
+ return false;
+ }
+ if(size >= capacipy)
+ {
+ temp = Ps_New(capacipy * ENLARGE_FACTOR);
+ memcpy(temp, values, sizeof(T) * capacipy);
+ capacipy *= ENLARGE_FACTOR;
+ Ps_Delete(values);
+ values = temp;
+ }
+ for(; i >= location; i --)
+ {
+ values[i + 1] = values[i];
+ }
+ values[location] = value;
+ size ++;
+ return true;
+}
+
+template
+bool
+ArrayList::del(int location)
+{
+ int i;
+ if(location < 0 || location >= size)
+ {
+ return false;
+ }
+ if(location == size - 1)
+ {
+ size --;
+ return true;
+ }
+ for(i = location; i < size - 1; i ++)
+ {
+ values[i] = values[i + 1];
+ }
+ size --;
+ return true;
+}
+
+template
+int
+ArrayList::get_size() const
+{
+ return this->size;
+}
+
+template
+void ArrayList::insert_head(T value)
+{
+ (void)insert(0, value);
+}
+
+template
+void
+ArrayList::append(T value)
+{
+ insert(size, value);
+}
+
+template
+int
+ArrayList::find(T value)
+{
+ int i = 0;
+ for(; i < size; i ++)
+ {
+ if(values[i] == value)
+ return i;
+ }
+ return -1;
+}
+
+template
+void
+ArrayList::clear()
+{
+ size = 0;
+}
+
+#ifdef ARRAYLIST_DEBUG
+#include
+using namespace std;
+
+template
+void show_info(ArrayList al)
+{
+ int i = 0;
+ for(; i < al.get_size(); i ++)
+ {
+ cout << al.at(i) << " ";
+ }
+ cout << endl;
+}
+
+int main(int argc, char **argv)
+{
+ ArrayList ints;
+ ints.at(0, 12);
+ show_info(ints);
+ ints.append(34);
+ show_info(ints);
+ ints.at(0, 43);
+ show_info(ints);
+ ints.insert_head(42);
+ show_info(ints);
+ ints.append(32);
+ show_info(ints);
+ ints.del(0);
+ show_info(ints);
+ ints.del(3);
+ show_info(ints);
+ ints.del(2);
+ show_info(ints);
+ for(int i = 10; i < 25; i ++)
+ ints.append(i);
+ show_info(ints);
+ for(int i = ints.get_size(); i < 45; i ++)
+ ints.insert(i - 5, i);
+ show_info(ints);
+ cout << ints.find(42) << endl;
+ ints.clear();
+ show_info(ints);
+ cout << ints.find(42) << endl;
+}
+#endif*/
+
+
diff --git a/src/browser/arraylist.h b/src/browser/arraylist.h
new file mode 100644
index 0000000..762f6d9
--- /dev/null
+++ b/src/browser/arraylist.h
@@ -0,0 +1,249 @@
+#ifndef ARRAYLIST_H
+#define ARRAYLIST_H
+#include
+#include "MM.h"
+
+#define FIRST_SIZE 8
+#define ENLARGE_FACTOR 2
+
+//#define ARRAYLIST_DEBUG
+
+template
+class ArrayList
+{
+public:
+ ArrayList();
+ ArrayList(T value);
+ ArrayList(ArrayList &a);
+ ~ArrayList();
+ bool at(int location, T value);
+ bool at(int location, T *ret);
+ T at(int locatin);
+ bool insert(int location, T value);
+ bool del(int location);
+ int get_size() const;
+ void insert_head(T value);
+ void append(T value);
+ /*Need self overload operator =*/
+ int find(T value);
+ void clear();
+private:
+ T *values;
+ int size;
+ int capacipy;
+};
+
+/**
+ * g++ -o __arraylist__ arraylist.cpp MM.cpp ../lib/mm.c ../util/log.c -lpython2.6 -lcurl
+ */
+#include "arraylist.h"
+
+template
+ArrayList::ArrayList() :
+ size(0), capacipy(FIRST_SIZE)
+{
+ values = Ps_New(FIRST_SIZE);
+}
+
+template
+ArrayList::ArrayList(T value) :
+ size(1), capacipy(FIRST_SIZE)
+{
+ values = Ps_New(FIRST_SIZE);
+ values[0] = value;
+}
+
+template
+ArrayList::ArrayList(ArrayList &a)
+{
+ size = a.size;
+ capacipy = a.capacipy;
+ values = Ps_New(capacipy);
+ memcpy(values, a.values, sizeof(T) * size);
+}
+
+template
+ArrayList::~ArrayList()
+{
+ Ps_Delete(values);
+}
+
+template
+bool ArrayList::at(int location, T value)
+{
+ T* temp;
+ if(location < 0 || location > size)
+ return false;
+ if(location == capacipy)
+ {
+ temp = Ps_New(ENLARGE_FACTOR * capacipy);
+ memcpy(temp, values, sizeof(T) * capacipy);
+ capacipy *= ENLARGE_FACTOR;
+ values = temp;
+
+ }
+ if(location == size)
+ size ++;
+ values[location] = value;
+ return true;
+}
+
+template
+bool ArrayList::at(int location, T *ret)
+{
+ if(location < 0 || location >= size)
+ {
+ ret = NULL;
+ return false;
+ }
+ *ret = values[location];
+ return true;
+}
+
+template
+T
+ArrayList::at(int location)
+{
+ return values[location];
+}
+
+template
+bool
+ArrayList::insert(int location, T value)
+{
+ T *temp;
+ int i = size - 1;
+ if(location < 0 || location > size)
+ {
+ return false;
+ }
+ if(size >= capacipy)
+ {
+ temp = Ps_New(capacipy * ENLARGE_FACTOR);
+ memcpy(temp, values, sizeof(T) * capacipy);
+ capacipy *= ENLARGE_FACTOR;
+ Ps_Delete(values);
+ values = temp;
+ }
+ for(; i >= location; i --)
+ {
+ values[i + 1] = values[i];
+ }
+ values[location] = value;
+ size ++;
+ return true;
+}
+
+template
+bool
+ArrayList::del(int location)
+{
+ int i;
+ if(location < 0 || location >= size)
+ {
+ return false;
+ }
+ if(location == size - 1)
+ {
+ size --;
+ return true;
+ }
+ for(i = location; i < size - 1; i ++)
+ {
+ values[i] = values[i + 1];
+ }
+ size --;
+ return true;
+}
+
+template
+int
+ArrayList::get_size() const
+{
+ return this->size;
+}
+
+template
+void ArrayList::insert_head(T value)
+{
+ (void)insert(0, value);
+}
+
+template
+void
+ArrayList::append(T value)
+{
+ insert(size, value);
+}
+
+template
+int
+ArrayList::find(T value)
+{
+ int i = 0;
+ for(; i < size; i ++)
+ {
+ if(values[i] == value)
+ return i;
+ }
+ return -1;
+}
+
+template
+void
+ArrayList::clear()
+{
+ size = 0;
+}
+
+#ifdef ARRAYLIST_DEBUG
+#include
+using namespace std;
+
+template
+void show_info(ArrayList al)
+{
+ int i = 0;
+ for(; i < al.get_size(); i ++)
+ {
+ cout << al.at(i) << " ";
+ }
+ cout << endl;
+}
+
+int main(int argc, char **argv)
+{
+ ArrayList ints;
+ ints.at(0, 12);
+ show_info(ints);
+ ints.append(34);
+ show_info(ints);
+ ints.at(0, 43);
+ show_info(ints);
+ ints.insert_head(42);
+ show_info(ints);
+ ints.append(32);
+ show_info(ints);
+ ints.del(0);
+ show_info(ints);
+ ints.del(3);
+ show_info(ints);
+ ints.del(2);
+ show_info(ints);
+ for(int i = 10; i < 25; i ++)
+ ints.append(i);
+ show_info(ints);
+ for(int i = ints.get_size(); i < 45; i ++)
+ ints.insert(i - 5, i);
+ show_info(ints);
+ cout << ints.find(42) << endl;
+ ints.clear();
+ show_info(ints);
+ cout << ints.find(42) << endl;
+}
+#endif
+
+
+
+
+#endif // ARRAYLIST_H
diff --git a/src/browser/browser.cpp b/src/browser/browser.cpp
new file mode 100644
index 0000000..a77a46b
--- /dev/null
+++ b/src/browser/browser.cpp
@@ -0,0 +1,46 @@
+#include "browser.h"
+
+Browser::Browser() :
+ QMainWindow()
+{
+ init();
+ add_widgets();
+ signal_deal();
+}
+
+Browser::~Browser()
+{
+ menu_bar->~MenuBar();
+ Ps_Delete(menu_bar);
+ tool_bar->~ToolBar();
+ Ps_Delete(tool_bar);
+}
+
+void
+Browser::clear()
+{
+ this->close();
+}
+
+void
+Browser::init()
+{
+ menu_bar = Ps_New();
+ new(menu_bar) MenuBar(0);
+ tool_bar = Ps_New();
+ new(tool_bar) ToolBar(this);
+}
+
+void
+Browser::add_widgets()
+{
+ this->setMenuBar(menu_bar);
+ this->addToolBar(tool_bar);
+}
+
+void
+Browser::signal_deal()
+{
+ connect(menu_bar, SIGNAL(exit_signal()), this, SLOT(clear()));
+
+}
diff --git a/src/browser/browser.h b/src/browser/browser.h
new file mode 100644
index 0000000..4c3e7c4
--- /dev/null
+++ b/src/browser/browser.h
@@ -0,0 +1,30 @@
+#ifndef BROWSER_H
+#define BROWSER_H
+#include
+
+#include "menubar.h"
+#include "toolbar.h"
+#include "MM.h"
+#include "../include/log.h"
+
+class Browser : public QMainWindow
+{
+ Q_OBJECT
+public:
+ Browser();
+ virtual ~Browser();
+
+private slots:
+ void clear();
+
+private:
+ void init();
+ void add_widgets();
+ void signal_deal();
+
+private:
+ MenuBar *menu_bar;
+ ToolBar *tool_bar;
+};
+
+#endif // BROWSER_H
diff --git a/src/browser/centerlinear.cpp b/src/browser/centerlinear.cpp
new file mode 100644
index 0000000..3af408e
--- /dev/null
+++ b/src/browser/centerlinear.cpp
@@ -0,0 +1,36 @@
+#include "centerlinear.h"
+
+
+
+#ifdef CENTER_LINEAR_DEBUG
+int main(int argc, char **argv)
+{
+ int i = 0;
+ bool r;
+ CenterLinear cl;
+ r = cl.is_null();
+ try{
+ cl.insert_head(0);
+ //std::cout << cl.prev() << std::endl;
+ cl.insert_tail(1);
+ std::cout << "cl prev " << cl.prev() << std::endl;
+ cl.insert_next_head(4);
+ std::cout << "cl next " << cl.next() <
+#endif
+
+template
+class CenterLinearNode
+{
+public:
+ CenterLinearNode(T value) :
+ prev(NULL), next(NULL), value(value)
+ {}
+
+ CenterLinearNode *prev, *next;
+ T value;
+};
+
+template
+class CenterLinear
+{
+public:
+ CenterLinear();
+ CenterLinear(T value);
+ CenterLinear(CenterLinear &other);
+ ~CenterLinear();
+
+ bool have_prev();
+ bool have_next();
+ bool is_null();
+
+ /**
+ * @brief Insert into the current behind
+ * and move to it.
+ * @param value
+ */
+ void insert_next_head(T value);
+
+ /**
+ * @brief Insert into the current forhead
+ * and move to it.
+ * @param value
+ */
+ void insert_prev_head(T value);
+
+ /**
+ * @brief Insert into the head
+ * and move to it.
+ * @param value
+ */
+ void insert_head(T value);
+
+ /**
+ * @brief Insert into the tail
+ * and move to it.
+ * @param value
+ */
+ void insert_tail(T value);
+
+ /*
+ * Get current value
+ * if current doesn't exit
+ * throw exception(Ps_OutOfIndexException)
+ */
+ T get_current();
+
+ /*
+ * Go to prev value and return it
+ * if next doesn't exist, will throw
+ * exception(Ps_OutOfIndexException)
+ */
+ T prev();
+
+ /*
+ * Go to next value and return it
+ * if next doesn't exist, will throw
+ * exception(Ps_OutOfIndexException)
+ */
+ T next();
+
+private:
+ CenterLinearNode *center;
+};
+
+template
+CenterLinear::CenterLinear() :
+ center(NULL)
+{
+
+}
+
+template
+CenterLinear::CenterLinear(T value)
+{
+ center = Ps_New >();
+ new(center) CenterLinearNode(value);
+}
+
+template
+CenterLinear::CenterLinear(CenterLinear &other)
+{
+ Ps_Log("It's dangerout to copy the center linear\n", Ps_LOG_WARING);
+ *this = other;
+}
+
+template
+CenterLinear::~CenterLinear()
+{
+ if(!center)
+ return;
+ CenterLinearNode *t = center->prev;
+ CenterLinearNode *v;
+ while(t)
+ {
+ v = t->prev;
+#ifdef CENTER_LINEAR_DEBUG
+ std::cout << t->value << std::endl;
+#endif
+ Ps_Free(t);
+ t = v;
+ }
+ while(center)
+ {
+ v = center->next;
+#ifdef CENTER_LINEAR_DEBUG
+ std::cout << center->value << std::endl;
+#endif
+ Ps_Free(center);
+ center = v;
+ }
+}
+
+template
+bool
+CenterLinear::have_prev()
+{
+ return (center && (center->prev));
+}
+
+template
+bool
+CenterLinear::have_next()
+{
+ return (center && (center->next));
+}
+
+template
+bool
+CenterLinear::is_null()
+{
+ return (center == NULL);
+}
+
+template
+void
+CenterLinear::insert_next_head(T value)
+{
+ CenterLinearNode *t= Ps_New >();
+ new(t) CenterLinearNode(value);
+ if(!center)
+ {
+ center = t;
+ return;
+ }
+ t->next = center->next;
+ t->prev = center;
+ if(center->next)
+ center->next->prev = t;
+ center->next = t;
+ center = t;
+}
+
+template
+void
+CenterLinear::insert_prev_head(T value)
+{
+ CenterLinearNode *t = Ps_New >();
+ new(t) CenterLinearNode(value);
+ if(!center)
+ {
+ center = t;
+ return;
+ }
+ if(center->prev)
+ center->prev->next = t;
+ t->prev = center->prev;
+ t->next = center;
+ center->prev = t;
+ center = t;
+}
+
+template
+void
+CenterLinear::insert_head(T value)
+{
+ CenterLinearNode *t = Ps_New >();
+ CenterLinearNode *v = center;
+ new(t) CenterLinearNode(value);
+ if(!center)
+ {
+ center = t;
+ return;
+ }
+ while(v->prev)
+ {
+ v = v->prev;
+ }
+ v->prev = t;
+ t->next = v;
+ center = t;
+}
+
+template
+void
+CenterLinear::insert_tail(T value)
+{
+ CenterLinearNode *t = Ps_New >();
+ CenterLinearNode *v = center;
+ new(t) CenterLinearNode(value);
+ if(!center)
+ {
+ center = t;
+ return;
+ }
+ while(v->next)
+ {
+ v = v->next;
+ }
+ v->next = t;
+ t->prev = v;
+ center = t;
+}
+
+template
+T
+CenterLinear::get_current()
+{
+ if(!center)
+ throw Ps_OutOfIndexException();
+ return center->value;
+}
+
+template
+T
+CenterLinear::prev()
+{
+ if(!center || !center->prev)
+ throw Ps_OutOfIndexException();
+ center = center->prev;
+ return center->value;
+}
+
+template
+T
+CenterLinear::next()
+{
+ if(!center || !center->next)
+ throw Ps_OutOfIndexException();
+ center = center->next;
+ return center->value;
+}
+
+#endif // CENTERLINEAR_H
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/browser/filemenu.cpp b/src/browser/filemenu.cpp
new file mode 100644
index 0000000..1dde513
--- /dev/null
+++ b/src/browser/filemenu.cpp
@@ -0,0 +1,129 @@
+#include "filemenu.h"
+
+FileMenu::FileMenu(QWidget *parent) :
+ QMenu(parent)
+{
+ init_items();
+ add_action();
+ patch_signal();
+}
+
+FileMenu::~FileMenu()
+{
+ new_tab_item->~QAction();
+ Ps_Delete(new_tab_item);
+ open_location_item->~QAction();
+ Ps_Delete(open_location_item);
+ open_file_item->~QAction();
+ Ps_Delete(open_file_item);
+ exit_item->~QAction();
+ Ps_Delete(exit_item);
+}
+
+void
+FileMenu::init_items()
+{
+ /**INIT new tab item***/
+ new_tab_item = Ps_New();
+ new(new_tab_item) QAction(NULL);
+ //new_tab_item = new QAction();
+ new_tab_item->setText(QString(tr(CREATE_NEW_TAB)));
+ new_tab_item->setShortcut(QKeySequence(tr(CREATE_NEW_TAB_SHORT)));
+ /*Init open location item*/
+ open_location_item = Ps_New();
+ new(open_location_item) QAction(NULL);
+ //open_location_item = new QAction(NULL);
+ open_location_item->setText(QString(tr(OPEN_LOCATION)));
+ open_location_item->setShortcut(QKeySequence(tr(OPEN_LOCATION_SHORT)));
+ /*Init open file item*/
+ open_file_item = Ps_New();
+ new(open_file_item) QAction(NULL);
+ //open_file_item = new QAction(NULL);
+ open_file_item->setText(QString(tr(OPEN_FILE)));
+ open_file_item->setShortcut(tr(OPEN_FILE_SHORT));
+ /*Init exit item*/
+ exit_item = Ps_New();
+ new(exit_item) QAction(NULL);
+ //exit_item = new QAction(NULL);
+ exit_item->setText(QString(tr(EXIT)));
+ exit_item->setShortcut(tr(EXIT_SHORT));
+}
+
+void
+FileMenu::patch_signal()
+{
+ connect(new_tab_item, SIGNAL(triggered()), this, SIGNAL(create_new_tab_signal()));
+ connect(exit_item, SIGNAL(triggered()), this, SIGNAL(exit_signal()));
+ connect(open_file_item, SIGNAL(triggered()), this, SLOT(open_file_slot()));
+}
+
+void
+FileMenu::add_action()
+{
+ this->addAction(new_tab_item);
+ this->addAction(open_location_item);
+ this->addAction(open_file_item);
+ this->addAction(exit_item);
+}
+
+void
+FileMenu::open_file_slot()
+{
+ FileChooser chooser;
+ QString filename;
+ int pos;
+ if(last_open_dir.length() != 0)
+ chooser.set_dir(last_open_dir);
+ filename = chooser.get_path();
+ if(filename.length() != 0)
+ {
+#if (PLATFORM & WIN32) || (PLATFORM & WIN64)
+ pos = filename.lastIndexOf("\\");
+#elif (PLATFORM & LINUX32) || (PLATFORM & LINUX64)
+ pos = filename.lastIndexOf("/");
+#endif
+ emit open_file_signal(filename);
+
+ }
+
+}
+
+
+FileChooser::FileChooser(QWidget *parent, QString *dir)
+ : QFileDialog(parent)
+{
+ this->setWindowTitle(tr(OPEN_FILE));
+ if(dir)
+ {
+ this->setDirectory(*dir);
+ }
+ //this->setFilter(tr("(*)"));
+
+}
+
+QString&
+FileChooser::get_path()
+{
+ if(exec() == QDialog::Accepted)
+ {
+ path = this->selectedFiles()[0];
+ }
+ else
+ path = QString();
+ return path;
+}
+
+void
+FileChooser::set_dir(const QString &dir)
+{
+ this->setDirectory(dir);
+}
+
+
+
+
+
+
+
+
+
diff --git a/src/browser/filemenu.h b/src/browser/filemenu.h
new file mode 100644
index 0000000..5022301
--- /dev/null
+++ b/src/browser/filemenu.h
@@ -0,0 +1,68 @@
+/**
+ * File Menu
+ * SHIT QT5,Why cannot input Chinese....
+ **/
+#ifndef FILEMENU_H
+#define FILEMENU_H
+
+#include
+#include
+#include
+#include
+#include "MM.h"
+#include "../include/config.h"
+
+
+#define CREATE_NEW_TAB "New Tab"
+#define OPEN_LOCATION "Open Location"
+#define OPEN_FILE "Open File"
+#define EXIT "Exit"
+
+#define CREATE_NEW_TAB_SHORT "Ctrl+N"
+#define OPEN_LOCATION_SHORT "Ctrl+L"
+#define OPEN_FILE_SHORT "Ctrl+O"
+#define EXIT_SHORT "Ctrl+Q"
+
+class FileChooser : public QFileDialog
+{
+ Q_OBJECT
+public:
+ FileChooser(QWidget *parent = 0, QString *dir = 0);
+ void set_dir(const QString &dir);
+ QString& get_path();
+private:
+ QString path;
+};
+
+class FileMenu : public QMenu
+{
+ Q_OBJECT
+public:
+ explicit FileMenu(QWidget *parent = 0);
+ virtual ~FileMenu();
+signals:
+ void open_location_signal(QString &location);
+ void open_file_signal(QString &filename);
+ void create_new_tab_signal();
+ void exit_signal();
+
+public slots:
+
+
+private slots:
+ void open_file_slot();
+
+private:
+ void init_items();
+ void patch_signal();
+ void add_action();
+
+private:
+ QAction *new_tab_item;
+ QAction *open_location_item;
+ QAction *open_file_item;
+ QAction *exit_item;
+ QString last_open_dir;
+};
+
+#endif // FILEMENU_H
diff --git a/src/browser/main.cpp b/src/browser/main.cpp
new file mode 100644
index 0000000..ccd2636
--- /dev/null
+++ b/src/browser/main.cpp
@@ -0,0 +1,38 @@
+#include
+#include
+#include "../include/init_clear.h"
+#include "browser.h"
+#include "toolbar.h"
+
+/*日志文件名*/
+#define LOG_FILE "log.txt"
+
+int
+main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ int ret;
+ Browser browser;
+ SearchBox box;
+ //日志文件
+ FILE *file;
+ file = fopen(LOG_FILE, "w");
+ //系统初始化
+ if(!file)
+ {
+ printf("Open %s as log file failed\n", LOG_FILE);
+ Ps_INIT(NULL, NULL, NULL);
+ }
+ else
+ Ps_INIT(file, file, file);
+
+ /*Run browser*/
+ browser.show();
+ //box.show();
+
+ ret = app.exec();
+ //系统清理
+ Ps_Log((char*)"Clear system to exit\n", Ps_LOG_NORMAL);
+ Ps_CLEAR();
+ return ret;
+}
diff --git a/src/browser/menubar.cpp b/src/browser/menubar.cpp
new file mode 100644
index 0000000..aa54482
--- /dev/null
+++ b/src/browser/menubar.cpp
@@ -0,0 +1,58 @@
+#include "menubar.h"
+
+MenuBar::MenuBar(QWidget *parent) :
+ QMenuBar(parent)
+{
+ init();
+ set_signal();
+ add_menu();
+}
+
+MenuBar::~MenuBar()
+{
+ file_menu->~FileMenu();
+ Ps_Delete(file_menu);
+}
+
+void
+MenuBar::init()
+{
+ /*Init file menu*/
+ file_menu = Ps_New();
+ new(file_menu) FileMenu(0);
+ file_menu->setTitle(QString(tr(FILE_NAME)));
+}
+
+
+void
+MenuBar::set_signal()
+{
+ /*Pass The signal from file menu*/
+ connect(file_menu, SIGNAL(open_location_signal(QString&)), this, SIGNAL(open_location_signal(QString&)));
+ connect(file_menu, SIGNAL(open_file_signal(QString&)), this, SIGNAL(open_file_signal(QString&)));
+ connect(file_menu, SIGNAL(create_new_tab_signal()), this, SIGNAL(create_new_tab_signal()));
+ connect(file_menu, SIGNAL(exit_signal()), this, SIGNAL(exit_signal()));
+#ifdef MENUBAR_DEBUG
+ connect(this, SIGNAL(exit_signal()), this, SLOT(exit_slot()));
+#endif
+}
+
+void
+MenuBar::add_menu()
+{
+ this->addMenu(file_menu);
+}
+
+#ifdef MENUBAR_DEBUG
+#include
+using namespace std;
+void
+MenuBar::exit_slot()
+{
+ cout << "Exit signal send" << endl;
+ Ps_Log((char*)"Exit signal send\n", Ps_LOG_WARING);
+}
+
+#endif
+
+
diff --git a/src/browser/menubar.h b/src/browser/menubar.h
new file mode 100644
index 0000000..5b7a757
--- /dev/null
+++ b/src/browser/menubar.h
@@ -0,0 +1,44 @@
+#ifndef MENUBAR_H
+#define MENUBAR_H
+
+#include
+#include
+
+#include "filemenu.h"
+#include "MM.h"
+#include "../include/log.h"
+
+#define FILE_NAME "File"
+
+#define MENUBAR_DEBUG
+
+class MenuBar : public QMenuBar
+{
+ Q_OBJECT
+public:
+ explicit MenuBar(QWidget *parent = 0);
+ virtual ~MenuBar();
+
+signals:
+ void open_location_signal(QString &location);
+ void open_file_signal(QString &filename);
+ void create_new_tab_signal();
+ void exit_signal();
+
+public slots:
+
+private slots:
+#ifdef MENUBAR_DEBUG
+ void exit_slot();
+#endif
+
+private:
+ void init();
+ void set_signal();
+ void add_menu();
+
+private:
+ FileMenu *file_menu;
+};
+
+#endif // MENUBAR_H
diff --git a/src/browser/pythonparser.cpp b/src/browser/pythonparser.cpp
new file mode 100644
index 0000000..c5f6b3f
--- /dev/null
+++ b/src/browser/pythonparser.cpp
@@ -0,0 +1,6 @@
+#include "pythonparser.h"
+
+PythonParser::PythonParser(QObject *parent) :
+ QThread(parent)
+{
+}
diff --git a/src/browser/pythonparser.h b/src/browser/pythonparser.h
new file mode 100644
index 0000000..8707aa5
--- /dev/null
+++ b/src/browser/pythonparser.h
@@ -0,0 +1,19 @@
+#ifndef PYTHONPARSER_H
+#define PYTHONPARSER_H
+
+#include
+#include
+
+class PythonParser : public QThread
+{
+ Q_OBJECT
+public:
+ explicit PythonParser(QObject *parent = 0);
+
+signals:
+
+public slots:
+
+};
+
+#endif // PYTHONPARSER_H
diff --git a/src/browser/tab.cpp b/src/browser/tab.cpp
new file mode 100644
index 0000000..2bf65f7
--- /dev/null
+++ b/src/browser/tab.cpp
@@ -0,0 +1,6 @@
+#include "tab.h"
+
+Tab::Tab(QWidget *parent) :
+ QWidget(parent)
+{
+}
diff --git a/src/browser/tab.h b/src/browser/tab.h
new file mode 100644
index 0000000..26ae590
--- /dev/null
+++ b/src/browser/tab.h
@@ -0,0 +1,20 @@
+#ifndef TAB_H
+#define TAB_H
+
+#include
+#include
+#include
+
+class Tab : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit Tab(QWidget *parent = 0);
+
+signals:
+
+public slots:
+
+};
+
+#endif // TAB_H
diff --git a/src/browser/tabs.cpp b/src/browser/tabs.cpp
new file mode 100644
index 0000000..ede76d7
--- /dev/null
+++ b/src/browser/tabs.cpp
@@ -0,0 +1,6 @@
+#include "tabs.h"
+
+Tabs::Tabs(QObject *parent) :
+ QTabWidget(parent)
+{
+}
diff --git a/src/browser/tabs.h b/src/browser/tabs.h
new file mode 100644
index 0000000..a2c938a
--- /dev/null
+++ b/src/browser/tabs.h
@@ -0,0 +1,31 @@
+#ifndef TAB_H
+#define TAB_H
+
+#include
+#include
+#include
+#include
+
+#include "webpage.h"
+
+struct Web_Info
+{
+ WebPage *page;
+ QWebView *view;
+};
+
+class Tab : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit Tab(QWidget *parent = 0);
+
+signals:
+
+public slots:
+
+private:
+
+};
+
+#endif // TAB_H
diff --git a/src/browser/test/__cl__ b/src/browser/test/__cl__
new file mode 100755
index 0000000..eb84df3
Binary files /dev/null and b/src/browser/test/__cl__ differ
diff --git a/src/browser/test/auto_cl.sh b/src/browser/test/auto_cl.sh
new file mode 100755
index 0000000..74ad5e7
--- /dev/null
+++ b/src/browser/test/auto_cl.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+g++ -o __cl__ ../centerlinear.cpp ../../lib/exception.cpp ../MM.cpp ../../lib/mm.c
+./__cl__
diff --git a/src/browser/toolbar.cpp b/src/browser/toolbar.cpp
new file mode 100644
index 0000000..bc048f8
--- /dev/null
+++ b/src/browser/toolbar.cpp
@@ -0,0 +1,391 @@
+#include "toolbar.h"
+#include
+
+/********************LabelItem************************/
+LabelItem::LabelItem()
+{
+}
+
+LabelItem::LabelItem(const QString &name, const QString &url)
+{
+ title_item.setText(name);
+ this->url = url;
+}
+
+LabelItem::LabelItem(const QString &name, const QString &url, const QIcon &icon)
+{
+ title_item.setText(name);
+ title_item.setIcon(icon);
+ this->url = url;
+}
+
+/*********************LabelsList**********************/
+LabelsList::LabelsList(QWidget *parent) :
+ QListWidget(parent)
+{
+ this->setWindowFlags(Qt::FramelessWindowHint);
+ this->setStyleSheet("background-color:black");
+ this->setStyleSheet("color:white");
+ this->setFocusPolicy(Qt::ClickFocus);
+ connect(this, SIGNAL(currentRowChanged(int)), this, SLOT(current_row__changed_slot(int)));
+ connect(this, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(item_clicked_slot(QListWidgetItem*)));
+
+}
+
+void
+LabelsList::show_pos(int x, int y)
+{
+ this->move(x, y);
+ this->setCurrentRow(0);
+ this->show();
+}
+
+void
+LabelsList::current_row__changed_slot(int currentRow)
+{
+ current_row = currentRow;
+}
+
+void
+LabelsList::item_clicked_slot(QListWidgetItem *item)
+{
+ emit row_clicked_signal(current_row);
+ this->setVisible(false);
+}
+
+void
+LabelsList::focusOutEvent(QFocusEvent *event)
+{
+ this->setVisible(false);
+}
+
+/********************Labels***************************/
+Labels::Labels(QWidget *parent) :
+ QPushButton(parent)
+{
+ this->setIcon(QIcon(QPixmap(LABEL_PATH)));
+ labels_list = Ps_New();
+ new(labels_list) LabelsList(parent);
+ connect(this, SIGNAL(clicked()), this, SLOT(show_list()));
+ connect(labels_list, SIGNAL(row_clicked_signal(int)), this, SLOT(item_clicked_slot(int)));
+
+}
+
+Labels::~Labels()
+{
+
+}
+
+void
+Labels::item_clicked_slot(int index)
+{
+ LabelItem item;
+ if(items.at(index, &item))
+ {
+ emit open_signal(item.url, SearchBox::WEB);
+ }
+}
+
+void
+Labels::add_item(const QString &name, const QString &url)
+{
+ LabelItem item(name, url);
+ add_item(item);
+}
+
+void
+Labels::add_item(const QString &name, const QString &url, const QIcon &icon)
+{
+ LabelItem item(name, url, icon);
+ add_item(item);
+}
+
+void
+Labels::add_item(LabelItem &item)
+{
+ items.append(item);
+ labels_list->addItem(&item.title_item);
+}
+
+void
+Labels::show_list()
+{
+ QRect rect = this->geometry();
+ int x = rect.x() + rect.width() / 2;
+ int y = rect.y() + rect.height();
+ std::cout << x << " " << rect.x() << " " << rect.width() << std::endl;
+ std::cout << y << " " << rect.y() << " " << rect.height() << std::endl;
+ labels_list->show_pos(x, y);
+
+}
+
+/********************IconButton***********************/
+IconButton::IconButton(QWidget *parent)
+ : QLabel(parent),
+ single_click(false)
+{
+}
+
+IconButton::IconButton(QPixmap &map, QWidget *parent) :
+ QLabel(parent)
+{
+ this->setPixmap(map);
+}
+
+void
+IconButton::mouseReleaseEvent(QMouseEvent *ev)
+{
+ ev = ev;
+ if(single_click)
+ {
+ single_click = false;
+ emit clicked();
+ }
+}
+
+void
+IconButton::mousePressEvent(QMouseEvent *ev)
+{
+ ev = ev;
+ single_click = true;
+}
+
+/*****************SearchBox*************************/
+SearchBox::SearchBox(QWidget *parent) :
+ QWidget(parent),
+ collected(false),
+ collected_icon(COLLECTED_PATH),
+ uncollected_icon(UNCOLLECTED_PATH),
+ page_map(PAGE_PATH)
+{
+ init();
+ patch_signal();
+ add_widget();
+}
+
+SearchBox::~SearchBox()
+{
+ icon_label->~QLabel();
+ Ps_Delete(icon_label);
+ search_line->~QLineEdit();
+ Ps_Delete(search_line);
+ //star_label->~QLabel();
+ //Ps_Delete(star_label);
+ star_button->~IconButton();
+ Ps_Delete(star_button);
+ main_layout->~QHBoxLayout();
+ Ps_Delete(main_layout);
+ star_layout->~QHBoxLayout();
+ Ps_Delete(star_layout);
+}
+
+void
+SearchBox::init()
+{
+ /*Init icon label*/
+ icon_label = Ps_New();
+ new(icon_label) QLabel();
+ icon_label->setPixmap(QPixmap(PAGE_PATH));
+ icon_label->setMaximumHeight(32);
+ /*Init search Line*/
+ search_line = Ps_New();
+ new(search_line) QLineEdit();
+ /*Init star button*/
+ star_button = Ps_New();
+ new(star_button) IconButton();
+ star_button->setPixmap(QPixmap(UNCOLLECTED_PATH));
+ //star_button->setBackgroundRole(QPalette::NoRole);
+ //star_button->setFlat(true);
+ /*Init star layout*/
+ star_layout = Ps_New();
+ new(star_layout) QHBoxLayout();
+ star_layout->addWidget(star_button);
+ /*Init star label*/
+ //star_label = Ps_New();
+ // new(star_label) QLabel();
+ //star_label->setLayout(star_layout);
+ /*Init main layout*/
+ main_layout = Ps_New();
+ new(main_layout) QHBoxLayout();
+}
+
+void
+SearchBox::add_widget()
+{
+ main_layout->addWidget(icon_label);
+ main_layout->addWidget(search_line);
+ main_layout->addLayout(star_layout);
+ this->setLayout(main_layout);
+}
+
+void
+SearchBox::set_icon(QPixmap &icon)
+{
+ icon_label->setPixmap(icon);
+}
+
+void
+SearchBox::set_collected(bool b)
+{
+ collected = b;
+ if(b)
+ star_button->setPixmap(collected_icon);
+ else
+ star_button->setPixmap(uncollected_icon);
+}
+
+void
+SearchBox::set_url(QString &url)
+{
+ search_line->setText(url);
+}
+
+void
+SearchBox::collect_slot()
+{
+ if(!collected)
+ {
+ collected = true;
+ set_collected(true);
+ star_button->setPixmap(collected_icon);
+ emit collect_signal();
+ }
+}
+
+void
+SearchBox::open_slot()
+{
+ QString url = search_line->text();
+ if(url.length() > 0)
+ {
+ emit open_signal(url, WEB);
+ }
+}
+
+void
+SearchBox::patch_signal()
+{
+ connect(star_button, SIGNAL(clicked()), this, SLOT(collect_slot()));
+ connect(search_line, SIGNAL(editingFinished()), this, SLOT(open_slot()));
+}
+
+ToolBar::ToolBar(QWidget *parent) :
+ QToolBar(parent), parent(parent)
+{
+ init();
+}
+
+/*********************ToolBar***************************/
+void
+ToolBar::init()
+{
+ /*Init back_button*/
+ back_button = Ps_New();
+ new(back_button) QPushButton();
+ back_button->setIcon(QIcon(QPixmap(BACKWARD_PATH)));
+ back_button->setFlat(true);
+ /*Init forward button*/
+ forward_button = Ps_New();
+ new(forward_button) QPushButton();
+ forward_button->setIcon(QIcon(QPixmap(FORWARD_PATH)));
+ forward_button->setFlat(true);
+ /*Init refresh button*/
+ refresh_button = Ps_New();
+ new(refresh_button) QPushButton();
+ refresh_button->setIcon(QIcon(QPixmap(REFRESH_PATH)));
+ refresh_button->setFlat(true);
+ /*Init search box*/
+ search_box = Ps_New();
+ new(search_box) SearchBox();
+ //search_box->setStyleSheet("border: 2px solid black");
+ //search_box->setStyleSheet("border-style:outset");
+ /*Init main layout*/
+ //main_layout = Ps_New();
+ //new(main_layout) QHBoxLayout();
+ /*Init label button*/
+ label_button = Ps_New();
+ new(label_button) Labels(0);
+ label_button->setIcon(QIcon(QPixmap(LABEL_PATH)));
+ label_button->setFlat(true);
+
+ this->addWidget(back_button);
+ this->addWidget(forward_button);
+ this->addWidget(refresh_button);
+ this->addSeparator();
+ this->addWidget(search_box);
+ this->addSeparator();
+ this->addWidget(label_button);
+
+ this->setMovable(false);
+ //this->setLayout(main_layout);
+
+}
+
+void
+ToolBar::set_icon_slot(QPixmap &icon)
+{
+ search_box->set_icon(icon);
+}
+
+void
+ToolBar::set_collected_slot(bool b)
+{
+ search_box->set_collected(b);
+}
+
+void
+ToolBar::set_back_enable_slot(bool b)
+{
+ back_button->setEnabled(b);
+}
+
+void
+ToolBar::set_forward_enable_slot(bool b)
+{
+ forward_button->setEnabled(b);
+}
+
+void
+ToolBar::set_url(QString &url)
+{
+ search_box->set_url(url);
+}
+
+void
+ToolBar::add_item_slot(QString &name, QString &url)
+{
+ label_button->add_item(name, url);
+}
+
+void
+ToolBar::add_item_slot(QString &name, QString &url, QIcon &icon)
+{
+ label_button->add_item(name, url, icon);
+}
+
+void
+ToolBar::patch_signal()
+{
+ connect(search_box, SIGNAL(open_signal(QString&,OpenType)), this, SIGNAL(open_signal(QString&,SearchBox::OpenType)));
+ connect(search_box, SIGNAL(collect_signal()), this, SIGNAL(collect_signal()));
+ connect(back_button, SIGNAL(clicked()), this, SIGNAL(back_signal()));
+ connect(forward_button, SIGNAL(clicked()), this, SIGNAL(forward_signal()));
+ connect(refresh_button, SIGNAL(clicked()), this, SIGNAL(refresh_signal()));
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/browser/toolbar.h b/src/browser/toolbar.h
new file mode 100644
index 0000000..29b632a
--- /dev/null
+++ b/src/browser/toolbar.h
@@ -0,0 +1,192 @@
+#ifndef TOOLBAR_H
+#define TOOLBAR_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "MM.h"
+#include "arraylist.h"
+
+#define COLLECTED_PATH "../icons/collected.png"
+#define UNCOLLECTED_PATH "../icons/uncollected.png"
+#define BACKWARD_PATH "../icons/backward32.png"
+#define FORWARD_PATH "../icons/forward32.png"
+#define PAGE_PATH "../icons/page.png"
+#define REFRESH_PATH "../icons/refresh.png"
+#define LABEL_PATH "../icons/label.png"
+
+#define TOOLBAR_DEBUG
+
+class IconButton : public QLabel
+{
+ Q_OBJECT
+public:
+ IconButton(QWidget *parent = 0);
+ IconButton(QPixmap &map, QWidget *parent = 0);
+
+protected:
+ virtual void mouseReleaseEvent(QMouseEvent *ev);
+ virtual void mousePressEvent(QMouseEvent *ev);
+
+signals:
+ void clicked();
+
+public slots:
+
+private:
+ bool single_click;
+};
+
+class SearchBox : public QWidget
+{
+ Q_OBJECT
+public:
+ SearchBox(QWidget *parent = 0);
+ virtual ~SearchBox();
+
+public slots:
+ void set_icon(QPixmap &icon);
+ void set_collected(bool b);
+ void set_url(QString &url);
+
+public:
+ /**/
+ enum OpenType {WEB, DOWNLOAD, SRC, INTERNAL};
+
+signals:
+ void open_signal(QString &url, enum OpenType type);
+ void collect_signal();
+
+private:
+ void init();
+ void patch_signal();
+
+private slots:
+ void collect_slot();
+ void open_slot();
+ void add_widget();
+
+private:
+ QLabel *icon_label;
+ QLineEdit *search_line;
+ //QLabel *star_label;
+ IconButton *star_button;
+ QHBoxLayout *main_layout;
+ QHBoxLayout *star_layout;
+ const QPixmap page_map;
+ const QPixmap collected_icon;
+ const QPixmap uncollected_icon;
+ bool collected;
+};
+
+class LabelItem
+{
+public:
+ LabelItem();
+ LabelItem(const QString &name, const QString &url);
+ LabelItem(const QString &name, const QString &url, const QIcon &icon);
+
+public:
+ QListWidgetItem title_item;
+ QString url;
+};
+
+class LabelsList : public QListWidget
+{
+ Q_OBJECT
+public:
+ LabelsList(QWidget *parent = 0);
+ void show_pos(int x, int y);
+
+signals:
+ void row_clicked_signal(int row);
+
+protected:
+ virtual void focusOutEvent(QFocusEvent *event);
+
+private slots:
+ void current_row__changed_slot(int currentRow);
+ void item_clicked_slot(QListWidgetItem *item);
+
+private:
+ int current_row;
+
+};
+
+class Labels : public QPushButton
+{
+ Q_OBJECT
+public:
+ Labels(QWidget *parent = 0);
+ virtual ~Labels();
+
+public slots:
+ void add_item(const QString &name, const QString &url);
+ void add_item(const QString &name, const QString &url, const QIcon &icon);
+ void add_item(LabelItem &item);
+ void show_list();
+
+signals:
+ void open_signal(QString &url, SearchBox::OpenType type);
+
+private slots:
+ void item_clicked_slot(int index);
+
+private:
+
+
+private:
+ ArrayList items;
+ LabelsList *labels_list;
+};
+
+
+
+
+
+class ToolBar : public QToolBar
+{
+ Q_OBJECT
+public:
+ ToolBar(QWidget *parent = 0);
+
+signals:
+ void open_signal(QString &url, enum SearchBox::OpenType type);
+ void collect_signal();
+ void back_signal();
+ void forward_signal();
+ void refresh_signal();
+
+public slots:
+ void set_icon_slot(QPixmap &icon);
+ void set_collected_slot(bool b);
+ void set_back_enable_slot(bool b);
+ void set_forward_enable_slot(bool b);
+ void add_item_slot(QString &name, QString &url);
+ void add_item_slot(QString &name, QString &url, QIcon &icon);
+ void set_url(QString &url);
+
+private:
+ void init();
+ void patch_signal();
+private:
+ QPushButton *back_button;
+ QPushButton *forward_button;
+ QPushButton *refresh_button;
+ SearchBox *search_box;
+ Labels *label_button;
+ QWidget *parent;
+ //QHBoxLayout *main_layout;
+};
+
+#endif // TOOLBAR_H
diff --git a/src/browser/webpage.cpp b/src/browser/webpage.cpp
new file mode 100644
index 0000000..c6daace
--- /dev/null
+++ b/src/browser/webpage.cpp
@@ -0,0 +1,74 @@
+#include "webpage.h"
+
+#include
+#include
+
+WebPage::WebPage(QObject *parent) :
+ QWebPage(parent)
+{
+ init();
+
+}
+
+WebPage::~WebPage()
+{
+ parser->~PythonParser();
+ Ps_Delete(parser);
+}
+
+void
+WebPage::init()
+{
+ parser = Ps_New();
+ new(parser) PythonParser(this);
+
+ /*signal---slot*/
+ connect(this->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(page_url_changed_slot(QUrl)));
+
+ /**/
+ this->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+}
+
+/*Struggle to get the main python path*/
+QString
+WebPage::get_python_url()
+{
+ QUrl ret;
+ /**/
+ QWebElement element = mainFrame()->findFirstElement("script[type='Ps'][__name__='__main__']");
+ if(element.isNull())
+ {
+ element = mainFrame()->findFirstElement("script[type='PythonScript'][__name__='__main__']");
+ if(element.isNull())
+ {
+ element = mainFrame()->findFirstElement("script[type='Ps']");
+ if(element.isNull())
+ {
+ element = mainFrame()->findFirstElement("script[type='PythonScript']");
+ if(element.isNull())
+ return QString();
+ }
+ }
+ }
+ /**/
+ QString relative = element.attribute("src");
+ if(!relative.isNull())
+ {
+ ret = page_url.resolved(QUrl(relative));
+ return ret.toString();
+ }
+ return QString();
+}
+
+void
+WebPage::page_url_changed_slot(QUrl url)
+{
+ this->page_url = url;
+}
+
+
+
+
+
+
+
diff --git a/src/browser/webpage.h b/src/browser/webpage.h
new file mode 100644
index 0000000..d51533e
--- /dev/null
+++ b/src/browser/webpage.h
@@ -0,0 +1,40 @@
+#ifndef WEBPAGE_H
+#define WEBPAGE_H
+
+#include
+#include
+#include
+
+#include "MM.h"
+#include "pythonparser.h"
+
+class WebPage : public QWebPage
+{
+ Q_OBJECT
+public:
+ enum LINK_OPEN_METHOD{};
+
+ WebPage(QObject *parent = 0);
+
+ virtual ~WebPage();
+
+ QString get_python_url();
+
+
+
+signals:
+
+public slots:
+
+private slots:
+ void page_url_changed_slot(QUrl url);
+
+private:
+ void init();
+
+private:
+ PythonParser *parser;
+ QUrl page_url;
+};
+
+#endif // WEBPAGE_H
diff --git a/src/include/exception.h b/src/include/exception.h
new file mode 100644
index 0000000..bd3dd11
--- /dev/null
+++ b/src/include/exception.h
@@ -0,0 +1,50 @@
+#ifndef EXCEPTION_H
+#define EXCEPTION_H
+
+#define Ps_COMMON_EXCEPTION_NAME "Ps Common exception"
+#define Ps_NOMEMERY_EXCEPTION_NAME "Ps detected no enough memory"
+#define Ps_POINTER_EXCEPION_NAME "Ps detected using error pointer"
+#define Ps_OUTOFINDEX_EXCEPTION_NAME "Ps detected out of index"
+
+class Ps_Exception
+{
+public:
+ Ps_Exception();
+ Ps_Exception(void *value);
+ virtual ~Ps_Exception();
+ virtual const char* what() const throw();
+ virtual void* get_value();
+private:
+ void *value;
+};
+
+class Ps_NoMemeryException : public Ps_Exception
+{
+public:
+ Ps_NoMemeryException();
+ Ps_NoMemeryException(void *value);
+ ~Ps_NoMemeryException();
+ virtual const char* what() const throw();
+};
+
+class Ps_PointerException : public Ps_Exception
+{
+public:
+ Ps_PointerException();
+ Ps_PointerException(void *value);
+ virtual ~Ps_PointerException();
+ virtual const char* what() const throw();
+};
+
+class Ps_OutOfIndexException : public Ps_Exception
+{
+public:
+ Ps_OutOfIndexException();
+ Ps_OutOfIndexException(void *value);
+ virtual ~Ps_OutOfIndexException();
+ virtual const char* what() const throw();
+};
+
+//#define EXCEPION_DEBUG
+
+#endif // EXCEPTION_H
diff --git a/src/include/init_clear.h b/src/include/init_clear.h
index a8f8f96..f45fa8d 100644
--- a/src/include/init_clear.h
+++ b/src/include/init_clear.h
@@ -4,7 +4,7 @@
#ifndef _INIT_CLEAR_H
#define _INIT_CLEAR_H
-#ifdef _cplusplus
+#ifdef __cplusplus
extern "C"
{
#endif
@@ -23,8 +23,8 @@ extern "C"
Ps_MMClear()
-#ifdef _cplusplus
+#ifdef __cplusplus
}
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/src/include/log.h b/src/include/log.h
index 56b4227..e0817d3 100644
--- a/src/include/log.h
+++ b/src/include/log.h
@@ -4,7 +4,7 @@
#ifndef LOG_H
#define LOG_H
-#ifdef _cplusplus
+#ifdef __cplusplus
extern "C"
{
#endif
@@ -92,7 +92,7 @@ BOOL Ps_CloseLog();
//#define LOG_DEBUG
-#ifdef _cplusplus
+#ifdef __cplusplus
}
#endif
diff --git a/src/include/mm.h b/src/include/mm.h
index 30576f0..1d70399 100644
--- a/src/include/mm.h
+++ b/src/include/mm.h
@@ -1,6 +1,6 @@
#include "../include/size.h"
-#ifdef _cplusplus
+#ifdef __cplusplus
extern "C"
{
#endif
@@ -27,6 +27,6 @@ extern "C"
BOOL Ps_MMClear();
//#define MM_DEBUG
-#ifdef _cplusplus
+#ifdef __cplusplus
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/include/web.h b/src/include/web.h
index 4bc7f9a..1d44666 100644
--- a/src/include/web.h
+++ b/src/include/web.h
@@ -4,7 +4,7 @@
#ifndef _WEB_H
#define _WEB_H
-#ifdef _cplusplus
+#ifdef __cplusplus
extern "C"
{
#endif
@@ -39,10 +39,10 @@ BOOL Ps_DownloadTimeout(char *url, FILE *p, int timeout);
**/
BOOL Ps_WebClear();
-#define WEB_DEBUG
+//#define WEB_DEBUG
-#ifdef _cplusplus
+#ifdef __cplusplus
}
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/src/lib/__exception__ b/src/lib/__exception__
new file mode 100755
index 0000000..dc55156
Binary files /dev/null and b/src/lib/__exception__ differ
diff --git a/src/lib/exception.cpp b/src/lib/exception.cpp
new file mode 100644
index 0000000..b519377
--- /dev/null
+++ b/src/lib/exception.cpp
@@ -0,0 +1,208 @@
+/**
+ * Ps's exception system
+ * test: g++ -o __exception__ exception.cpp
+ **/
+#include "../include/exception.h"
+
+/*******Ps_Exception*************/
+Ps_Exception::Ps_Exception()
+{
+ value = (void*)0;
+}
+
+Ps_Exception::Ps_Exception(void *value)
+{
+ this->value = value;
+}
+
+Ps_Exception::~Ps_Exception()
+{
+
+}
+
+const char*
+Ps_Exception::what() const throw()
+{
+ return Ps_COMMON_EXCEPTION_NAME;
+}
+
+void*
+Ps_Exception::get_value()
+{
+ return value;
+}
+
+/********Ps_NoMemeryException*********/
+Ps_NoMemeryException::Ps_NoMemeryException() :
+ Ps_Exception()
+{
+
+}
+
+Ps_NoMemeryException::Ps_NoMemeryException(void *value) :
+ Ps_Exception(value)
+{
+
+}
+
+Ps_NoMemeryException::~Ps_NoMemeryException()
+{
+
+}
+
+const char*
+Ps_NoMemeryException::what() const throw()
+{
+ return Ps_NOMEMERY_EXCEPTION_NAME;
+}
+
+/********Ps_PointerException************/
+Ps_PointerException::Ps_PointerException() :
+ Ps_Exception()
+{
+
+}
+
+Ps_PointerException::Ps_PointerException(void *value) :
+ Ps_Exception(value)
+{
+
+}
+
+Ps_PointerException::~Ps_PointerException()
+{
+
+}
+
+const char*
+Ps_PointerException::what() const throw()
+{
+ return Ps_POINTER_EXCEPION_NAME;
+}
+/***********Ps_OutOfIndexException****/
+Ps_OutOfIndexException::Ps_OutOfIndexException() :
+ Ps_Exception()
+{
+
+}
+
+Ps_OutOfIndexException::Ps_OutOfIndexException(void *value) :
+ Ps_Exception(value)
+{
+
+}
+
+Ps_OutOfIndexException::~Ps_OutOfIndexException()
+{
+
+}
+
+const char*
+Ps_OutOfIndexException::what() const throw()
+{
+ return Ps_OUTOFINDEX_EXCEPTION_NAME;
+}
+
+/*************************************
+***********TEST*********************
+***********************************/
+#ifdef EXCEPION_DEBUG
+#include
+char *info = (char*)"Hello I am exception";
+
+void test_exception1()
+{
+ throw Ps_Exception();
+}
+
+void test_exception2()
+{
+ throw Ps_Exception((void*)info);
+}
+
+void test_nomem_exception()
+{
+ throw Ps_NoMemeryException();
+}
+
+void test_pointer_exception()
+{
+ throw Ps_PointerException();
+}
+
+void test_outofindex_exception()
+{
+ throw Ps_OutOfIndexException();
+}
+
+int main(int argc, char **argv)
+{
+ /******NO 1:test Ps_Exception*****/
+ try
+ {
+ test_exception1();
+ }
+ catch(Ps_Exception &e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+ /******NO 2:test Ps_Exception*****/
+ try
+ {
+ test_exception2();
+ }
+ catch(Ps_Exception &e)
+ {
+ std::cout <<(char*)e.get_value() << std::endl;
+ }
+ /*******************************/
+ try
+ {
+ test_nomem_exception();
+ }
+ catch(Ps_Exception &e)
+ {
+ std::cout << e.get_value() << std::endl;
+ std::cout << e.what() << std::endl;
+ }
+ /*****************************/
+ try
+ {
+ test_pointer_exception();
+ }
+ catch(Ps_Exception &e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+ /****************************/
+ try
+ {
+ test_outofindex_exception();
+ }
+ catch(Ps_Exception &e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+}
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/mm.c b/src/lib/mm.c
index c65fd11..454dfe2 100644
--- a/src/lib/mm.c
+++ b/src/lib/mm.c
@@ -1,6 +1,8 @@
+#include
+#include
#include
#include "../include/log.h"
-#include
+
#include
#include "../include/mm.h"
@@ -435,4 +437,4 @@ int main(int argc, char **argv)
Ps_MMClear();
return 0;
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/lib_python/c_driver/import_module.c b/src/lib_python/c_driver/import_module.c
index 976790f..8a66a7a 100644
--- a/src/lib_python/c_driver/import_module.c
+++ b/src/lib_python/c_driver/import_module.c
@@ -24,6 +24,9 @@ static PyThread_type_lock module_lock = NULL;
static unsigned int file_name_no = 0;
+/*使用2.6a1的pyc文件*/
+#define PYC_MAGIC (62161 | ((long)'\r'<<16) | ((long)'\n'<<24))
+
BOOL
Ps_ImportInit()
{
@@ -83,6 +86,7 @@ create_module(char *name, PyObject *co)
PyObject *m;
PyObject *d;
PyObject *v;
+ PyObject *err;
assert(name);
assert(co);
/*创建一个新的模块*/
@@ -105,10 +109,15 @@ create_module(char *name, PyObject *co)
if(PyDict_SetItemString(d, "__file__", v) != 0)
PyErr_Clear();
Py_DECREF(v);
+#ifdef IMPORT_DEBUG
+ Ps_Log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n", Ps_LOG_NORMAL);
+ //Ps_LogObject(d, Ps_LOG_NORMAL);
+ Ps_Log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n", Ps_LOG_NORMAL);
+#endif
/*执行字节码*/
v = PyEval_EvalCode((PyCodeObject*)co, d, d);
- if(v == NULL)
+ if(v == NULL || (err = PyErr_Occurred()))
{
Ps_LogObject(d, Ps_LOG_WARING);
Ps_Log("PyEval_EvalCode failed\n", Ps_LOG_WARING);
@@ -145,7 +154,77 @@ __import__(FILE *file, char *name, char *path, char *as, PyObject *local, PyObje
Ps_Log("compile failed\n", Ps_LOG_WARING);
return NULL;
}
+ m = create_module(name, (PyObject*)co);
+ if(m == NULL)
+ {
+ Ps_Log("create_module failed\n", Ps_LOG_WARING);
+ return NULL;
+ }
+ Py_DECREF(co);
+
+ if(local && PyDict_Check(local))
+ {
+ Py_INCREF(m);
+#ifdef IMPORT_DEBUG
+ Ps_LogFormat("The module name is %s\n", Ps_LOG_NORMAL, module_name);
+ Ps_LogObject(local, Ps_LOG_WARING);
+ Ps_LogObject(m, Ps_LOG_WARING);
+ int ret =
+#endif
+ PyDict_SetItemString(local, module_name, m);
+#ifdef IMPORT_DEBUG
+ if(ret == 0)
+ Ps_LogFormat("ret is %d, Import module %s successfully\n", Ps_LOG_NORMAL, ret, module_name);
+ else
+ Ps_LogFormat("ret is %d, Import module %s failed\n", Ps_LOG_NORMAL, ret, module_name);
+#endif
+ }
+ else
+ {
+ PyObject *info = PyString_FromFormat("Import module %s failed", name);
+ if(!info)
+ {
+ PyErr_SetString(PyExc_ImportError, "Import module failed");
+ }
+ else
+ PyErr_SetObject(PyExc_ImportError, info);
+ return NULL;
+ }
+ return m;
+}
+
+static PyObject*
+__import__compiled(FILE *f, char *name, char *path, char *as, PyObject *local, PyObject *global)
+{
+ char *module_name = as ? as : name;
+ PyCodeObject *co;
+ PyObject *m;
+
+ if(name == NULL)
+ return NULL;
+ //比较文件的魔数
+ if(PyMarshal_ReadLongFromFile(f) != PYC_MAGIC)
+ {
+ PyErr_Format(PyExc_ImportError, "Bad magic number of %s", name);
+ return NULL;
+ }
+ //读掉时间信息
+ (void*)PyMarshal_ReadLongFromFile(f);
+ //创建PyCodeObject
+ co = (PyCodeObject*)PyMarshal_ReadLastObjectFromFile(f);
+ if(co == NULL)
+ {
+ PyErr_Format(PyExc_ImportError, "Cannot create code object from module %s", name);
+ return NULL;
+ }
+ if(!PyCode_Check(co))
+ {
+ PyErr_Format(PyExc_ImportError, "Non-code object in module %s", name);
+ Py_DECREF(co);
+ return NULL;
+ }
+ /*创建模块*/
m = create_module(name, (PyObject*)co);
if(m == NULL)
{
@@ -154,6 +233,7 @@ __import__(FILE *file, char *name, char *path, char *as, PyObject *local, PyObje
}
Py_DECREF(co);
+ /*将模块导入命名空间*/
if(local && PyDict_Check(local))
{
Py_INCREF(m);
@@ -184,6 +264,7 @@ __import__(FILE *file, char *name, char *path, char *as, PyObject *local, PyObje
}
return m;
+
}
static FILE*
@@ -297,6 +378,8 @@ from_web_import_as(char *website, char *module, char *as)
#define WEB_PATH_MAX 1024
char buffer[WEB_PATH_MAX];
char file_name[Ps_NAME_MAX];
+ /*加载函数的函数指针*/
+ PyObject* (*loader)(FILE *f, char *name, char *path, char *as, PyObject *local, PyObject *global);
FILE *f;
PyObject *m;
@@ -329,10 +412,11 @@ from_web_import_as(char *website, char *module, char *as)
PyErr_SetString(PyExc_ImportError, "The path to get python module is too long");
return NULL;
}
+ loader = __import__;
if(!Ps_DownloadTimeout(buffer, f, TIME_OUT))
{
Ps_Log("Cannot download %s's py file\n", Ps_LOG_WARING);
- /*再次尝试下载pyc文件*/
+ /*再次尝试下载pyc文件*/
//
(void)get_url(website, module, TRUE, buffer, WEB_PATH_MAX);
if(!Ps_DownloadTimeout(buffer, f, TIME_OUT))
@@ -341,12 +425,27 @@ from_web_import_as(char *website, char *module, char *as)
PyErr_Format(PyExc_ImportError, "Cannot download module %s file from %s\n", module, website);
return NULL;
}
+ /*使用加载pyc文件的加载函数*/
+ loader = __import__compiled;
+ }
+ /*加载py文件*/
+ fclose(f);
+ if((f = fopen(file_name, "r")) == NULL)
+ {
+ Ps_Log("Open temp file failed\n", Ps_LOG_WARING);
+ PyErr_SetString(PyExc_ImportError, "open temp file failed");
+ return NULL;
}
- if(!(m = __import__(f, module, NULL, as, PyEval_GetLocals(), PyEval_GetGlobals())))
+ if(!(m = loader(f, module, NULL, as, PyEval_GetLocals(), PyEval_GetGlobals())))
{
fclose(f);
return NULL;
}
+#ifdef IMPORT_DEBUG
+ Ps_Log("******************************************", Ps_LOG_NORMAL);
+ Ps_LogObject(m, Ps_LOG_NORMAL);
+ Ps_Log("******************************************", Ps_LOG_NORMAL);
+#endif
Py_INCREF(Py_True);
return Py_True;
}
@@ -394,12 +493,12 @@ Ps_FromWebImportAs(PyObject *self, PyObject *args, PyObject *kwds)
PyObject*
Ps_Import(PyObject *self, PyObject *args, PyObject *kws)
{
- struct _ts *state;
+ //struct _ts *state;
char *module;
char *arglist[] = {"module", 0};
FILE *f;
PyObject *m;
- PyObject *local = NULL, *global = NULL;
+ //PyObject *local = NULL, *global = NULL;
if(!PyArg_ParseTupleAndKeywords(args, kws, "s:import", arglist, &module))
{
@@ -411,18 +510,20 @@ Ps_Import(PyObject *self, PyObject *args, PyObject *kws)
Ps_LogFormat("Open file %s failed\n", Ps_LOG_WARING, module);
goto error;
}
- state = PyThreadState_Get();
+ /*state = PyThreadState_Get();
if(state->frame)
{
local = state->frame->f_locals;
global = state->frame->f_globals;
- }
+ }*/
- if((m = __import__(f, module, NULL, NULL, local, global)) == NULL)
+ if((m = __import__(f, module, NULL, NULL, PyEval_GetLocals(), PyEval_GetGlobals())) == NULL)
{
if(PyErr_Occurred())
+ {
return NULL;
+ }
goto error;
}
Py_INCREF(Py_True);
diff --git a/src/lib_python/c_driver/test_/cache/0 b/src/lib_python/c_driver/test_/cache/0
index f687f50..847297e 100644
--- a/src/lib_python/c_driver/test_/cache/0
+++ b/src/lib_python/c_driver/test_/cache/0
@@ -1,4 +1,6 @@
-#a = 10
-#b = 20
-#print a + b
-dir()
\ No newline at end of file
+a = 10
+b = 20
+print a + b
+
+#if a
+# print a
\ No newline at end of file
diff --git a/src/lib_python/c_driver/test_/cache/1 b/src/lib_python/c_driver/test_/cache/1
deleted file mode 100644
index 74887d1..0000000
--- a/src/lib_python/c_driver/test_/cache/1
+++ /dev/null
@@ -1,3 +0,0 @@
-a = 10
-b = 20
-print a + b
\ No newline at end of file
diff --git a/src/lib_python/c_driver/test_/cache/test5.py b/src/lib_python/c_driver/test_/cache/test5.py
new file mode 100644
index 0000000..d555b2f
--- /dev/null
+++ b/src/lib_python/c_driver/test_/cache/test5.py
@@ -0,0 +1 @@
+test5.py
\ No newline at end of file
diff --git a/src/lib_python/c_driver/test_/log.txt b/src/lib_python/c_driver/test_/log.txt
index 97469a7..f2bb1d3 100644
--- a/src/lib_python/c_driver/test_/log.txt
+++ b/src/lib_python/c_driver/test_/log.txt
@@ -1,7 +1,9 @@
Creat temp file cache/0
From http://localhost:8080/global/python import test1
Total_len is 45 and buffer len is 1024
-The module name is test1
+$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+The module name is t
--------------------
Object dict info:
doc: dict() -> new empty dictionary
@@ -31,8 +33,23 @@ base size is 12
Length unchangable object.
repr:
str:
-hash value: -1216657924
+hash value: -1217579740
It's an uncallable object
It's an uniterable object
----------------------
-ret is 0, Import module test1 successfully
+ret is 0, Import module t successfully
+******************************************--------------------
+Object module info:
+doc: module(name[, doc])
+
+Create a module object.
+The name must be a string; the optional doc argument can have any type.
+base size is 12
+Length unchangable object.
+repr:
+str:
+hash value: -1217579740
+It's an uncallable object
+It's an uniterable object
+----------------------
+******************************************
\ No newline at end of file
diff --git a/src/lib_python/c_driver/test_/psimport.so b/src/lib_python/c_driver/test_/psimport.so
index e1efdf8..6dec039 100755
Binary files a/src/lib_python/c_driver/test_/psimport.so and b/src/lib_python/c_driver/test_/psimport.so differ
diff --git a/src/lib_python/c_driver/test_/test b/src/lib_python/c_driver/test_/test
index 75909d6..b0892b0 100644
--- a/src/lib_python/c_driver/test_/test
+++ b/src/lib_python/c_driver/test_/test
@@ -1,2 +1,2 @@
-#a = '123'
-print a
\ No newline at end of file
+a = '123'
+print aa
\ No newline at end of file
diff --git a/src/lib_python/c_driver/test_/test5.py b/src/lib_python/c_driver/test_/test5.py
new file mode 100644
index 0000000..4b45312
--- /dev/null
+++ b/src/lib_python/c_driver/test_/test5.py
@@ -0,0 +1 @@
+a = 10
\ No newline at end of file
diff --git a/src/lib_python/c_driver/test_/test5.pyc b/src/lib_python/c_driver/test_/test5.pyc
new file mode 100644
index 0000000..aeabc45
Binary files /dev/null and b/src/lib_python/c_driver/test_/test5.pyc differ
diff --git a/src/lib_python/c_driver/test_/web_test.py b/src/lib_python/c_driver/test_/web_test.py
index 73da729..6c37fca 100644
--- a/src/lib_python/c_driver/test_/web_test.py
+++ b/src/lib_python/c_driver/test_/web_test.py
@@ -1,2 +1,6 @@
import psimport
-print psimport.ps_fromwebimport("http://localhost:8080/global/python", "test1")
+#dir()
+print 'a'
+psimport.ps_fromwebimportas("http://localhost:8080/global/python", "test1", 't')
+print t.a, t
+#import test5
\ No newline at end of file
diff --git a/src/lib_python/c_driver/test_/web_test.pyc b/src/lib_python/c_driver/test_/web_test.pyc
index b97ceb8..befa850 100644
Binary files a/src/lib_python/c_driver/test_/web_test.pyc and b/src/lib_python/c_driver/test_/web_test.pyc differ
diff --git a/src/util/log.c b/src/util/log.c
index e68bb2c..291f93a 100644
--- a/src/util/log.c
+++ b/src/util/log.c
@@ -1,3 +1,4 @@
+
/**
* Ps的log
**/
@@ -50,7 +51,7 @@ Ps_Log(char *info, int type)
//assert(log_error);
//assert(log_normal);
GET_LOG_LOCK();
- printf("%d\n", type);
+ //printf("%d\n", type);
switch(type)
{
case Ps_LOG_WARING:
diff --git a/web.o b/web.o
new file mode 100644
index 0000000..05fe0ab
Binary files /dev/null and b/web.o differ