mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
Merge pull request #2602 from csoler/v0.6-cmake
added cmake list for files in GUI
This commit is contained in:
commit
7532efd5fc
492
retroshare-gui/CMakeLists.txt
Normal file
492
retroshare-gui/CMakeLists.txt
Normal file
@ -0,0 +1,492 @@
|
||||
################################################################################
|
||||
# retroshare-gui/CMakeLists.txt #
|
||||
# Copyright (C) 2022, Retroshare team <retroshare.team@gmailcom> #
|
||||
# #
|
||||
# This program is free software: you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU Affero General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU Affero General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Affero General Public License #
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||
################################################################################
|
||||
|
||||
cmake_minimum_required (VERSION 3.18.0)
|
||||
project(retroshare-gui VERSION 0.6.6 LANGUAGES CXX)
|
||||
|
||||
include(CMakeDependentOption)
|
||||
|
||||
set(
|
||||
RS_BIN_INSTALL_DIR
|
||||
"${CMAKE_INSTALL_PREFIX}/bin"
|
||||
CACHE PATH
|
||||
"Path where to install retroshare-service compiled binary" )
|
||||
|
||||
option(
|
||||
RS_DEVELOPMENT_BUILD
|
||||
"Disable optimization to speed up build, enable verbose build log. \
|
||||
just for development purposes, not suitable for library usage"
|
||||
ON )
|
||||
|
||||
option(
|
||||
RS_JSON_API
|
||||
"Use restbed to expose libretroshare as JSON API via HTTP"
|
||||
OFF )
|
||||
|
||||
option(
|
||||
RS_SERVICE_DESKTOP
|
||||
"Install icons and shortcuts for desktop environements"
|
||||
OFF )
|
||||
|
||||
option(
|
||||
RS_SERVICE_TERMINAL_LOGIN
|
||||
"Enable RetroShare login via terminal"
|
||||
ON )
|
||||
|
||||
option( RS_GXSGUI "Enable GXS services in GUI" ON )
|
||||
option( RS_GXSCHANNELS "Enable GXS channels in GUI" ON )
|
||||
option( RS_GXSFORUMS "Enable GXS forums in GUI" ON )
|
||||
option( RS_GXSPOSTED "Enable GXS posted in GUI" ON )
|
||||
option( RS_GXSCIRCLES "Enable GXS circles in GUI" ON )
|
||||
|
||||
cmake_dependent_option(
|
||||
RS_SERVICE_TERMINAL_WEBUI_PASSWORD
|
||||
"Enable settin Web UI password via terminal in retroshare-service"
|
||||
OFF
|
||||
"RS_WEBUI"
|
||||
ON )
|
||||
|
||||
cmake_dependent_option(
|
||||
RS_WEBUI
|
||||
"Install RetroShare Web UI"
|
||||
OFF
|
||||
"RS_JSON_API"
|
||||
ON )
|
||||
|
||||
################################ QT FILES #######################################
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package( Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package( Qt5 COMPONENTS Widgets REQUIRED)
|
||||
find_package( Qt5 COMPONENTS Xml REQUIRED)
|
||||
find_package( Qt5 COMPONENTS Network REQUIRED)
|
||||
find_package( Qt5 COMPONENTS Multimedia REQUIRED)
|
||||
find_package( Qt5 COMPONENTS PrintSupport REQUIRED)
|
||||
|
||||
list( APPEND RS_LINK_LIBRARIES Qt5::Multimedia Qt5::Widgets Qt5::Xml Qt5::Network Qt5::PrintSupport)
|
||||
|
||||
################################################################################
|
||||
|
||||
set(FETCHCONTENT_QUIET OFF)
|
||||
include(FetchContent)
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_DEVELOPMENT_BUILD)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
endif(RS_DEVELOPMENT_BUILD)
|
||||
|
||||
################################################################################
|
||||
|
||||
include(src/CMakeLists.txt)
|
||||
|
||||
qt5_wrap_ui(RS_UI_HEADERS ${RS_GUI_FORMS})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${RS_GUI_SOURCES} ${RS_UI_HEADERS} ${RS_GUI_QTRESOURCES})
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION ${RS_BIN_INSTALL_DIR})
|
||||
|
||||
include_directories( ${CMAKE_BINARY_DIR} )
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_DEVELOPMENT_BUILD)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE "-O0")
|
||||
endif(RS_DEVELOPMENT_BUILD)
|
||||
|
||||
################################################################################
|
||||
|
||||
set(LIBRETROSHARE_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libretroshare/")
|
||||
if(EXISTS "${LIBRETROSHARE_DEVEL_DIR}/.git" )
|
||||
message(
|
||||
STATUS
|
||||
"libretroshare submodule found at ${LIBRETROSHARE_DEVEL_DIR} using it" )
|
||||
add_subdirectory(
|
||||
"${LIBRETROSHARE_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/libretroshare" )
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
libretroshare
|
||||
GIT_REPOSITORY "https://gitlab.com/RetroShare/libretroshare.git"
|
||||
GIT_TAG "origin/master"
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
TIMEOUT 10
|
||||
)
|
||||
FetchContent_MakeAvailable(libretroshare)
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBRETROSHARE_DEVEL_DIR}/src/)
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_SERVICE_DESKTOP)
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(
|
||||
FILES data/retroshare.svg
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/ )
|
||||
|
||||
install(
|
||||
FILES data/retroshare.xpm
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps/ )
|
||||
|
||||
install(
|
||||
FILES data/24x24/apps/retroshare.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/24x24/apps/retroshare.png )
|
||||
|
||||
install(
|
||||
FILES data/48x48/apps/retroshare.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps/retroshare.png )
|
||||
|
||||
install(
|
||||
FILES data/64x64/apps/retroshare.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/64x64/apps/retroshare.png )
|
||||
|
||||
install(
|
||||
FILES data/128x128/apps/retroshare.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/128x128/apps/retroshare.png )
|
||||
|
||||
install(
|
||||
FILES data/retroshare.desktop
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/data/retroshare.desktop )
|
||||
|
||||
install(
|
||||
FILES gui/qss/chat/Bubble gui/qss/chat/Bubble_Compact
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/data/stylesheets/ )
|
||||
|
||||
install(
|
||||
FILES src/sounds/ src/qss/
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/ )
|
||||
endif(UNIX AND NOT APPLE)
|
||||
endif(RS_SERVICE_DESKTOP)
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_JSON_API)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_JSONAPI)
|
||||
endif(RS_JSON_API)
|
||||
|
||||
################################# CMark ########################################
|
||||
|
||||
if(RS_GUI_CMARK)
|
||||
set(CMARK_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../supportlibs/cmark/")
|
||||
if(EXISTS "${LIBRETROSHARE_DEVEL_DIR}/.git" )
|
||||
message( STATUS "cmark submodule found at ${LIBRETROSHARE_DEVEL_DIR} using it" )
|
||||
add_subdirectory( "${LIBRETROSHARE_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/cmark" )
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
cmark
|
||||
GIT_REPOSITORY "https://github.com/commonmark/cmark.git"
|
||||
GIT_TAG "origin/master"
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
TIMEOUT 10
|
||||
)
|
||||
FetchContent_MakeAvailable(cmark)
|
||||
endif()
|
||||
endif(RS_GUI_CMARK)
|
||||
|
||||
################################# LibSam v3 ####################################
|
||||
|
||||
set(SAM3_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../supportlibs/libsam3/")
|
||||
if(EXISTS "${SAM3_DEVEL_DIR}/.git" )
|
||||
message( STATUS "libsam3 submodule found at ${SAM3_DEVEL_DIR} using it" )
|
||||
add_subdirectory( "${SAM3_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/libsam3" )
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
libsam3
|
||||
GIT_REPOSITORY "https://github.com/i2p/libsam3.git"
|
||||
GIT_TAG "origin/master"
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
TIMEOUT 10
|
||||
)
|
||||
FetchContent_MakeAvailable(libsam3)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# TODO #
|
||||
################################################################################
|
||||
|
||||
# # Auto detect installed version of cmark
|
||||
# rs_gui_cmark {
|
||||
# DEFINES *= USE_CMARK
|
||||
# no_rs_cross_compiling {
|
||||
# message("Using compiled cmark")
|
||||
# CMARK_SRC_PATH=$$clean_path($${RS_SRC_PATH}/supportlibs/cmark)
|
||||
# CMARK_BUILD_PATH=$$clean_path($${RS_BUILD_PATH}/supportlibs/cmark/build)
|
||||
# INCLUDEPATH *= $$clean_path($${CMARK_SRC_PATH}/src/)
|
||||
# DEPENDPATH *= $$clean_path($${CMARK_SRC_PATH}/src/)
|
||||
# QMAKE_LIBDIR *= $$clean_path($${CMARK_BUILD_PATH}/)
|
||||
# # Using sLibs would fail as libcmark.a is generated at compile-time
|
||||
# LIBS *= -L$$clean_path($${CMARK_BUILD_PATH}/src/) -lcmark
|
||||
#
|
||||
# DUMMYCMARKINPUT = FORCE
|
||||
# CMAKE_GENERATOR_OVERRIDE=""
|
||||
# win32-g++|win32-clang-g++:CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\""
|
||||
# gencmarklib.name = Generating libcmark.
|
||||
# gencmarklib.input = DUMMYCMARKINPUT
|
||||
# gencmarklib.output = $$clean_path($${CMARK_BUILD_PATH}/src/libcmark.a)
|
||||
# gencmarklib.CONFIG += target_predeps combine
|
||||
# gencmarklib.variable_out = PRE_TARGETDEPS
|
||||
# gencmarklib.commands = \
|
||||
# cd $${RS_SRC_PATH} && ( \
|
||||
# git submodule update --init supportlibs/cmark ; \
|
||||
# cd $${CMARK_SRC_PATH} ; \
|
||||
# true ) && \
|
||||
# mkdir -p $${CMARK_BUILD_PATH} && cd $${CMARK_BUILD_PATH} && \
|
||||
# cmake \
|
||||
# -DCMAKE_CXX_COMPILER=$$QMAKE_CXX \
|
||||
# \"-DCMAKE_CXX_FLAGS=$${QMAKE_CXXFLAGS}\" \
|
||||
# $${CMAKE_GENERATOR_OVERRIDE} \
|
||||
# -DCMAKE_INSTALL_PREFIX=. \
|
||||
# -B. \
|
||||
# -H$$shell_path($${CMARK_SRC_PATH}) && \
|
||||
# $(MAKE)
|
||||
# QMAKE_EXTRA_COMPILERS += gencmarklib
|
||||
# } else {
|
||||
# message("Using systems cmark")
|
||||
# sLibs *= libcmark
|
||||
# }
|
||||
# }
|
||||
|
||||
################################# Linux ##########################################
|
||||
# Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib
|
||||
|
||||
if(UNIX)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(X11 REQUIRED x11)
|
||||
pkg_check_modules(XSCRNSAVER REQUIRED xscrnsaver)
|
||||
|
||||
list( APPEND RS_LINK_LIBRARIES ${X11_LIBRARIES} )
|
||||
list( APPEND RS_LINK_LIBRARIES ${XSCRNSAVER_LIBRARIES} )
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${X11_INCLUDE_DIRS})
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${X11_CFLAGS_OTHER})
|
||||
|
||||
target_include_directories(retroshare-gui PRIVATE ${XSCRNSAVER_INCLUDE_DIRS})
|
||||
target_compile_options(retroshare-gui PRIVATE ${XSCRNSAVER_CFLAGS_OTHER})
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_XSS)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE _FILE_OFFSET_BITS=64)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE LINKER:-rdynamic)
|
||||
endif(UNIX)
|
||||
|
||||
if(RS_SANITIZE)
|
||||
list( APPEND RS_LINK_LIBRARIES asan )
|
||||
list( APPEND RS_LINK_LIBRARIES ubsan )
|
||||
endif(RS_SANITIZE)
|
||||
|
||||
# #################### Cross compilation for windows under Linux ###################
|
||||
#
|
||||
# win32-x-g++ {
|
||||
# OBJECTS_DIR = temp/win32-x-g++/obj
|
||||
#
|
||||
# LIBS += ../../../../lib/win32-x-g++-v0.5/libssl.a
|
||||
# LIBS += ../../../../lib/win32-x-g++-v0.5/libcrypto.a
|
||||
# LIBS += ../../../../lib/win32-x-g++-v0.5/libgpgme.dll.a
|
||||
# LIBS += ../../../../lib/win32-x-g++-v0.5/libminiupnpc.a
|
||||
# LIBS += ../../../../lib/win32-x-g++-v0.5/libz.a
|
||||
# LIBS += -L${HOME}/.wine/drive_c/pthreads/lib -lpthreadGCE2
|
||||
# LIBS += -lQtUiTools
|
||||
# LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32
|
||||
# LIBS += -lole32 -lwinmm
|
||||
#
|
||||
# DEFINES *= WINDOWS_SYS WIN32 WIN32_CROSS_UBUNTU
|
||||
#
|
||||
# INCLUDEPATH += ../../../../gpgme-1.1.8/src/
|
||||
# INCLUDEPATH += ../../../../libgpg-error-1.7/src/
|
||||
#
|
||||
# RC_FILE = gui/images/retroshare_win.rc
|
||||
# }
|
||||
#
|
||||
# #################################### Windows #####################################
|
||||
#
|
||||
# win32-g++|win32-clang-g++ {
|
||||
# CONFIG(debug, debug|release) {
|
||||
# # show console output
|
||||
# CONFIG += console
|
||||
# } else {
|
||||
# CONFIG -= console
|
||||
# }
|
||||
#
|
||||
# CONFIG(debug, debug|release) {
|
||||
# } else {
|
||||
# # Tell linker to use ASLR protection
|
||||
# QMAKE_LFLAGS += -Wl,-dynamicbase
|
||||
# # Tell linker to use DEP protection
|
||||
# QMAKE_LFLAGS += -Wl,-nxcompat
|
||||
# }
|
||||
#
|
||||
# # Fix linking error (ld.exe: Error: export ordinal too large) due to too
|
||||
# # many exported symbols.
|
||||
# !libretroshare_shared:QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL
|
||||
#
|
||||
# # Switch off optimization for release version
|
||||
# QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||
# QMAKE_CXXFLAGS_RELEASE += -O0
|
||||
# QMAKE_CFLAGS_RELEASE -= -O2
|
||||
# QMAKE_CFLAGS_RELEASE += -O0
|
||||
#
|
||||
# # Switch on optimization for debug version
|
||||
# #QMAKE_CXXFLAGS_DEBUG += -O2
|
||||
# #QMAKE_CFLAGS_DEBUG += -O2
|
||||
#
|
||||
# OBJECTS_DIR = temp/obj
|
||||
#
|
||||
# dLib = ws2_32 gdi32 uuid ole32 iphlpapi crypt32 winmm
|
||||
# LIBS *= $$linkDynamicLibs(dLib)
|
||||
#
|
||||
# RC_FILE = gui/images/retroshare_win.rc
|
||||
#
|
||||
# # export symbols for the plugins
|
||||
# LIBS += -Wl,--export-all-symbols,--out-implib,lib/libretroshare-gui.a
|
||||
#
|
||||
# # create lib directory
|
||||
# isEmpty(QMAKE_SH) {
|
||||
# QMAKE_PRE_LINK = $(CHK_DIR_EXISTS) lib $(MKDIR) lib
|
||||
# } else {
|
||||
# QMAKE_PRE_LINK = $(CHK_DIR_EXISTS) lib || $(MKDIR) lib
|
||||
# }
|
||||
#
|
||||
# greaterThan(QT_MAJOR_VERSION, 4) {
|
||||
# # Qt 5
|
||||
# RC_INCLUDEPATH += $$_PRO_FILE_PWD_/../../libretroshare/src
|
||||
# } else {
|
||||
# # Qt 4
|
||||
# QMAKE_RC += --include-dir=$$_PRO_FILE_PWD_/../../libretroshare/src
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# ##################################### MacOS ######################################
|
||||
#
|
||||
# macx {
|
||||
# # ENABLE THIS OPTION FOR Univeral Binary BUILD.
|
||||
# #CONFIG += ppc x86
|
||||
# #QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
||||
# QMAKE_INFO_PLIST = Info.plist
|
||||
# mac_icon.files = $$files($$PWD/rsMacIcon.icns)
|
||||
# mac_icon.path = Contents/Resources
|
||||
# QMAKE_BUNDLE_DATA += mac_icon
|
||||
# dplQSS.files = $$PWD/qss
|
||||
# dplQSS.path = Contents/Resources
|
||||
# QMAKE_BUNDLE_DATA += dplQSS
|
||||
# dplChatStyles.files = \
|
||||
# $$PWD/gui/qss/chat/Bubble \
|
||||
# $$PWD/gui/qss/chat/Bubble_Compact
|
||||
# dplChatStyles.path = Contents/Resources/stylesheets
|
||||
# QMAKE_BUNDLE_DATA += dplChatStyles
|
||||
# # mac_webui.files = $$files($$PWD/../../libresapi/src/webui)
|
||||
# # mac_webui.path = Contents/Resources
|
||||
# # QMAKE_BUNDLE_DATA += mac_webui
|
||||
#
|
||||
# OBJECTS_DIR = temp/obj
|
||||
#
|
||||
# CONFIG += version_detail_bash_script
|
||||
# LIBS += -lssl -lcrypto -lz
|
||||
# for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a}
|
||||
# LIBS += -framework CoreFoundation
|
||||
# LIBS += -framework Security
|
||||
# LIBS += -framework Carbon
|
||||
#
|
||||
# for(lib, LIB_DIR):LIBS += -L"$$lib"
|
||||
# for(bin, BIN_DIR):LIBS += -L"$$bin"
|
||||
#
|
||||
# DEPENDPATH += . $$INC_DIR
|
||||
# INCLUDEPATH += . $$INC_DIR
|
||||
#
|
||||
# #DEFINES *= MAC_IDLE # for idle feature
|
||||
# CONFIG -= uitools
|
||||
# }
|
||||
#
|
||||
# ##################################### FreeBSD ######################################
|
||||
#
|
||||
# freebsd-* {
|
||||
# INCLUDEPATH *= /usr/local/include/gpgme
|
||||
# LIBS *= -lssl
|
||||
# LIBS *= -lgpgme
|
||||
# LIBS *= -lupnp
|
||||
# LIBS *= -lgnome-keyring
|
||||
#
|
||||
# LIBS += -lsqlite3
|
||||
# }
|
||||
#
|
||||
# ##################################### Haiku ######################################
|
||||
#
|
||||
# haiku-* {
|
||||
# PRE_TARGETDEPS *= ../../libretroshare/src/lib/libretroshare.a
|
||||
# PRE_TARGETDEPS *= ../../openpgpsdk/src/lib/libops.a
|
||||
#
|
||||
# LIBS *= ../../libretroshare/src/lib/libretroshare.a
|
||||
# LIBS *= ../../openpgpsdk/src/lib/libops.a -lbz2 -lbsd
|
||||
# LIBS *= -lssl -lcrypto -lnetwork
|
||||
# LIBS *= -lgpgme
|
||||
# LIBS *= -lupnp
|
||||
# LIBS *= -lz
|
||||
# LIBS *= -lixml
|
||||
#
|
||||
# LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
|
||||
# LIBS += -lsqlite3
|
||||
# }
|
||||
#
|
||||
# ##################################### OpenBSD ######################################
|
||||
#
|
||||
# openbsd-* {
|
||||
# INCLUDEPATH *= /usr/local/include
|
||||
#
|
||||
# LIBS *= -lssl -lcrypto
|
||||
# LIBS *= -lgpgme
|
||||
# LIBS *= -lupnp
|
||||
# LIBS *= -lgnome-keyring
|
||||
# LIBS += -lsqlite3
|
||||
# LIBS *= -rdynamic
|
||||
# }
|
||||
#
|
||||
# ################################### COMMON stuff ##################################
|
||||
#
|
||||
# wikipoos {
|
||||
# PRE_TARGETDEPS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
|
||||
# LIBS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
|
||||
# LIBS *= -lglib-2.0
|
||||
# }
|
||||
|
||||
################################ GENERAL #######################################
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${RS_LINK_LIBRARIES})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/)
|
||||
|
||||
set( CMAKE_CXX_FLAGS "-Wno-deprecated-declarations" )
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_NO_WARN_DEPRECATED )
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE RS_RELEASE_VERSION )
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE TARGET=\"retroshare\")
|
||||
|
||||
if(RS_GXS_CIRCLES)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE RS_USE_CIRCLES )
|
||||
endif(RS_GXS_CIRCLES)
|
||||
|
||||
#add_dependencies(${PROJECT_NAME} libretroshare)
|
||||
|
1279
retroshare-gui/src/CMakeLists.txt
Normal file
1279
retroshare-gui/src/CMakeLists.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
|
||||
#include "AboutDialog.h"
|
||||
#include "HelpDialog.h"
|
||||
#include "qmake_info.h"
|
||||
#include "include/qmake_info.h"
|
||||
#include "rshare.h"
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
Q_DECLARE_METATYPE(FileProgressInfo)
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
DLListDelegate::DLListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
@ -180,7 +182,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
break;
|
||||
case COLUMN_SOURCES:
|
||||
case COLUMN_SOURCES:
|
||||
{
|
||||
double dblValue = index.data().toDouble();
|
||||
|
||||
@ -188,7 +190,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
||||
}
|
||||
break;
|
||||
case COLUMN_PRIORITY:
|
||||
case COLUMN_PRIORITY:
|
||||
{
|
||||
double dblValue = index.data().toDouble();
|
||||
if (dblValue == PRIORITY_NULL)
|
||||
@ -205,7 +207,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
||||
}
|
||||
break;
|
||||
case COLUMN_DOWNLOADTIME:
|
||||
case COLUMN_DOWNLOADTIME:
|
||||
downloadtime = index.data().toLongLong();
|
||||
minutes = downloadtime / 60;
|
||||
seconds = downloadtime % 60;
|
||||
@ -225,7 +227,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
temp = "" ;
|
||||
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
||||
break;
|
||||
case COLUMN_NAME:
|
||||
case COLUMN_NAME:
|
||||
{
|
||||
// decoration
|
||||
int pixOffset = 0;
|
||||
|
@ -18,55 +18,40 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef DLLISTDELEGATE_H
|
||||
#define DLLISTDELEGATE_H
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include "xprogressbar.h"
|
||||
|
||||
|
||||
// Defines for download list list columns
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_SIZE 1
|
||||
#define COLUMN_COMPLETED 2
|
||||
#define COLUMN_DLSPEED 3
|
||||
#define COLUMN_PROGRESS 4
|
||||
#define COLUMN_SOURCES 5
|
||||
#define COLUMN_STATUS 6
|
||||
#define COLUMN_PRIORITY 7
|
||||
#define COLUMN_REMAINING 8
|
||||
#define COLUMN_DOWNLOADTIME 9
|
||||
#define COLUMN_ID 10
|
||||
#define COLUMN_LASTDL 11
|
||||
#define COLUMN_PATH 12
|
||||
#define COLUMN_COUNT 13
|
||||
|
||||
#define PRIORITY_NULL 0.0
|
||||
#define PRIORITY_FASTER 0.1
|
||||
#define PRIORITY_AVERAGE 0.2
|
||||
#define PRIORITY_SLOWER 0.3
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
class QModelIndex;
|
||||
class QPainter;
|
||||
|
||||
class DLListDelegate: public QAbstractItemDelegate
|
||||
{
|
||||
public:
|
||||
DLListDelegate(QObject *parent=0);
|
||||
virtual ~DLListDelegate(){}
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const;
|
||||
|
||||
class DLListDelegate: public QAbstractItemDelegate {
|
||||
static constexpr int COLUMN_NAME = 0;
|
||||
static constexpr int COLUMN_SIZE = 1;
|
||||
static constexpr int COLUMN_COMPLETED = 2;
|
||||
static constexpr int COLUMN_DLSPEED = 3;
|
||||
static constexpr int COLUMN_PROGRESS = 4;
|
||||
static constexpr int COLUMN_SOURCES = 5;
|
||||
static constexpr int COLUMN_STATUS = 6;
|
||||
static constexpr int COLUMN_PRIORITY = 7;
|
||||
static constexpr int COLUMN_REMAINING = 8;
|
||||
static constexpr int COLUMN_DOWNLOADTIME= 9;
|
||||
static constexpr int COLUMN_ID = 10;
|
||||
static constexpr int COLUMN_LASTDL = 11;
|
||||
static constexpr int COLUMN_PATH = 12;
|
||||
static constexpr int COLUMN_COUNT = 13;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DLListDelegate(QObject *parent=0);
|
||||
virtual ~DLListDelegate(){}
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const;
|
||||
|
||||
private:
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
static constexpr float PRIORITY_NULL = 0.0;
|
||||
static constexpr float PRIORITY_FASTER = 0.1;
|
||||
static constexpr float PRIORITY_AVERAGE = 0.2;
|
||||
static constexpr float PRIORITY_SLOWER = 0.3;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -55,6 +55,16 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#define SHARED_FILES_DIALOG_COLUMN_NAME 0
|
||||
#define SHARED_FILES_DIALOG_COLUMN_FILENB 1
|
||||
#define SHARED_FILES_DIALOG_COLUMN_SIZE 2
|
||||
#define SHARED_FILES_DIALOG_COLUMN_AGE 3
|
||||
#define SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS 4
|
||||
#define SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR 5
|
||||
#define SHARED_FILES_DIALOG_COLUMN_COUNT 6
|
||||
|
||||
#define SHARED_FILES_DIALOG_FILTER_STRING "filtered"
|
||||
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_DOWNLOAD ":/icons/png/download.png"
|
||||
#define IMAGE_PLAY ":/images/start.png"
|
||||
@ -187,17 +197,17 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent)
|
||||
tree_proxyModel->setSourceModel(tree_model);
|
||||
tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
tree_proxyModel->sort(COLUMN_NAME);
|
||||
tree_proxyModel->sort(SHARED_FILES_DIALOG_COLUMN_NAME);
|
||||
tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
|
||||
tree_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
|
||||
tree_proxyModel->setFilterRegExp(QRegExp(QString(SHARED_FILES_DIALOG_FILTER_STRING))) ;
|
||||
|
||||
flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
|
||||
flat_proxyModel->setSourceModel(flat_model);
|
||||
flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
flat_proxyModel->sort(COLUMN_NAME);
|
||||
flat_proxyModel->sort(SHARED_FILES_DIALOG_COLUMN_NAME);
|
||||
flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
|
||||
flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
|
||||
flat_proxyModel->setFilterRegExp(QRegExp(QString(SHARED_FILES_DIALOG_FILTER_STRING))) ;
|
||||
|
||||
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
|
||||
@ -219,12 +229,12 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent)
|
||||
int charWidth = ui.dirTreeView->fontMetrics().horizontalAdvance("_");
|
||||
#endif
|
||||
|
||||
header->resizeSection ( COLUMN_NAME , charWidth*100 );
|
||||
header->resizeSection ( COLUMN_FILENB , charWidth*15 );
|
||||
header->resizeSection ( COLUMN_SIZE , charWidth*10 );
|
||||
header->resizeSection ( COLUMN_AGE , charWidth*6 );
|
||||
header->resizeSection ( COLUMN_FRIEND_ACCESS, charWidth*10 );
|
||||
header->resizeSection ( COLUMN_WN_VISU_DIR , charWidth*20 );
|
||||
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_NAME , charWidth*100 );
|
||||
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_FILENB , charWidth*15 );
|
||||
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_SIZE , charWidth*10 );
|
||||
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_AGE , charWidth*6 );
|
||||
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, charWidth*10 );
|
||||
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR , charWidth*20 );
|
||||
|
||||
header->setStretchLastSection(true);
|
||||
|
||||
@ -260,7 +270,7 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
||||
: SharedFilesDialog(false,parent)
|
||||
{
|
||||
// Hide columns after loading the settings
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
|
||||
ui.downloadButton->hide() ;
|
||||
|
||||
// load settings
|
||||
@ -279,14 +289,14 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
||||
|
||||
ui.titleBarPixmap->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_MYFILES)) ;
|
||||
|
||||
ui.dirTreeView->setItemDelegateForColumn(COLUMN_FRIEND_ACCESS,new ShareFlagsItemDelegate()) ;
|
||||
ui.dirTreeView->setItemDelegateForColumn(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS,new ShareFlagsItemDelegate()) ;
|
||||
}
|
||||
|
||||
RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent)
|
||||
: SharedFilesDialog(true,parent)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, true) ;
|
||||
ui.checkButton->hide() ;
|
||||
|
||||
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected()));
|
||||
@ -440,9 +450,9 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
|
||||
restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes);
|
||||
|
||||
QHeaderView * header = ui.dirTreeView->header () ;
|
||||
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(header, SHARED_FILES_DIALOG_COLUMN_NAME, QHeaderView::Interactive);
|
||||
|
||||
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ;
|
||||
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, SHARED_FILES_DIALOG_COLUMN_NAME, SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR) ;
|
||||
|
||||
// recursRestoreExpandedItems(ui.dirTreeView->rootIndex(),expanded_indexes);
|
||||
FilterItems();
|
||||
@ -452,9 +462,9 @@ void LocalSharedFilesDialog::showProperColumns()
|
||||
{
|
||||
if(model == tree_model)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
@ -464,9 +474,9 @@ void LocalSharedFilesDialog::showProperColumns()
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, true) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, true) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->show();
|
||||
ui.filterPatternLineEdit->show();
|
||||
@ -477,9 +487,9 @@ void RemoteSharedFilesDialog::showProperColumns()
|
||||
{
|
||||
if(model == tree_model)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, true) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, true) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
@ -489,9 +499,9 @@ void RemoteSharedFilesDialog::showProperColumns()
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, true) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->show();
|
||||
ui.filterPatternLineEdit->show();
|
||||
@ -1337,9 +1347,9 @@ void SharedFilesDialog::indicatorChanged(int index)
|
||||
ui.dirTreeView->update(ui.dirTreeView->rootIndex());
|
||||
|
||||
if (correct_indicator[index] != IND_ALWAYS)
|
||||
ui.dirTreeView->sortByColumn(COLUMN_AGE, Qt::AscendingOrder);
|
||||
ui.dirTreeView->sortByColumn(SHARED_FILES_DIALOG_COLUMN_AGE, Qt::AscendingOrder);
|
||||
else
|
||||
ui.dirTreeView->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
|
||||
ui.dirTreeView->sortByColumn(SHARED_FILES_DIALOG_COLUMN_NAME, Qt::AscendingOrder);
|
||||
|
||||
updateDisplay() ;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public:
|
||||
}
|
||||
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const
|
||||
{
|
||||
return COLUMN_COUNT ;
|
||||
return DLListDelegate::COLUMN_COUNT ;
|
||||
}
|
||||
bool hasChildren(const QModelIndex &parent = QModelIndex()) const
|
||||
{
|
||||
@ -176,7 +176,7 @@ public:
|
||||
|
||||
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const
|
||||
{
|
||||
if(row < 0 || column < 0 || column >= COLUMN_COUNT)
|
||||
if(row < 0 || column < 0 || column >= DLListDelegate::COLUMN_COUNT)
|
||||
return QModelIndex();
|
||||
|
||||
void *parent_ref = (parent.isValid())?parent.internalPointer():NULL ;
|
||||
@ -258,19 +258,19 @@ public:
|
||||
switch(section)
|
||||
{
|
||||
default:
|
||||
case COLUMN_NAME: return tr("Name", "i.e: file name");
|
||||
case COLUMN_SIZE: return tr("Size", "i.e: file size");
|
||||
case COLUMN_COMPLETED: return tr("Completed", "");
|
||||
case COLUMN_DLSPEED: return tr("Speed", "i.e: Download speed");
|
||||
case COLUMN_PROGRESS: return tr("Progress / Availability", "i.e: % downloaded");
|
||||
case COLUMN_SOURCES: return tr("Sources", "i.e: Sources");
|
||||
case COLUMN_STATUS: return tr("Status");
|
||||
case COLUMN_PRIORITY: return tr("Speed / Queue position");
|
||||
case COLUMN_REMAINING: return tr("Remaining");
|
||||
case COLUMN_DOWNLOADTIME: return tr("Download time", "i.e: Estimated Time of Arrival / Time left");
|
||||
case COLUMN_ID: return tr("Hash");
|
||||
case COLUMN_LASTDL: return tr("Last Time Seen", "i.e: Last Time Receiced Data");
|
||||
case COLUMN_PATH: return tr("Path", "i.e: Where file is saved");
|
||||
case DLListDelegate::COLUMN_NAME: return tr("Name", "i.e: file name");
|
||||
case DLListDelegate::COLUMN_SIZE: return tr("Size", "i.e: file size");
|
||||
case DLListDelegate::COLUMN_COMPLETED: return tr("Completed", "");
|
||||
case DLListDelegate::COLUMN_DLSPEED: return tr("Speed", "i.e: Download speed");
|
||||
case DLListDelegate::COLUMN_PROGRESS: return tr("Progress / Availability", "i.e: % downloaded");
|
||||
case DLListDelegate::COLUMN_SOURCES: return tr("Sources", "i.e: Sources");
|
||||
case DLListDelegate::COLUMN_STATUS: return tr("Status");
|
||||
case DLListDelegate::COLUMN_PRIORITY: return tr("Speed / Queue position");
|
||||
case DLListDelegate::COLUMN_REMAINING: return tr("Remaining");
|
||||
case DLListDelegate::COLUMN_DOWNLOADTIME: return tr("Download time", "i.e: Estimated Time of Arrival / Time left");
|
||||
case DLListDelegate::COLUMN_ID: return tr("Hash");
|
||||
case DLListDelegate::COLUMN_LASTDL: return tr("Last Time Seen", "i.e: Last Time Receiced Data");
|
||||
case DLListDelegate::COLUMN_PATH: return tr("Path", "i.e: Where file is saved");
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,19 +352,19 @@ public:
|
||||
switch(col)
|
||||
{
|
||||
default:
|
||||
case COLUMN_NAME: return QVariant( QSize(factor * 170, factor*14.0f ));
|
||||
case COLUMN_SIZE: return QVariant( QSize(factor * 70 , factor*14.0f ));
|
||||
case COLUMN_COMPLETED: return QVariant( QSize(factor * 75 , factor*14.0f ));
|
||||
case COLUMN_DLSPEED: return QVariant( QSize(factor * 75 , factor*14.0f ));
|
||||
case COLUMN_PROGRESS: return QVariant( QSize(factor * 170, factor*14.0f ));
|
||||
case COLUMN_SOURCES: return QVariant( QSize(factor * 90 , factor*14.0f ));
|
||||
case COLUMN_STATUS: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case COLUMN_PRIORITY: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case COLUMN_REMAINING: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case COLUMN_DOWNLOADTIME: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case COLUMN_ID: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case COLUMN_LASTDL: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case COLUMN_PATH: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_NAME: return QVariant( QSize(factor * 170, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_SIZE: return QVariant( QSize(factor * 70 , factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_COMPLETED: return QVariant( QSize(factor * 75 , factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_DLSPEED: return QVariant( QSize(factor * 75 , factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_PROGRESS: return QVariant( QSize(factor * 170, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_SOURCES: return QVariant( QSize(factor * 90 , factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_STATUS: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_PRIORITY: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_REMAINING: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_DOWNLOADTIME: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_ID: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_LASTDL: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
case DLListDelegate::COLUMN_PATH: return QVariant( QSize(factor * 100, factor*14.0f ));
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,11 +374,11 @@ public:
|
||||
if(source_id == -1) // toplevel
|
||||
switch(col)
|
||||
{
|
||||
case COLUMN_NAME: return QVariant(QString::fromUtf8(fileInfo.fname.c_str()));
|
||||
case COLUMN_COMPLETED: return QVariant((qlonglong)fileInfo.transfered);
|
||||
case COLUMN_DLSPEED: return QVariant((double)((fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0));
|
||||
case COLUMN_PROGRESS: return QVariant((float)((fileInfo.size == 0) ? 0 : (fileInfo.transfered * 100.0 / (float)fileInfo.size)));
|
||||
case COLUMN_STATUS:
|
||||
case DLListDelegate::COLUMN_NAME: return QVariant(QString::fromUtf8(fileInfo.fname.c_str()));
|
||||
case DLListDelegate::COLUMN_COMPLETED: return QVariant((qlonglong)fileInfo.transfered);
|
||||
case DLListDelegate::COLUMN_DLSPEED: return QVariant((double)((fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0));
|
||||
case DLListDelegate::COLUMN_PROGRESS: return QVariant((float)((fileInfo.size == 0) ? 0 : (fileInfo.transfered * 100.0 / (float)fileInfo.size)));
|
||||
case DLListDelegate::COLUMN_STATUS:
|
||||
{
|
||||
QString status;
|
||||
switch (fileInfo.downloadStatus)
|
||||
@ -396,9 +396,9 @@ public:
|
||||
return QVariant(status);
|
||||
}
|
||||
|
||||
case COLUMN_PRIORITY:
|
||||
case DLListDelegate::COLUMN_PRIORITY:
|
||||
{
|
||||
double priority = PRIORITY_NULL;
|
||||
double priority = DLListDelegate::PRIORITY_NULL;
|
||||
|
||||
if (fileInfo.downloadStatus == FT_STATE_QUEUED)
|
||||
priority = fileInfo.queue_position;
|
||||
@ -407,18 +407,18 @@ public:
|
||||
else
|
||||
switch (fileInfo.priority)
|
||||
{
|
||||
case SPEED_LOW: priority = PRIORITY_SLOWER; break;
|
||||
case SPEED_NORMAL: priority = PRIORITY_AVERAGE; break;
|
||||
case SPEED_HIGH: priority = PRIORITY_FASTER; break;
|
||||
default: priority = PRIORITY_AVERAGE; break;
|
||||
case SPEED_LOW: priority = DLListDelegate::PRIORITY_SLOWER; break;
|
||||
case SPEED_NORMAL: priority = DLListDelegate::PRIORITY_AVERAGE; break;
|
||||
case SPEED_HIGH: priority = DLListDelegate::PRIORITY_FASTER; break;
|
||||
default: priority = DLListDelegate::PRIORITY_AVERAGE; break;
|
||||
}
|
||||
|
||||
return QVariant(priority);
|
||||
}
|
||||
|
||||
case COLUMN_REMAINING: return QVariant((qlonglong)(fileInfo.size - fileInfo.transfered));
|
||||
case COLUMN_DOWNLOADTIME: return QVariant((qlonglong)(fileInfo.tfRate > 0)?( (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0) ) : 0);
|
||||
case COLUMN_LASTDL:
|
||||
case DLListDelegate::COLUMN_REMAINING: return QVariant((qlonglong)(fileInfo.size - fileInfo.transfered));
|
||||
case DLListDelegate::COLUMN_DOWNLOADTIME: return QVariant((qlonglong)(fileInfo.tfRate > 0)?( (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0) ) : 0);
|
||||
case DLListDelegate::COLUMN_LASTDL:
|
||||
{
|
||||
qint64 qi64LastDL = fileInfo.lastTS ;
|
||||
|
||||
@ -437,7 +437,7 @@ public:
|
||||
}
|
||||
return QVariant(qi64LastDL) ;
|
||||
}
|
||||
case COLUMN_PATH:
|
||||
case DLListDelegate::COLUMN_PATH:
|
||||
{
|
||||
QString strPath = QString::fromUtf8(fileInfo.path.c_str());
|
||||
QString strPathAfterDL = strPath;
|
||||
@ -446,7 +446,7 @@ public:
|
||||
return QVariant(strPathAfterDL);
|
||||
}
|
||||
|
||||
case COLUMN_SOURCES:
|
||||
case DLListDelegate::COLUMN_SOURCES:
|
||||
{
|
||||
int active = 0;
|
||||
//QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
|
||||
@ -478,9 +478,9 @@ public:
|
||||
|
||||
}
|
||||
|
||||
case COLUMN_SIZE: return QVariant((qlonglong) fileInfo.size);
|
||||
case DLListDelegate::COLUMN_SIZE: return QVariant((qlonglong) fileInfo.size);
|
||||
|
||||
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
|
||||
case DLListDelegate::COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
|
||||
|
||||
default:
|
||||
return QVariant("[ TODO ]");
|
||||
@ -492,16 +492,16 @@ public:
|
||||
switch(col)
|
||||
{
|
||||
default:
|
||||
case COLUMN_SOURCES:
|
||||
case COLUMN_COMPLETED:
|
||||
case COLUMN_REMAINING:
|
||||
case COLUMN_LASTDL:
|
||||
case COLUMN_ID:
|
||||
case COLUMN_PATH:
|
||||
case COLUMN_DOWNLOADTIME:
|
||||
case COLUMN_SIZE: return QVariant();
|
||||
case COLUMN_PROGRESS: return QVariant( (fileInfo.size>0)?((fileInfo.peers[source_id].transfered % chunk_size)*100.0/fileInfo.size):0.0) ;
|
||||
case COLUMN_DLSPEED:
|
||||
case DLListDelegate::COLUMN_SOURCES:
|
||||
case DLListDelegate::COLUMN_COMPLETED:
|
||||
case DLListDelegate::COLUMN_REMAINING:
|
||||
case DLListDelegate::COLUMN_LASTDL:
|
||||
case DLListDelegate::COLUMN_ID:
|
||||
case DLListDelegate::COLUMN_PATH:
|
||||
case DLListDelegate::COLUMN_DOWNLOADTIME:
|
||||
case DLListDelegate::COLUMN_SIZE: return QVariant();
|
||||
case DLListDelegate::COLUMN_PROGRESS: return QVariant( (fileInfo.size>0)?((fileInfo.peers[source_id].transfered % chunk_size)*100.0/fileInfo.size):0.0) ;
|
||||
case DLListDelegate::COLUMN_DLSPEED:
|
||||
{
|
||||
double peerDlspeed = 0;
|
||||
if((uint32_t)fileInfo.peers[source_id].status == FT_STATE_DOWNLOADING && fileInfo.downloadStatus != FT_STATE_PAUSED && fileInfo.downloadStatus != FT_STATE_COMPLETE)
|
||||
@ -509,13 +509,13 @@ public:
|
||||
|
||||
return QVariant((double)peerDlspeed) ;
|
||||
}
|
||||
case COLUMN_NAME:
|
||||
case DLListDelegate::COLUMN_NAME:
|
||||
{
|
||||
QString iconName,tooltip;
|
||||
return QVariant(TransfersDialog::getPeerName(fileInfo.peers[source_id].peerId, iconName, tooltip));
|
||||
}
|
||||
|
||||
case COLUMN_PRIORITY: return QVariant((double)PRIORITY_NULL);
|
||||
case DLListDelegate::COLUMN_PRIORITY: return QVariant((double)DLListDelegate::PRIORITY_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,7 +527,7 @@ public:
|
||||
if(source_id == -1)
|
||||
switch(col)
|
||||
{
|
||||
case COLUMN_PROGRESS:
|
||||
case DLListDelegate::COLUMN_PROGRESS:
|
||||
{
|
||||
FileChunksInfo fcinfo;
|
||||
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
|
||||
@ -554,7 +554,7 @@ public:
|
||||
return QVariant::fromValue(pinfo);
|
||||
}
|
||||
|
||||
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
|
||||
case DLListDelegate::COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
|
||||
|
||||
|
||||
default:
|
||||
@ -563,7 +563,7 @@ public:
|
||||
else
|
||||
switch(col)
|
||||
{
|
||||
case COLUMN_PROGRESS:
|
||||
case DLListDelegate::COLUMN_PROGRESS:
|
||||
{
|
||||
FileChunksInfo fcinfo;
|
||||
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
|
||||
@ -582,7 +582,7 @@ public:
|
||||
return QVariant::fromValue(pinfo);
|
||||
}
|
||||
|
||||
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()) + QString::fromStdString(fileInfo.peers[source_id].peerId.toStdString()));
|
||||
case DLListDelegate::COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()) + QString::fromStdString(fileInfo.peers[source_id].peerId.toStdString()));
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
@ -592,7 +592,7 @@ public:
|
||||
|
||||
QVariant decorationRole(const FileInfo& fileInfo,int source_id,int col) const
|
||||
{
|
||||
if(col == COLUMN_NAME)
|
||||
if(col == DLListDelegate::COLUMN_NAME)
|
||||
{
|
||||
if(source_id == -1)
|
||||
return QVariant(FilesDefs::getIconFromFileType(QString::fromUtf8(fileInfo.fname.c_str())));
|
||||
@ -666,7 +666,7 @@ public:
|
||||
|
||||
if(fileInfo.downloadStatus == FT_STATE_DOWNLOADING || old_status != fileInfo.downloadStatus)
|
||||
{
|
||||
QModelIndex topLeft = createIndex(i,0), bottomRight = createIndex(i, COLUMN_COUNT-1);
|
||||
QModelIndex topLeft = createIndex(i,0), bottomRight = createIndex(i, DLListDelegate::COLUMN_COUNT-1);
|
||||
emit dataChanged(topLeft, bottomRight);
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ public:
|
||||
//
|
||||
// if(!mDownloads.empty())
|
||||
// {
|
||||
// QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(mDownloads.size()-1, COLUMN_COUNT-1);
|
||||
// QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(mDownloads.size()-1, DLListDelegate::COLUMN_COUNT-1);
|
||||
// emit dataChanged(topLeft, bottomRight);
|
||||
// mDownloads[i] = fileInfo ;
|
||||
// }
|
||||
@ -761,8 +761,8 @@ public:
|
||||
return QStandardItem::operator<(other);
|
||||
}
|
||||
|
||||
QStandardItem *myName = myParent->child(index().row(), COLUMN_NAME);
|
||||
QStandardItem *otherName = otherParent->child(other.index().row(), COLUMN_NAME);
|
||||
QStandardItem *myName = myParent->child(index().row(), DLListDelegate::COLUMN_NAME);
|
||||
QStandardItem *otherName = otherParent->child(other.index().row(), DLListDelegate::COLUMN_NAME);
|
||||
|
||||
if (header == NULL || header->sortIndicatorOrder() == Qt::AscendingOrder) {
|
||||
/* Ascending */
|
||||
@ -847,41 +847,41 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||
|
||||
// /* Set header resize modes and initial section sizes Downloads TreeView*/
|
||||
QHeaderView * dlheader = ui.downloadList->header () ;
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_NAME, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_SIZE, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_COMPLETED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_DLSPEED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PROGRESS, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_SOURCES, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_STATUS, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PRIORITY, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_REMAINING, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_DOWNLOADTIME, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_ID, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_LASTDL, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PATH, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_NAME, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_SIZE, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_COMPLETED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_DLSPEED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_PROGRESS, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_SOURCES, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_STATUS, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_PRIORITY, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_REMAINING, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_DOWNLOADTIME, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_ID, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_LASTDL, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_PATH, QHeaderView::Interactive);
|
||||
|
||||
// set default column and sort order for download
|
||||
ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
|
||||
ui.downloadList->sortByColumn(DLListDelegate::COLUMN_NAME, Qt::AscendingOrder);
|
||||
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
/* Add filter actions */
|
||||
QString headerName = DLListModel->headerData(COLUMN_NAME, Qt::Horizontal).toString();
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerName, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerName));
|
||||
QString headerID = DLListModel->headerData(COLUMN_ID, Qt::Horizontal).toString();
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerID, COLUMN_ID , QString("%1 %2").arg(tr("Search"), headerID));
|
||||
QString headerName = DLListModel->headerData(DLListDelegate::COLUMN_NAME, Qt::Horizontal).toString();
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerName, DLListDelegate::COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerName));
|
||||
QString headerID = DLListModel->headerData(DLListDelegate::COLUMN_ID, Qt::Horizontal).toString();
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerID, DLListDelegate::COLUMN_ID , QString("%1 %2").arg(tr("Search"), headerID));
|
||||
|
||||
connect( ui.uploadsList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( uploadsListCustomPopupMenu( QPoint ) ) );
|
||||
|
||||
// Set Upload list model
|
||||
ULListModel = new QStandardItemModel(0,COLUMN_UCOUNT);
|
||||
ULListModel->setHeaderData(COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
||||
ULListModel->setHeaderData(COLUMN_UPEER, Qt::Horizontal, tr("Peer", "i.e: user name / tunnel id"));
|
||||
ULListModel->setHeaderData(COLUMN_USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
||||
ULListModel->setHeaderData(COLUMN_UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
|
||||
ULListModel->setHeaderData(COLUMN_ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
|
||||
ULListModel->setHeaderData(COLUMN_UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded"));
|
||||
ULListModel->setHeaderData(COLUMN_UHASH, Qt::Horizontal, tr("Hash", ""));
|
||||
ULListModel = new QStandardItemModel(0,ULListDelegate::COLUMN_UCOUNT);
|
||||
ULListModel->setHeaderData(ULListDelegate::COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
||||
ULListModel->setHeaderData(ULListDelegate::COLUMN_UPEER, Qt::Horizontal, tr("Peer", "i.e: user name / tunnel id"));
|
||||
ULListModel->setHeaderData(ULListDelegate::COLUMN_USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
||||
ULListModel->setHeaderData(ULListDelegate::COLUMN_UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
|
||||
ULListModel->setHeaderData(ULListDelegate::COLUMN_ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
|
||||
ULListModel->setHeaderData(ULListDelegate::COLUMN_UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded"));
|
||||
ULListModel->setHeaderData(ULListDelegate::COLUMN_UHASH, Qt::Horizontal, tr("Hash", ""));
|
||||
|
||||
ui.uploadsList->setModel(ULListModel);
|
||||
|
||||
@ -901,22 +901,22 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||
|
||||
/* Set header resize modes and initial section sizes Uploads TreeView*/
|
||||
QHeaderView * upheader = ui.uploadsList->header () ;
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UNAME, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UPEER, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_USIZE, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UTRANSFERRED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_ULSPEED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UPROGRESS, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UNAME, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UPEER, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_USIZE, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UTRANSFERRED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_ULSPEED, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UPROGRESS, QHeaderView::Interactive);
|
||||
|
||||
upheader->resizeSection ( COLUMN_UNAME, 260 );
|
||||
upheader->resizeSection ( COLUMN_UPEER, 120 );
|
||||
upheader->resizeSection ( COLUMN_USIZE, 70 );
|
||||
upheader->resizeSection ( COLUMN_UTRANSFERRED, 75 );
|
||||
upheader->resizeSection ( COLUMN_ULSPEED, 75 );
|
||||
upheader->resizeSection ( COLUMN_UPROGRESS, 170 );
|
||||
upheader->resizeSection ( ULListDelegate::COLUMN_UNAME, 260 );
|
||||
upheader->resizeSection ( ULListDelegate::COLUMN_UPEER, 120 );
|
||||
upheader->resizeSection ( ULListDelegate::COLUMN_USIZE, 70 );
|
||||
upheader->resizeSection ( ULListDelegate::COLUMN_UTRANSFERRED, 75 );
|
||||
upheader->resizeSection ( ULListDelegate::COLUMN_ULSPEED, 75 );
|
||||
upheader->resizeSection ( ULListDelegate::COLUMN_UPROGRESS, 170 );
|
||||
|
||||
// set default column and sort order for upload
|
||||
ui.uploadsList->sortByColumn(COLUMN_UNAME, Qt::AscendingOrder);
|
||||
ui.uploadsList->sortByColumn(ULListDelegate::COLUMN_UNAME, Qt::AscendingOrder);
|
||||
|
||||
QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ;
|
||||
|
||||
@ -1174,18 +1174,18 @@ void TransfersDialog::processSettings(bool bLoad)
|
||||
// state of splitter
|
||||
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
|
||||
|
||||
setShowDLSizeColumn(Settings->value("showDLSizeColumn", !ui.downloadList->isColumnHidden(COLUMN_SIZE)).toBool());
|
||||
setShowDLCompleteColumn(Settings->value("showDLCompleteColumn", !ui.downloadList->isColumnHidden(COLUMN_COMPLETED)).toBool());
|
||||
setShowDLDLSpeedColumn(Settings->value("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(COLUMN_DLSPEED)).toBool());
|
||||
setShowDLProgressColumn(Settings->value("showDLProgressColumn", !ui.downloadList->isColumnHidden(COLUMN_PROGRESS)).toBool());
|
||||
setShowDLSourcesColumn(Settings->value("showDLSourcesColumn", !ui.downloadList->isColumnHidden(COLUMN_SOURCES)).toBool());
|
||||
setShowDLStatusColumn(Settings->value("showDLStatusColumn", !ui.downloadList->isColumnHidden(COLUMN_STATUS)).toBool());
|
||||
setShowDLPriorityColumn(Settings->value("showDLPriorityColumn", !ui.downloadList->isColumnHidden(COLUMN_PRIORITY)).toBool());
|
||||
setShowDLRemainingColumn(Settings->value("showDLRemainingColumn", !ui.downloadList->isColumnHidden(COLUMN_REMAINING)).toBool());
|
||||
setShowDLDownloadTimeColumn(Settings->value("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(COLUMN_DOWNLOADTIME)).toBool());
|
||||
setShowDLIDColumn(Settings->value("showDLIDColumn", !ui.downloadList->isColumnHidden(COLUMN_ID)).toBool());
|
||||
setShowDLLastDLColumn(Settings->value("showDLLastDLColumn", !ui.downloadList->isColumnHidden(COLUMN_LASTDL)).toBool());
|
||||
setShowDLPath(Settings->value("showDLPath", !ui.downloadList->isColumnHidden(COLUMN_PATH)).toBool());
|
||||
setShowDLSizeColumn(Settings->value("showDLSizeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SIZE)).toBool());
|
||||
setShowDLCompleteColumn(Settings->value("showDLCompleteColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_COMPLETED)).toBool());
|
||||
setShowDLDLSpeedColumn(Settings->value("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DLSPEED)).toBool());
|
||||
setShowDLProgressColumn(Settings->value("showDLProgressColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PROGRESS)).toBool());
|
||||
setShowDLSourcesColumn(Settings->value("showDLSourcesColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SOURCES)).toBool());
|
||||
setShowDLStatusColumn(Settings->value("showDLStatusColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_STATUS)).toBool());
|
||||
setShowDLPriorityColumn(Settings->value("showDLPriorityColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PRIORITY)).toBool());
|
||||
setShowDLRemainingColumn(Settings->value("showDLRemainingColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_REMAINING)).toBool());
|
||||
setShowDLDownloadTimeColumn(Settings->value("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME)).toBool());
|
||||
setShowDLIDColumn(Settings->value("showDLIDColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_ID)).toBool());
|
||||
setShowDLLastDLColumn(Settings->value("showDLLastDLColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_LASTDL)).toBool());
|
||||
setShowDLPath(Settings->value("showDLPath", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PATH)).toBool());
|
||||
|
||||
// selected tab
|
||||
ui.tabWidget->setCurrentIndex(Settings->value("selectedTab").toInt());
|
||||
@ -1199,18 +1199,18 @@ void TransfersDialog::processSettings(bool bLoad)
|
||||
// state of splitter
|
||||
Settings->setValue("Splitter", ui.splitter->saveState());
|
||||
|
||||
Settings->setValue("showDLSizeColumn", !ui.downloadList->isColumnHidden(COLUMN_SIZE));
|
||||
Settings->setValue("showDLCompleteColumn", !ui.downloadList->isColumnHidden(COLUMN_COMPLETED));
|
||||
Settings->setValue("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(COLUMN_DLSPEED));
|
||||
Settings->setValue("showDLProgressColumn", !ui.downloadList->isColumnHidden(COLUMN_PROGRESS));
|
||||
Settings->setValue("showDLSourcesColumn", !ui.downloadList->isColumnHidden(COLUMN_SOURCES));
|
||||
Settings->setValue("showDLStatusColumn", !ui.downloadList->isColumnHidden(COLUMN_STATUS));
|
||||
Settings->setValue("showDLPriorityColumn", !ui.downloadList->isColumnHidden(COLUMN_PRIORITY));
|
||||
Settings->setValue("showDLRemainingColumn", !ui.downloadList->isColumnHidden(COLUMN_REMAINING));
|
||||
Settings->setValue("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(COLUMN_DOWNLOADTIME));
|
||||
Settings->setValue("showDLIDColumn", !ui.downloadList->isColumnHidden(COLUMN_ID));
|
||||
Settings->setValue("showDLLastDLColumn", !ui.downloadList->isColumnHidden(COLUMN_LASTDL));
|
||||
Settings->setValue("showDLPath", !ui.downloadList->isColumnHidden(COLUMN_PATH));
|
||||
Settings->setValue("showDLSizeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SIZE));
|
||||
Settings->setValue("showDLCompleteColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_COMPLETED));
|
||||
Settings->setValue("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DLSPEED));
|
||||
Settings->setValue("showDLProgressColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PROGRESS));
|
||||
Settings->setValue("showDLSourcesColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SOURCES));
|
||||
Settings->setValue("showDLStatusColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_STATUS));
|
||||
Settings->setValue("showDLPriorityColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PRIORITY));
|
||||
Settings->setValue("showDLRemainingColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_REMAINING));
|
||||
Settings->setValue("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME));
|
||||
Settings->setValue("showDLIDColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_ID));
|
||||
Settings->setValue("showDLLastDLColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_LASTDL));
|
||||
Settings->setValue("showDLPath", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PATH));
|
||||
|
||||
// selected tab
|
||||
Settings->setValue("selectedTab", ui.tabWidget->currentIndex());
|
||||
@ -1423,18 +1423,18 @@ void TransfersDialog::downloadListHeaderCustomPopupMenu( QPoint /*point*/ )
|
||||
std::cerr << "TransfersDialog::downloadListHeaderCustomPopupMenu()" << std::endl;
|
||||
QMenu contextMnu( this );
|
||||
|
||||
showDLSizeAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_SIZE));
|
||||
showDLCompleteAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_COMPLETED));
|
||||
showDLDLSpeedAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_DLSPEED));
|
||||
showDLProgressAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_PROGRESS));
|
||||
showDLSourcesAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_SOURCES));
|
||||
showDLStatusAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_STATUS));
|
||||
showDLPriorityAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_PRIORITY));
|
||||
showDLRemainingAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_REMAINING));
|
||||
showDLDownloadTimeAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_DOWNLOADTIME));
|
||||
showDLIDAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_ID));
|
||||
showDLLastDLAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_LASTDL));
|
||||
showDLPath->setChecked(!ui.downloadList->isColumnHidden(COLUMN_PATH));
|
||||
showDLSizeAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SIZE));
|
||||
showDLCompleteAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_COMPLETED));
|
||||
showDLDLSpeedAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DLSPEED));
|
||||
showDLProgressAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PROGRESS));
|
||||
showDLSourcesAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SOURCES));
|
||||
showDLStatusAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_STATUS));
|
||||
showDLPriorityAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PRIORITY));
|
||||
showDLRemainingAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_REMAINING));
|
||||
showDLDownloadTimeAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME));
|
||||
showDLIDAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_ID));
|
||||
showDLLastDLAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_LASTDL));
|
||||
showDLPath->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PATH));
|
||||
|
||||
QMenu *menu = contextMnu.addMenu(tr("Columns"));
|
||||
menu->addAction(showDLSizeAct);
|
||||
@ -1486,12 +1486,12 @@ void TransfersDialog::uploadsListHeaderCustomPopupMenu( QPoint /*point*/ )
|
||||
std::cerr << "TransfersDialog::uploadsListHeaderCustomPopupMenu()" << std::endl;
|
||||
QMenu contextMnu( this );
|
||||
|
||||
showULPeerAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPEER));
|
||||
showULSizeAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_USIZE));
|
||||
showULTransferredAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UTRANSFERRED));
|
||||
showULSpeedAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_ULSPEED));
|
||||
showULProgressAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPROGRESS));
|
||||
showULHashAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UHASH));
|
||||
showULPeerAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UPEER));
|
||||
showULSizeAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_USIZE));
|
||||
showULTransferredAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UTRANSFERRED));
|
||||
showULSpeedAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_ULSPEED));
|
||||
showULProgressAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UPROGRESS));
|
||||
showULHashAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UHASH));
|
||||
|
||||
QMenu *menu = contextMnu.addMenu(tr("Columns"));
|
||||
menu->addAction(showULPeerAct);
|
||||
@ -1554,20 +1554,20 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
||||
// change progress column to own class for sorting
|
||||
//ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL));
|
||||
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), fileName);
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), FilesDefs::getIconFromFileType(fileName), Qt::DecorationRole);
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash);
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash, Qt::UserRole);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UNAME), fileName);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UNAME), FilesDefs::getIconFromFileType(fileName), Qt::DecorationRole);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UHASH), fileHash);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UHASH), fileHash, Qt::UserRole);
|
||||
}
|
||||
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize));
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_USIZE), QVariant((qlonglong)fileSize));
|
||||
|
||||
//Reset Parent info if child present
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(QString(tr("%1 tunnels").arg(fileInfo.peers.size()))) );
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QIcon(), Qt::DecorationRole);
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(), Qt::ToolTipRole);
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant());
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant());
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(QString(tr("%1 tunnels").arg(fileInfo.peers.size()))) );
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QIcon(), Qt::DecorationRole);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(), Qt::ToolTipRole);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UTRANSFERRED), QVariant());
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPROGRESS), QVariant());
|
||||
|
||||
QStandardItem *ulItem = ULListModel->item(row);
|
||||
std::set<int> used_rows ;
|
||||
@ -1617,11 +1617,11 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
||||
//Only one peer so update parent
|
||||
QString iconName;
|
||||
QString tooltip;
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(getPeerName(transferInfo.peerId, iconName, tooltip)));
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QIcon(iconName), Qt::DecorationRole);
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(tooltip), Qt::ToolTipRole);
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant(completed));
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant::fromValue(peerpinfo));
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(getPeerName(transferInfo.peerId, iconName, tooltip)));
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QIcon(iconName), Qt::DecorationRole);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(tooltip), Qt::ToolTipRole);
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UTRANSFERRED), QVariant(completed));
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPROGRESS), QVariant::fromValue(peerpinfo));
|
||||
} else {
|
||||
int row_id = addPeerToULItem(ulItem, transferInfo.peerId, hashFileAndPeerId, completed, peerULSpeed, peerpinfo);
|
||||
|
||||
@ -1632,7 +1632,7 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
||||
}
|
||||
|
||||
// Update Parent UpLoad Speed
|
||||
ULListModel->setData(ULListModel->index(row, COLUMN_ULSPEED), QVariant((double)peerULSpeedTotal));
|
||||
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_ULSPEED), QVariant((double)peerULSpeedTotal));
|
||||
|
||||
|
||||
// This is not optimal, but we deal with a small number of elements. The reverse order is really important,
|
||||
@ -1653,7 +1653,7 @@ int TransfersDialog::addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer
|
||||
int childRow = -1;
|
||||
|
||||
QStandardItem *childId = NULL;
|
||||
for (int count = 0; (childId = ulItem->child(count, COLUMN_UHASH)) != NULL; ++count) {
|
||||
for (int count = 0; (childId = ulItem->child(count, ULListDelegate::COLUMN_UHASH)) != NULL; ++count) {
|
||||
if (childId->data(Qt::UserRole).toString() == coreID) {
|
||||
childRow = count;
|
||||
break;
|
||||
@ -1700,9 +1700,9 @@ int TransfersDialog::addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer
|
||||
childRow = ulItem->rowCount() - 1;
|
||||
} else {
|
||||
// just update the child (peer)
|
||||
ulItem->child(childRow, COLUMN_ULSPEED)->setData(QVariant((double)ulspeed), Qt::DisplayRole);
|
||||
ulItem->child(childRow, COLUMN_UTRANSFERRED)->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
||||
ulItem->child(childRow, COLUMN_UPROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
|
||||
ulItem->child(childRow, ULListDelegate::COLUMN_ULSPEED)->setData(QVariant((double)ulspeed), Qt::DisplayRole);
|
||||
ulItem->child(childRow, ULListDelegate::COLUMN_UTRANSFERRED)->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
||||
ulItem->child(childRow, ULListDelegate::COLUMN_UPROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
|
||||
}
|
||||
|
||||
return childRow;
|
||||
@ -1743,7 +1743,7 @@ void TransfersDialog::insertTransfers()
|
||||
int rowCount = ULListModel->rowCount();
|
||||
|
||||
for (int row = 0; row < rowCount; ) {
|
||||
RsFileHash hash ( ULListModel->item(row, COLUMN_UHASH)->data(Qt::UserRole).toString().toStdString());
|
||||
RsFileHash hash ( ULListModel->item(row, ULListDelegate::COLUMN_UHASH)->data(Qt::UserRole).toString().toStdString());
|
||||
|
||||
std::set<RsFileHash>::iterator hashIt = hashs.find(hash);
|
||||
if (hashIt == hashs.end()) {
|
||||
@ -1976,13 +1976,13 @@ void TransfersDialog::getDLSelectedItems(std::set<RsFileHash> *ids, std::set<int
|
||||
if (ids) ids->clear();
|
||||
if (rows) rows->clear();
|
||||
|
||||
QModelIndexList selectedRows = selection->selectedRows(COLUMN_ID);
|
||||
QModelIndexList selectedRows = selection->selectedRows(DLListDelegate::COLUMN_ID);
|
||||
|
||||
int i, imax = selectedRows.count();
|
||||
for (i = 0; i < imax; ++i) {
|
||||
QModelIndex index = selectedRows.at(i);
|
||||
if (index.parent().isValid() && index.model())
|
||||
index = index.model()->index(index.parent().row(), COLUMN_ID);
|
||||
index = index.model()->index(index.parent().row(), DLListDelegate::COLUMN_ID);
|
||||
|
||||
if (ids) {
|
||||
ids->insert(RsFileHash(index.data(Qt::DisplayRole).toString().toStdString()));
|
||||
@ -2010,7 +2010,7 @@ void TransfersDialog::getULSelectedItems(std::set<RsFileHash> *ids, std::set<int
|
||||
|
||||
foreach(index, indexes) {
|
||||
if (ids) {
|
||||
QStandardItem *id = ULListModel->item(index.row(), COLUMN_UHASH);
|
||||
QStandardItem *id = ULListModel->item(index.row(), ULListDelegate::COLUMN_UHASH);
|
||||
ids->insert(RsFileHash(id->data(Qt::DisplayRole).toString().toStdString()));
|
||||
}
|
||||
if (rows) {
|
||||
@ -2383,72 +2383,72 @@ return 0.0 ;
|
||||
|
||||
double TransfersDialog::getSpeed(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_DLSPEED), Qt::DisplayRole).toDouble();
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_DLSPEED), Qt::DisplayRole).toDouble();
|
||||
}
|
||||
|
||||
QString TransfersDialog::getFileName(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_NAME), Qt::DisplayRole).toString();
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_NAME), Qt::DisplayRole).toString();
|
||||
}
|
||||
|
||||
QString TransfersDialog::getStatus(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_STATUS), Qt::DisplayRole).toString();
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_STATUS), Qt::DisplayRole).toString();
|
||||
}
|
||||
|
||||
QString TransfersDialog::getID(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_ID), Qt::UserRole).toString().left(40); // gets only the "hash" part of the name
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_ID), Qt::UserRole).toString().left(40); // gets only the "hash" part of the name
|
||||
}
|
||||
|
||||
QString TransfersDialog::getID(int row, QSortFilterProxyModel *filter)
|
||||
{
|
||||
QModelIndex index = filter->mapToSource(filter->index(row, COLUMN_ID));
|
||||
QModelIndex index = filter->mapToSource(filter->index(row, DLListDelegate::COLUMN_ID));
|
||||
|
||||
return filter->sourceModel()->data(index, Qt::UserRole).toString().left(40); // gets only the "hash" part of the name
|
||||
}
|
||||
|
||||
QString TransfersDialog::getPriority(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_PRIORITY), Qt::DisplayRole).toString();
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_PRIORITY), Qt::DisplayRole).toString();
|
||||
}
|
||||
|
||||
qlonglong TransfersDialog::getFileSize(int row, QStandardItemModel *model)
|
||||
{
|
||||
bool ok = false;
|
||||
return model->data(model->index(row, COLUMN_SIZE), Qt::DisplayRole).toULongLong(&ok);
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_SIZE), Qt::DisplayRole).toULongLong(&ok);
|
||||
}
|
||||
|
||||
qlonglong TransfersDialog::getTransfered(int row, QStandardItemModel *model)
|
||||
{
|
||||
bool ok = false;
|
||||
return model->data(model->index(row, COLUMN_COMPLETED), Qt::DisplayRole).toULongLong(&ok);
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_COMPLETED), Qt::DisplayRole).toULongLong(&ok);
|
||||
}
|
||||
|
||||
qlonglong TransfersDialog::getRemainingTime(int row, QStandardItemModel *model)
|
||||
{
|
||||
bool ok = false;
|
||||
return model->data(model->index(row, COLUMN_REMAINING), Qt::DisplayRole).toULongLong(&ok);
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_REMAINING), Qt::DisplayRole).toULongLong(&ok);
|
||||
}
|
||||
|
||||
qlonglong TransfersDialog::getDownloadTime(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_DOWNLOADTIME), Qt::DisplayRole).toULongLong();
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_DOWNLOADTIME), Qt::DisplayRole).toULongLong();
|
||||
}
|
||||
|
||||
qlonglong TransfersDialog::getLastDL(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_LASTDL), Qt::DisplayRole).toULongLong();
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_LASTDL), Qt::DisplayRole).toULongLong();
|
||||
}
|
||||
|
||||
qlonglong TransfersDialog::getPath(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, COLUMN_PATH), Qt::DisplayRole).toULongLong();
|
||||
return model->data(model->index(row, DLListDelegate::COLUMN_PATH), Qt::DisplayRole).toULongLong();
|
||||
}
|
||||
|
||||
QString TransfersDialog::getSources(int row, QStandardItemModel *model)
|
||||
{
|
||||
double dblValue = model->data(model->index(row, COLUMN_SOURCES), Qt::DisplayRole).toDouble();
|
||||
double dblValue = model->data(model->index(row, DLListDelegate::COLUMN_SOURCES), Qt::DisplayRole).toDouble();
|
||||
QString temp = QString("%1 (%2)").arg((int)dblValue).arg((int)((fmod(dblValue,1)*1000)+0.5));
|
||||
|
||||
return temp;
|
||||
@ -2608,25 +2608,25 @@ void TransfersDialog::collAutoOpen(const QString &fileHash)
|
||||
}
|
||||
}
|
||||
|
||||
void TransfersDialog::setShowDLSizeColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_SIZE, !show); }
|
||||
void TransfersDialog::setShowDLCompleteColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_COMPLETED, !show); }
|
||||
void TransfersDialog::setShowDLDLSpeedColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_DLSPEED, !show); }
|
||||
void TransfersDialog::setShowDLProgressColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_PROGRESS, !show); }
|
||||
void TransfersDialog::setShowDLSourcesColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_SOURCES, !show); }
|
||||
void TransfersDialog::setShowDLStatusColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_STATUS, !show); }
|
||||
void TransfersDialog::setShowDLPriorityColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_PRIORITY, !show); }
|
||||
void TransfersDialog::setShowDLRemainingColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_REMAINING, !show); }
|
||||
void TransfersDialog::setShowDLDownloadTimeColumn(bool show) { ui.downloadList->setColumnHidden(COLUMN_DOWNLOADTIME, !show); }
|
||||
void TransfersDialog::setShowDLIDColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_ID, !show); }
|
||||
void TransfersDialog::setShowDLLastDLColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_LASTDL, !show); }
|
||||
void TransfersDialog::setShowDLPath (bool show) { ui.downloadList->setColumnHidden(COLUMN_PATH, !show); }
|
||||
void TransfersDialog::setShowDLSizeColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_SIZE, !show); }
|
||||
void TransfersDialog::setShowDLCompleteColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_COMPLETED, !show); }
|
||||
void TransfersDialog::setShowDLDLSpeedColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_DLSPEED, !show); }
|
||||
void TransfersDialog::setShowDLProgressColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_PROGRESS, !show); }
|
||||
void TransfersDialog::setShowDLSourcesColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_SOURCES, !show); }
|
||||
void TransfersDialog::setShowDLStatusColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_STATUS, !show); }
|
||||
void TransfersDialog::setShowDLPriorityColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_PRIORITY, !show); }
|
||||
void TransfersDialog::setShowDLRemainingColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_REMAINING, !show); }
|
||||
void TransfersDialog::setShowDLDownloadTimeColumn(bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME, !show); }
|
||||
void TransfersDialog::setShowDLIDColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_ID, !show); }
|
||||
void TransfersDialog::setShowDLLastDLColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_LASTDL, !show); }
|
||||
void TransfersDialog::setShowDLPath (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_PATH, !show); }
|
||||
|
||||
void TransfersDialog::setShowULPeerColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPEER, !show); }
|
||||
void TransfersDialog::setShowULSizeColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_USIZE, !show); }
|
||||
void TransfersDialog::setShowULTransferredColumn(bool show) { ui.uploadsList->setColumnHidden(COLUMN_UTRANSFERRED, !show); }
|
||||
void TransfersDialog::setShowULSpeedColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_ULSPEED, !show); }
|
||||
void TransfersDialog::setShowULProgressColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPROGRESS, !show); }
|
||||
void TransfersDialog::setShowULHashColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UHASH, !show); }
|
||||
void TransfersDialog::setShowULPeerColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UPEER, !show); }
|
||||
void TransfersDialog::setShowULSizeColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_USIZE, !show); }
|
||||
void TransfersDialog::setShowULTransferredColumn(bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UTRANSFERRED, !show); }
|
||||
void TransfersDialog::setShowULSpeedColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_ULSPEED, !show); }
|
||||
void TransfersDialog::setShowULProgressColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UPROGRESS, !show); }
|
||||
void TransfersDialog::setShowULHashColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UHASH, !show); }
|
||||
|
||||
void TransfersDialog::expandAllDL()
|
||||
{
|
||||
|
@ -25,14 +25,14 @@
|
||||
|
||||
Q_DECLARE_METATYPE(FileProgressInfo)
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
ULListDelegate::ULListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
ULListDelegate::~ULListDelegate(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||
@ -65,7 +65,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
|
||||
// draw the background color
|
||||
bool bDrawBackground = true;
|
||||
if(index.column() == COLUMN_UPROGRESS) {
|
||||
if(index.column() == COLUMN_UPROGRESS) {
|
||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||
bDrawBackground = (pinfo.type == FileProgressInfo::UNINIT);
|
||||
}
|
||||
@ -133,7 +133,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_UPROGRESS:
|
||||
case COLUMN_UPROGRESS:
|
||||
{
|
||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||
if (pinfo.type == FileProgressInfo::UNINIT)
|
||||
@ -143,7 +143,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
painter->save() ;
|
||||
xProgressBar progressBar(pinfo,option.rect,painter,0);// the 3rd param is the color schema (0 is the default value)
|
||||
|
||||
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), COLUMN_UNAME).data().toString().toStdString())).suffix();;
|
||||
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), COLUMN_UNAME).data().toString().toStdString())).suffix();;
|
||||
if (ext == "rsfc" || ext == "rsrl" || ext == "dist" || ext == "rsfb")
|
||||
progressBar.setColorSchema( 9);
|
||||
else
|
||||
@ -157,8 +157,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
break;
|
||||
case COLUMN_UNAME:
|
||||
case COLUMN_UPEER:
|
||||
case COLUMN_UNAME:
|
||||
case COLUMN_UPEER:
|
||||
// decoration
|
||||
value = index.data(Qt::DecorationRole);
|
||||
pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);
|
||||
|
@ -18,43 +18,27 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef ULLISTDELEGATE_H
|
||||
#define ULLISTDELEGATE_H
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
|
||||
// Defines for upload list list columns
|
||||
#define COLUMN_UNAME 0
|
||||
#define COLUMN_UPEER 1
|
||||
#define COLUMN_USIZE 2
|
||||
#define COLUMN_UTRANSFERRED 3
|
||||
#define COLUMN_ULSPEED 4
|
||||
#define COLUMN_UPROGRESS 5
|
||||
#define COLUMN_UHASH 6
|
||||
#define COLUMN_UCOUNT 7
|
||||
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
class QModelIndex;
|
||||
class QPainter;
|
||||
|
||||
class ULListDelegate: public QAbstractItemDelegate
|
||||
{
|
||||
public:
|
||||
ULListDelegate(QObject *parent=0);
|
||||
~ULListDelegate();
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
|
||||
class ULListDelegate: public QAbstractItemDelegate {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ULListDelegate(QObject *parent=0);
|
||||
~ULListDelegate();
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
|
||||
private:
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
static constexpr int COLUMN_UNAME = 0;
|
||||
static constexpr int COLUMN_UPEER = 1;
|
||||
static constexpr int COLUMN_USIZE = 2;
|
||||
static constexpr int COLUMN_UTRANSFERRED = 3;
|
||||
static constexpr int COLUMN_ULSPEED = 4;
|
||||
static constexpr int COLUMN_UPROGRESS = 5;
|
||||
static constexpr int COLUMN_UHASH = 6;
|
||||
static constexpr int COLUMN_UCOUNT = 7;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -466,10 +466,8 @@ void MainWindow::initStackedPage()
|
||||
}
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
#ifdef PLUGINMGR
|
||||
addPage(pluginsPage = new gui::PluginsPage(ui->stackPages), grp, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef GETSTARTED_GUI
|
||||
#ifdef GETSTARTED_GUI
|
||||
|
@ -73,7 +73,7 @@ NetworkDialog::NetworkDialog(QWidget */*parent*/)
|
||||
PGPIdItemProxy = new pgpid_item_proxy(this);
|
||||
connect(ui.onlyTrustedKeys, SIGNAL(toggled(bool)), PGPIdItemProxy, SLOT(use_only_trusted_keys(bool)));
|
||||
PGPIdItemProxy->setSourceModel(PGPIdItemModel);
|
||||
PGPIdItemProxy->setFilterKeyColumn(COLUMN_PEERNAME);
|
||||
PGPIdItemProxy->setFilterKeyColumn(pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERNAME);
|
||||
PGPIdItemProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
PGPIdItemProxy->setSortRole(Qt::EditRole); //use edit role to get raw data since we do not have edit for this model.
|
||||
ui.connectTreeWidget->setModel(PGPIdItemProxy);
|
||||
@ -90,9 +90,9 @@ NetworkDialog::NetworkDialog(QWidget */*parent*/)
|
||||
ui.onlyTrustedKeys->setMinimumWidth(20*f);
|
||||
|
||||
/* add filter actions */
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Name"), COLUMN_PEERNAME, tr("Search name"));
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), COLUMN_PEERID, tr("Search peer ID"));
|
||||
ui.filterLineEdit->setCurrentFilter(COLUMN_PEERNAME);
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Name"), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERNAME, tr("Search name"));
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID, tr("Search peer ID"));
|
||||
ui.filterLineEdit->setCurrentFilter(pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERNAME);
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), PGPIdItemProxy, SLOT(setFilterWildcard(QString)));
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
|
||||
QMenu *contextMnu = new QMenu;
|
||||
|
||||
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
|
||||
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()) ;
|
||||
|
||||
// That's what context menus are made for
|
||||
RsPeerDetails detail;
|
||||
@ -179,7 +179,7 @@ void NetworkDialog::removeSelectedKeys()
|
||||
return;
|
||||
|
||||
std::set<RsPgpId> selected;
|
||||
selected.insert(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()));
|
||||
selected.insert(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()));
|
||||
|
||||
removeKeys(selected);
|
||||
}
|
||||
@ -228,7 +228,7 @@ void NetworkDialog::denyFriend()
|
||||
if(l.empty())
|
||||
return;
|
||||
|
||||
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString());
|
||||
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString());
|
||||
rsPeers->removeFriend(peer_id) ;
|
||||
|
||||
securedUpdateDisplay();
|
||||
@ -241,7 +241,7 @@ void NetworkDialog::makeFriend()
|
||||
if(l.empty())
|
||||
return;
|
||||
|
||||
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
|
||||
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
|
||||
}
|
||||
|
||||
/** Shows Peer Information/Auth Dialog */
|
||||
@ -251,7 +251,7 @@ void NetworkDialog::peerdetails()
|
||||
if(l.empty())
|
||||
return;
|
||||
|
||||
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
|
||||
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
|
||||
}
|
||||
|
||||
void NetworkDialog::copyLink()
|
||||
@ -261,7 +261,7 @@ void NetworkDialog::copyLink()
|
||||
return;
|
||||
|
||||
|
||||
RsPgpId peer_id (ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
|
||||
RsPgpId peer_id (ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()) ;
|
||||
|
||||
QList<RetroShareLink> urls;
|
||||
RetroShareLink link = RetroShareLink::createPerson(peer_id);
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include <QIcon>
|
||||
#include <QBrush>
|
||||
|
||||
#define IMAGE_AUTHED ":/images/accepted16.png"
|
||||
#define IMAGE_DENIED ":/images/denied16.png"
|
||||
#define IMAGE_TRUSTED ":/images/rs-2.png"
|
||||
|
||||
/*TODO:
|
||||
* using list here for internal data storage is not best option
|
||||
@ -41,22 +44,22 @@ QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation,
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case COLUMN_CHECK:
|
||||
case PGP_ITEM_MODEL_COLUMN_CHECK:
|
||||
return QString(tr(" Do you accept connections signed by this profile?"));
|
||||
break;
|
||||
case COLUMN_PEERNAME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEERNAME:
|
||||
return QString(tr("Name of the profile"));
|
||||
break;
|
||||
case COLUMN_I_AUTH_PEER:
|
||||
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
|
||||
return QString(tr("This column indicates the trust level you indicated and whether you signed the profile PGP key"));
|
||||
break;
|
||||
case COLUMN_PEER_AUTH_ME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
|
||||
return QString(tr("Did that peer sign your own profile PGP key"));
|
||||
break;
|
||||
case COLUMN_PEERID:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEERID:
|
||||
return QString(tr("PGP Key Id of that profile"));
|
||||
break;
|
||||
case COLUMN_LAST_USED:
|
||||
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
|
||||
return QString(tr("Last time this key was used (received time, or to check connection)"));
|
||||
break;
|
||||
}
|
||||
@ -65,22 +68,22 @@ QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation,
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case COLUMN_CHECK:
|
||||
case PGP_ITEM_MODEL_COLUMN_CHECK:
|
||||
return QString(tr("Connections"));
|
||||
break;
|
||||
case COLUMN_PEERNAME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEERNAME:
|
||||
return QString(tr("Profile"));
|
||||
break;
|
||||
case COLUMN_I_AUTH_PEER:
|
||||
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
|
||||
return QString(tr("Trust level"));
|
||||
break;
|
||||
case COLUMN_PEER_AUTH_ME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
|
||||
return QString(tr("Has signed your key?"));
|
||||
break;
|
||||
case COLUMN_PEERID:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEERID:
|
||||
return QString(tr("Id"));
|
||||
break;
|
||||
case COLUMN_LAST_USED:
|
||||
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
|
||||
return QString(tr("Last used"));
|
||||
break;
|
||||
}
|
||||
@ -98,13 +101,13 @@ QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation,
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case COLUMN_CHECK:
|
||||
case PGP_ITEM_MODEL_COLUMN_CHECK:
|
||||
return 25*font_height;
|
||||
break;
|
||||
case COLUMN_PEERNAME: case COLUMN_I_AUTH_PEER: case COLUMN_PEER_AUTH_ME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEERNAME: case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER: case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
|
||||
return 200*font_height;
|
||||
break;
|
||||
case COLUMN_LAST_USED:
|
||||
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
|
||||
return 75*font_height;
|
||||
break;
|
||||
}
|
||||
@ -122,7 +125,7 @@ int pgpid_item_model::rowCount(const QModelIndex &/*parent*/) const
|
||||
|
||||
int pgpid_item_model::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_COUNT;
|
||||
return PGP_ITEM_MODEL_COLUMN_COUNT;
|
||||
}
|
||||
|
||||
|
||||
@ -148,20 +151,20 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case COLUMN_LAST_USED:
|
||||
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
|
||||
return detail.lastUsed;
|
||||
break;
|
||||
case COLUMN_I_AUTH_PEER:
|
||||
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
|
||||
{
|
||||
if (detail.ownsign)
|
||||
return RS_TRUST_LVL_ULTIMATE;
|
||||
return detail.trustLvl;
|
||||
}
|
||||
break;
|
||||
case COLUMN_PEER_AUTH_ME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
|
||||
return detail.hasSignedMe;
|
||||
break;
|
||||
case COLUMN_CHECK:
|
||||
case PGP_ITEM_MODEL_COLUMN_CHECK:
|
||||
return detail.accept_connection;
|
||||
break;
|
||||
default:
|
||||
@ -174,13 +177,13 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case COLUMN_PEERNAME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEERNAME:
|
||||
return QString::fromUtf8(detail.name.c_str());
|
||||
break;
|
||||
case COLUMN_PEERID:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEERID:
|
||||
return QString::fromStdString(detail.gpg_id.toStdString());
|
||||
break;
|
||||
case COLUMN_I_AUTH_PEER:
|
||||
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
|
||||
{
|
||||
if (detail.ownsign)
|
||||
return tr("Personal signature");
|
||||
@ -199,7 +202,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COLUMN_PEER_AUTH_ME:
|
||||
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
|
||||
{
|
||||
if (detail.hasSignedMe)
|
||||
return tr("Yes");
|
||||
@ -207,7 +210,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
return tr("No");
|
||||
}
|
||||
break;
|
||||
case COLUMN_LAST_USED:
|
||||
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
uint64_t last_time_used = now - detail.lastUsed ;
|
||||
@ -226,7 +229,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
return lst_used_str;
|
||||
}
|
||||
break;
|
||||
case COLUMN_CHECK:
|
||||
case PGP_ITEM_MODEL_COLUMN_CHECK:
|
||||
{
|
||||
if (detail.accept_connection || rsPeers->getGPGOwnId() == detail.gpg_id)
|
||||
return tr("Accepted");
|
||||
@ -242,7 +245,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case COLUMN_I_AUTH_PEER:
|
||||
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
|
||||
{
|
||||
if (detail.ownsign)
|
||||
return tr("PGP key signed by you");
|
||||
@ -263,7 +266,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case COLUMN_CHECK:
|
||||
case PGP_ITEM_MODEL_COLUMN_CHECK:
|
||||
{
|
||||
if (detail.accept_connection)
|
||||
return QIcon(IMAGE_AUTHED);
|
||||
@ -345,14 +348,14 @@ void pgpid_item_model::data_updated(std::list<RsPgpId> &new_neighs)
|
||||
break;
|
||||
if(*i1 != *i2)
|
||||
{
|
||||
QModelIndex topLeft = createIndex(ii1,0), bottomRight = createIndex(ii1, COLUMN_COUNT-1);
|
||||
QModelIndex topLeft = createIndex(ii1,0), bottomRight = createIndex(ii1, PGP_ITEM_MODEL_COLUMN_COUNT-1);
|
||||
emit dataChanged(topLeft, bottomRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(new_size > old_size)
|
||||
{
|
||||
QModelIndex topLeft = createIndex(old_size ? old_size -1 : 0 ,0), bottomRight = createIndex(new_size -1, COLUMN_COUNT-1);
|
||||
QModelIndex topLeft = createIndex(old_size ? old_size -1 : 0 ,0), bottomRight = createIndex(new_size -1, PGP_ITEM_MODEL_COLUMN_COUNT-1);
|
||||
emit dataChanged(topLeft, bottomRight);
|
||||
}
|
||||
//dirty solution for initial data fetch
|
||||
|
@ -25,20 +25,6 @@
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <QColor>
|
||||
|
||||
#define IMAGE_AUTHED ":/images/accepted16.png"
|
||||
#define IMAGE_DENIED ":/images/denied16.png"
|
||||
#define IMAGE_TRUSTED ":/images/rs-2.png"
|
||||
|
||||
|
||||
#define COLUMN_CHECK 0
|
||||
#define COLUMN_PEERNAME 1
|
||||
#define COLUMN_I_AUTH_PEER 2
|
||||
#define COLUMN_PEER_AUTH_ME 3
|
||||
#define COLUMN_PEERID 4
|
||||
#define COLUMN_LAST_USED 5
|
||||
#define COLUMN_COUNT 6
|
||||
|
||||
|
||||
class pgpid_item_model : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -62,6 +48,13 @@ public:
|
||||
void setBackgroundColorDenied(QColor color) { mBackgroundColorDenied = color; }
|
||||
void setTextColor(QColor color) { mTextColor = color; }
|
||||
|
||||
static constexpr int PGP_ITEM_MODEL_COLUMN_CHECK = 0;
|
||||
static constexpr int PGP_ITEM_MODEL_COLUMN_PEERNAME = 1;
|
||||
static constexpr int PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER = 2;
|
||||
static constexpr int PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME = 3;
|
||||
static constexpr int PGP_ITEM_MODEL_COLUMN_PEERID = 4;
|
||||
static constexpr int PGP_ITEM_MODEL_COLUMN_LAST_USED = 5;
|
||||
static constexpr int PGP_ITEM_MODEL_COLUMN_COUNT = 6;
|
||||
|
||||
public slots:
|
||||
void data_updated(std::list<RsPgpId> &new_neighs);
|
||||
|
@ -26,17 +26,13 @@
|
||||
#include <retroshare/rsdisc.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
||||
|
||||
//TODO: set this defines in one place
|
||||
// Defines for key list columns
|
||||
#define COLUMN_CHECK 0
|
||||
#define COLUMN_PEERNAME 1
|
||||
#define COLUMN_I_AUTH_PEER 2
|
||||
#define COLUMN_PEER_AUTH_ME 3
|
||||
#define COLUMN_PEERID 4
|
||||
#define COLUMN_LAST_USED 5
|
||||
#define COLUMN_COUNT 6
|
||||
|
||||
bool pgpid_item_proxy::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
{
|
||||
if(left.column() == pgpid_item_model::PGP_ITEM_MODEL_COLUMN_LAST_USED)
|
||||
return left.data(Qt::EditRole).toUInt() < right.data(Qt::EditRole).toUInt();
|
||||
else
|
||||
return left.data(Qt::DisplayRole).toString().toUpper() < right.data(Qt::DisplayRole).toString().toUpper();
|
||||
}
|
||||
|
||||
|
||||
pgpid_item_proxy::pgpid_item_proxy(QObject *parent) :
|
||||
@ -57,7 +53,7 @@ bool pgpid_item_proxy::filterAcceptsRow(int sourceRow, const QModelIndex &source
|
||||
{
|
||||
if(!rsPeers)
|
||||
return false;
|
||||
RsPgpId peer_id (sourceModel()->data(sourceModel()->index(sourceRow, COLUMN_PEERID, sourceParent)).toString().toStdString());
|
||||
RsPgpId peer_id (sourceModel()->data(sourceModel()->index(sourceRow, pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID, sourceParent)).toString().toStdString());
|
||||
RsPeerDetails details;
|
||||
if(!rsPeers->getGPGDetails(peer_id, details))
|
||||
return false;
|
||||
|
@ -34,14 +34,7 @@ class pgpid_item_proxy :
|
||||
public:
|
||||
pgpid_item_proxy(QObject *parent = nullptr);
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
|
||||
{
|
||||
if(left.column() == COLUMN_LAST_USED)
|
||||
return left.data(Qt::EditRole).toUInt() < right.data(Qt::EditRole).toUInt();
|
||||
else
|
||||
return left.data(Qt::DisplayRole).toString().toUpper() < right.data(Qt::DisplayRole).toString().toUpper();
|
||||
}
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
||||
|
||||
public slots:
|
||||
void use_only_trusted_keys(bool val);
|
||||
|
@ -48,6 +48,15 @@
|
||||
* #define RDM_SEARCH_DEBUG
|
||||
****/
|
||||
|
||||
#define REMOTEDIRMODEL_COLUMN_NAME 0
|
||||
#define REMOTEDIRMODEL_COLUMN_FILENB 1
|
||||
#define REMOTEDIRMODEL_COLUMN_SIZE 2
|
||||
#define REMOTEDIRMODEL_COLUMN_AGE 3
|
||||
#define REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS 4
|
||||
#define REMOTEDIRMODEL_COLUMN_WN_VISU_DIR 5
|
||||
#define REMOTEDIRMODEL_COLUMN_COUNT 6
|
||||
#define RETROSHARE_DIR_MODEL_FILTER_STRING "filtered"
|
||||
|
||||
static const uint32_t FLAT_VIEW_MAX_REFS_PER_SECOND = 2000 ;
|
||||
static const size_t FLAT_VIEW_MAX_REFS_TABLE_SIZE = 10000 ; //
|
||||
static const uint32_t FLAT_VIEW_MIN_DELAY_BETWEEN_UPDATES = 120 ; // dont rebuild ref list more than every 2 mins.
|
||||
@ -295,11 +304,11 @@ int FlatStyle_RDM::rowCount(const QModelIndex &parent) const
|
||||
|
||||
int TreeStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_COUNT;
|
||||
return REMOTEDIRMODEL_COLUMN_COUNT;
|
||||
}
|
||||
int FlatStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return COLUMN_COUNT;
|
||||
return REMOTEDIRMODEL_COLUMN_COUNT;
|
||||
}
|
||||
|
||||
QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
|
||||
@ -416,7 +425,7 @@ QVariant RetroshareDirModel::filterRole(const DirDetails& details, int /*coln*/)
|
||||
|
||||
QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
if(coln == COLUMN_FRIEND_ACCESS)
|
||||
if(coln == REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS)
|
||||
{
|
||||
if(details.type == DIR_TYPE_PERSON) return QVariant() ;
|
||||
|
||||
@ -484,7 +493,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME: {
|
||||
case REMOTEDIRMODEL_COLUMN_NAME: {
|
||||
//SharedDirStats stats ;
|
||||
QString res ;
|
||||
|
||||
@ -497,7 +506,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
|
||||
return res ;
|
||||
}
|
||||
case COLUMN_FILENB: {
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB: {
|
||||
SharedDirStats stats ;
|
||||
|
||||
if(RemoteMode)
|
||||
@ -516,7 +525,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
}
|
||||
return tr("Empty");
|
||||
}
|
||||
case COLUMN_SIZE: {
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE: {
|
||||
SharedDirStats stats ;
|
||||
|
||||
if(RemoteMode)
|
||||
@ -531,7 +540,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
|
||||
return QString();
|
||||
}
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
if(!isNewerThanEpoque(details.max_mtime))
|
||||
return QString();
|
||||
else if(details.id != rsPeers->getOwnId())
|
||||
@ -547,13 +556,13 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME:
|
||||
case REMOTEDIRMODEL_COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
case COLUMN_FILENB:
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB:
|
||||
return QVariant();
|
||||
case COLUMN_SIZE:
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE:
|
||||
return misc::friendlyUnit(details.size);
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
{
|
||||
if(details.type == DIR_TYPE_FILE)
|
||||
return misc::timeRelativeToNow(details.max_mtime);
|
||||
@ -567,9 +576,9 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
|
||||
return QVariant();
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
|
||||
return getGroupsString(details.flags,details.parent_groups) ;
|
||||
|
||||
default:
|
||||
@ -580,22 +589,22 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME:
|
||||
case REMOTEDIRMODEL_COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
break;
|
||||
case COLUMN_FILENB:
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB:
|
||||
if (details.children.size() > 1)
|
||||
{
|
||||
return QString::number(details.children.size()) + " " + tr("Files");
|
||||
}
|
||||
return QString::number(details.children.size()) + " " + tr("File");
|
||||
case COLUMN_SIZE:
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE:
|
||||
return misc::friendlyUnit(details.size);
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
return misc::timeRelativeToNow(details.max_mtime);
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
|
||||
return QVariant();
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
|
||||
return getGroupsString(details.flags,details.parent_groups) ;
|
||||
|
||||
default:
|
||||
@ -650,12 +659,12 @@ QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) /* File */
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
|
||||
case COLUMN_FILENB: return QString();
|
||||
case COLUMN_SIZE: return misc::friendlyUnit(details.size);
|
||||
case COLUMN_AGE: return misc::timeRelativeToNow(details.max_mtime);
|
||||
case COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
case COLUMN_WN_VISU_DIR: return computeDirectoryPath(details);
|
||||
case REMOTEDIRMODEL_COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB: return QString();
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE: return misc::friendlyUnit(details.size);
|
||||
case REMOTEDIRMODEL_COLUMN_AGE: return misc::timeRelativeToNow(details.max_mtime);
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: return computeDirectoryPath(details);
|
||||
default:
|
||||
return QVariant() ;
|
||||
}
|
||||
@ -675,9 +684,9 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME:
|
||||
case REMOTEDIRMODEL_COLUMN_NAME:
|
||||
return (RemoteMode)?(QString::fromUtf8(rsPeers->getPeerName(details.id).c_str())):tr("My files");
|
||||
case COLUMN_FILENB: {
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB: {
|
||||
SharedDirStats stats ;
|
||||
|
||||
if(RemoteMode)
|
||||
@ -687,7 +696,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
|
||||
return (qulonglong) stats.total_number_of_files;
|
||||
}
|
||||
case COLUMN_SIZE: {
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE: {
|
||||
SharedDirStats stats ;
|
||||
|
||||
if(RemoteMode)
|
||||
@ -697,7 +706,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
|
||||
return (qulonglong) stats.total_shared_size;
|
||||
}
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
return details.max_mtime;
|
||||
default:
|
||||
return QString();
|
||||
@ -707,17 +716,17 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME:
|
||||
case REMOTEDIRMODEL_COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
case COLUMN_FILENB:
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB:
|
||||
return (qulonglong) 0;
|
||||
case COLUMN_SIZE:
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE:
|
||||
return (qulonglong) details.size;
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
return details.max_mtime;
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
|
||||
return getFlagsString(details.flags);
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
|
||||
{
|
||||
QString ind("");
|
||||
if (ageIndicator != IND_ALWAYS)
|
||||
@ -732,15 +741,15 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME:
|
||||
case REMOTEDIRMODEL_COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
case COLUMN_FILENB:
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB:
|
||||
return (qulonglong) details.children.size();
|
||||
case COLUMN_SIZE:
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE:
|
||||
return (qulonglong) 0;
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
return details.max_mtime;
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
|
||||
return getFlagsString(details.flags);
|
||||
default:
|
||||
return tr("DIR");
|
||||
@ -760,12 +769,12 @@ QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
|
||||
case COLUMN_FILENB: return (qulonglong) 0;
|
||||
case COLUMN_SIZE: return (qulonglong) details.size;
|
||||
case COLUMN_AGE: return details.max_mtime;
|
||||
case COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
case COLUMN_WN_VISU_DIR: {
|
||||
case REMOTEDIRMODEL_COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB: return (qulonglong) 0;
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE: return (qulonglong) details.size;
|
||||
case REMOTEDIRMODEL_COLUMN_AGE: return details.max_mtime;
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: {
|
||||
RS_STACK_MUTEX(_ref_mutex) ;
|
||||
|
||||
return computeDirectoryPath(details);
|
||||
@ -793,7 +802,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
if((coln == COLUMN_FILENB) || (coln == COLUMN_SIZE))
|
||||
if((coln == REMOTEDIRMODEL_COLUMN_FILENB) || (coln == REMOTEDIRMODEL_COLUMN_SIZE))
|
||||
return int( Qt::AlignRight | Qt::AlignVCenter);
|
||||
else
|
||||
return QVariant();
|
||||
@ -895,7 +904,7 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
int defw = QFontMetricsF(QWidget().font()).width(headerData(section,Qt::Horizontal,Qt::DisplayRole).toString()) ;
|
||||
int defh = QFontMetricsF(QWidget().font()).height();
|
||||
|
||||
if (section < COLUMN_AGE)
|
||||
if (section < REMOTEDIRMODEL_COLUMN_AGE)
|
||||
{
|
||||
defw = 200/16.0*defh;
|
||||
}
|
||||
@ -909,7 +918,7 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case COLUMN_NAME:
|
||||
case REMOTEDIRMODEL_COLUMN_NAME:
|
||||
if (RemoteMode)
|
||||
if(mUpdating)
|
||||
return tr("Friends Directories [updating...]");
|
||||
@ -920,18 +929,18 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
return tr("My Directories [updating...]");
|
||||
else
|
||||
return tr("My Directories");
|
||||
case COLUMN_FILENB:
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB:
|
||||
return tr("# Files");
|
||||
case COLUMN_SIZE:
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE:
|
||||
return tr("Size");
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
return tr("Age");
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
|
||||
if (RemoteMode)
|
||||
return tr("Friend");
|
||||
else
|
||||
return tr("Access");
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
|
||||
if (RemoteMode)
|
||||
return tr("What's new");
|
||||
else
|
||||
@ -949,7 +958,7 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
int defw = QFontMetricsF(QWidget().font()).width(headerData(section,Qt::Horizontal,Qt::DisplayRole).toString()) ;
|
||||
int defh = QFontMetricsF(QWidget().font()).height();
|
||||
|
||||
if (section < COLUMN_AGE)
|
||||
if (section < REMOTEDIRMODEL_COLUMN_AGE)
|
||||
{
|
||||
defw = defh*200/16.0;
|
||||
}
|
||||
@ -963,24 +972,24 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case COLUMN_NAME:
|
||||
case REMOTEDIRMODEL_COLUMN_NAME:
|
||||
if (RemoteMode)
|
||||
{
|
||||
return tr("Friends Directories");
|
||||
}
|
||||
return tr("My Directories");
|
||||
case COLUMN_FILENB:
|
||||
case REMOTEDIRMODEL_COLUMN_FILENB:
|
||||
return tr("# Files");
|
||||
case COLUMN_SIZE:
|
||||
case REMOTEDIRMODEL_COLUMN_SIZE:
|
||||
return tr("Size");
|
||||
case COLUMN_AGE:
|
||||
case REMOTEDIRMODEL_COLUMN_AGE:
|
||||
return tr("Age");
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
|
||||
if(RemoteMode)
|
||||
return tr("Friend");
|
||||
else
|
||||
return tr("Share Flags");
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
|
||||
return tr("Directory");
|
||||
}
|
||||
return tr("Column %1").arg(section);
|
||||
@ -1096,7 +1105,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
|
||||
std::cerr << "Creating index 3 row=" << details.prow << ", column=" << 0 << ", ref=" << (void*)details.parent << std::endl;
|
||||
#endif
|
||||
|
||||
return createIndex(details.prow, COLUMN_NAME, details.parent);
|
||||
return createIndex(details.prow, REMOTEDIRMODEL_COLUMN_NAME, details.parent);
|
||||
}
|
||||
QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const
|
||||
{
|
||||
@ -1167,7 +1176,7 @@ void RetroshareDirModel::postMods()
|
||||
|
||||
endResetModel();
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,COLUMN_COUNT-1,(void*)NULL));
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,REMOTEDIRMODEL_COLUMN_COUNT-1,(void*)NULL));
|
||||
}
|
||||
|
||||
void FlatStyle_RDM::postMods()
|
||||
@ -1340,7 +1349,7 @@ void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, s
|
||||
QModelIndexList::const_iterator it;
|
||||
for(it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
if(it->column()==COLUMN_FILENB)
|
||||
if(it->column()==REMOTEDIRMODEL_COLUMN_FILENB)
|
||||
{
|
||||
void *ref = it -> internalPointer();
|
||||
|
||||
@ -1377,7 +1386,7 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
|
||||
std::set<std::string> already_in ;
|
||||
|
||||
for(QModelIndexList::const_iterator it(list.begin()); it != list.end(); ++it)
|
||||
if(it->column()==COLUMN_NAME)
|
||||
if(it->column()==REMOTEDIRMODEL_COLUMN_NAME)
|
||||
{
|
||||
void *ref = it -> internalPointer();
|
||||
|
||||
@ -1458,7 +1467,7 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil, bool openDir)
|
||||
|
||||
void RetroshareDirModel::getFilePath(const QModelIndex& index, std::string& fullpath)
|
||||
{
|
||||
void *ref = index.sibling(index.row(),COLUMN_FILENB).internalPointer();
|
||||
void *ref = index.sibling(index.row(),REMOTEDIRMODEL_COLUMN_FILENB).internalPointer();
|
||||
|
||||
DirDetails details ;
|
||||
|
||||
|
@ -32,15 +32,6 @@
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_FILENB 1
|
||||
#define COLUMN_SIZE 2
|
||||
#define COLUMN_AGE 3
|
||||
#define COLUMN_FRIEND_ACCESS 4
|
||||
#define COLUMN_WN_VISU_DIR 5
|
||||
#define COLUMN_COUNT 6
|
||||
#define RETROSHARE_DIR_MODEL_FILTER_STRING "filtered"
|
||||
|
||||
struct DirDetails;
|
||||
|
||||
class DirDetailsVector : public DirDetails
|
||||
|
@ -18,6 +18,8 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_BandwidthStatsWidget.h"
|
||||
#include "BWGraph.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user