|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "filebrowsermodel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tproject.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "filebrowser.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "history.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "iocommand.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qfileinfo></qfileinfo>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdir></qdir>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
#include <shlobj.h></shlobj.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <winnetwk.h></winnetwk.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#ifdef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
#include <cocoa cocoa.h=""></cocoa>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef LINETEST
|
|
Toshihiro Shimizu |
890ddd |
#include "tnzcamera.h"
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Shinya Kitaoka |
120a6e |
TFilePath getMyDocumentsPath() {
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Shinya Kitaoka |
120a6e |
WCHAR szPath[MAX_PATH];
|
|
Shinya Kitaoka |
120a6e |
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_PERSONAL, 0)) {
|
|
Shinya Kitaoka |
120a6e |
return TFilePath(szPath);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TFilePath();
|
|
Toshihiro Shimizu |
890ddd |
#elif defined MACOSX
|
|
Shinya Kitaoka |
120a6e |
NSArray *foundref = NSSearchPathForDirectoriesInDomains(
|
|
Shinya Kitaoka |
120a6e |
NSDocumentDirectory, NSUserDomainMask, YES);
|
|
Shinya Kitaoka |
120a6e |
if (!foundref) return TFilePath();
|
|
Shinya Kitaoka |
120a6e |
int c = [foundref count];
|
|
Shinya Kitaoka |
120a6e |
assert(c == 1);
|
|
Shinya Kitaoka |
120a6e |
NSString *documentsDirectory = [foundref objectAtIndex:0];
|
|
Shinya Kitaoka |
120a6e |
return TFilePath((const char *)[documentsDirectory
|
|
Shinya Kitaoka |
120a6e |
cStringUsingEncoding:NSASCIIStringEncoding]);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
return TFilePath();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
turtletooth |
bc1f43 |
|
|
Shinya Kitaoka |
120a6e |
// Desktop Path
|
|
Shinya Kitaoka |
120a6e |
TFilePath getDesktopPath() {
|
|
turtletooth |
bc1f43 |
#ifdef _WIN32
|
|
Shinya Kitaoka |
120a6e |
WCHAR szPath[MAX_PATH];
|
|
Shinya Kitaoka |
120a6e |
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_DESKTOP, 0)) {
|
|
Shinya Kitaoka |
120a6e |
return TFilePath(szPath);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TFilePath();
|
|
turtletooth |
bc1f43 |
#elif defined MACOSX
|
|
Shinya Kitaoka |
120a6e |
NSArray *foundref = NSSearchPathForDirectoriesInDomains(
|
|
Shinya Kitaoka |
120a6e |
NSDesktopDirectory, NSUserDomainMask, YES);
|
|
Shinya Kitaoka |
120a6e |
if (!foundref) return TFilePath();
|
|
Shinya Kitaoka |
120a6e |
int c = [foundref count];
|
|
Shinya Kitaoka |
120a6e |
assert(c == 1);
|
|
Shinya Kitaoka |
120a6e |
NSString *desktopDirectory = [foundref objectAtIndex:0];
|
|
Shinya Kitaoka |
120a6e |
return TFilePath((const char *)[desktopDirectory
|
|
Shinya Kitaoka |
120a6e |
cStringUsingEncoding:NSASCIIStringEncoding]);
|
|
turtletooth |
bc1f43 |
#else
|
|
Shinya Kitaoka |
120a6e |
return TFilePath();
|
|
turtletooth |
bc1f43 |
#endif
|
|
turtletooth |
bc1f43 |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelNode
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
DvDirModelNode::DvDirModelNode(DvDirModelNode *parent, std::wstring name)
|
|
Shinya Kitaoka |
120a6e |
: m_parent(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_name(name)
|
|
Shinya Kitaoka |
120a6e |
, m_oldName()
|
|
Shinya Kitaoka |
120a6e |
, m_row(-1)
|
|
Shinya Kitaoka |
120a6e |
, m_childrenValid(false)
|
|
Shinya Kitaoka |
120a6e |
, m_renameEnabled(false)
|
|
Shinya Kitaoka |
120a6e |
, m_nodeType("") {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode::~DvDirModelNode() { clearPointerContainer(m_children); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelNode::removeChildren(int row, int count) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= row && row + count <= (int)m_children.size());
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < count; i++) delete m_children[row + i];
|
|
Shinya Kitaoka |
120a6e |
m_children.erase(m_children.begin() + row, m_children.begin() + row + count);
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)m_children.size(); i++) m_children[i]->setRow(i);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelNode::addChild(DvDirModelNode *child) {
|
|
Shinya Kitaoka |
120a6e |
child->setRow(m_children.size());
|
|
Shinya Kitaoka |
120a6e |
m_children.push_back(child);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int DvDirModelNode::getChildCount() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_childrenValid) refreshChildren();
|
|
Shinya Kitaoka |
120a6e |
return (int)m_children.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirModelNode::getChild(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_childrenValid) refreshChildren();
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getChildCount());
|
|
Shinya Kitaoka |
120a6e |
return m_children[index];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModelNode::hasChildren() {
|
|
Shinya Kitaoka |
120a6e |
if (m_childrenValid)
|
|
Shinya Kitaoka |
120a6e |
return getChildCount() > 0;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelNode::getPixmap(bool isOpen) const { return QPixmap(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelNode::setTemporaryName(const std::wstring &newName) {
|
|
Shinya Kitaoka |
120a6e |
m_oldName = getName();
|
|
Shinya Kitaoka |
120a6e |
m_name = newName;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelNode::restoreName() {
|
|
Shinya Kitaoka |
120a6e |
if (m_oldName != L"") {
|
|
Shinya Kitaoka |
120a6e |
m_name = m_oldName;
|
|
Shinya Kitaoka |
120a6e |
m_oldName = L"";
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelFileFolderNode [File folder]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode::DvDirModelFileFolderNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
std::wstring name,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelNode(parent, name)
|
|
Shinya Kitaoka |
120a6e |
, m_path(path)
|
|
Shinya Kitaoka |
120a6e |
, m_isProjectFolder(false)
|
|
Shinya Kitaoka |
120a6e |
, m_existsChecked(false)
|
|
Shinya Kitaoka |
120a6e |
, m_exists(true)
|
|
Shinya Kitaoka |
120a6e |
, m_hasChildren(false)
|
|
Shinya Kitaoka |
120a6e |
, m_peeks(true) {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "FileFolder";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode::DvDirModelFileFolderNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelNode(parent, path.withoutParentDir().getWideString())
|
|
Shinya Kitaoka |
120a6e |
, m_path(path)
|
|
Shinya Kitaoka |
120a6e |
, m_isProjectFolder(false)
|
|
Shinya Kitaoka |
120a6e |
, m_existsChecked(false)
|
|
Shinya Kitaoka |
120a6e |
, m_exists(true)
|
|
Shinya Kitaoka |
120a6e |
, m_hasChildren(false)
|
|
Shinya Kitaoka |
120a6e |
, m_peeks(true) {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "FileFolder";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModelFileFolderNode::exists() {
|
|
Shinya Kitaoka |
120a6e |
return m_existsChecked ? m_exists : m_peeks
|
|
Shinya Kitaoka |
120a6e |
? m_existsChecked = true,
|
|
Shinya Kitaoka |
120a6e |
m_exists = TFileStatus(m_path).doesExist() : true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelFileFolderNode::visualizeContent(FileBrowser *browser) {
|
|
Shinya Kitaoka |
120a6e |
browser->setFolder(m_path);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirModelFileFolderNode::makeChild(std::wstring name) {
|
|
Shinya Kitaoka |
120a6e |
return createNode(this, m_path + name);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *DvDirModelFileFolderNode::createNode(
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parent, const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *node;
|
|
Shinya Kitaoka |
120a6e |
// check the project nodes under the Poject Root Node
|
|
Shinya Kitaoka |
120a6e |
if (QString::fromStdWString(parent->getName()).startsWith("Project root") &&
|
|
Shinya Kitaoka |
120a6e |
TProjectManager::instance()->isProject(path))
|
|
Shinya Kitaoka |
120a6e |
node = new DvDirModelProjectNode(parent, path);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
node = new DvDirModelFileFolderNode(parent, path);
|
|
Shinya Kitaoka |
120a6e |
if (path.getName().find("_files") == std::string::npos)
|
|
Shinya Kitaoka |
120a6e |
node->enableRename(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return node;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModelFileFolderNode::setName(std::wstring newName) {
|
|
Shinya Kitaoka |
120a6e |
if (isSpaceString(QString::fromStdWString(newName))) return true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath srcPath = getPath();
|
|
Shinya Kitaoka |
120a6e |
TFilePath dstPath = getPath().getParentDir() + newName;
|
|
Shinya Kitaoka |
120a6e |
if (srcPath == dstPath) return false;
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
TSystem::renameFile(dstPath, srcPath);
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_path = dstPath;
|
|
Shinya Kitaoka |
120a6e |
m_name = newName;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModelFileFolderNode::hasChildren() {
|
|
Shinya Kitaoka |
120a6e |
if (m_childrenValid) return m_hasChildren;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_peeks) {
|
|
Shinya Kitaoka |
120a6e |
// Using QDir directly rather than
|
|
Shinya Kitaoka |
120a6e |
// DvDirModelFileFolderNode::refreshChildren() due to
|
|
Shinya Kitaoka |
120a6e |
// performance issues
|
|
Shinya Kitaoka |
120a6e |
QDir dir(QString::fromStdWString(m_path.getWideString()));
|
|
Shinya Kitaoka |
120a6e |
dir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return (dir.count() > 0);
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return true; // Not peeking nodes allow users to actively scan for
|
|
Shinya Kitaoka |
120a6e |
// sub-folders
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelFileFolderNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
m_childrenValid = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> names;</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
getChildrenNames(names);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<dvdirmodelnode *=""> oldChildren;</dvdirmodelnode>
|
|
Shinya Kitaoka |
120a6e |
oldChildren.swap(m_children);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<dvdirmodelnode *="">::iterator j;</dvdirmodelnode>
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)names.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
std::wstring name = names[i];
|
|
Shinya Kitaoka |
120a6e |
for (j = oldChildren.begin();
|
|
Shinya Kitaoka |
120a6e |
j != oldChildren.end() && (*j)->getName() != name; ++j) {
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *child = 0;
|
|
Shinya Kitaoka |
120a6e |
if (j != oldChildren.end()) {
|
|
Shinya Kitaoka |
120a6e |
child = *j;
|
|
Shinya Kitaoka |
120a6e |
oldChildren.erase(j);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
child = makeChild(name);
|
|
Shinya Kitaoka |
120a6e |
if (DvDirModelFileFolderNode *folderNode =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<dvdirmodelfilefoldernode *="">(child))</dvdirmodelfilefoldernode>
|
|
Shinya Kitaoka |
120a6e |
folderNode->setPeeking(m_peeks);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!child) continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
for (j = oldChildren.begin(); j != oldChildren.end(); ++j) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *child = *j;
|
|
Shinya Kitaoka |
120a6e |
if (!!child && child->hasChildren())
|
|
Shinya Kitaoka |
120a6e |
child->removeChildren(0, child->getChildCount());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
delete *j;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_hasChildren = (m_children.size() > 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelFileFolderNode::getChildrenNames(
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> &names) const {</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
TFileStatus folderPathStatus(m_path);
|
|
Shinya Kitaoka |
120a6e |
if (folderPathStatus.isLink()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QStringList entries;
|
|
Shinya Kitaoka |
120a6e |
if (folderPathStatus.isDirectory()) {
|
|
Shinya Kitaoka |
120a6e |
QDir dir(toQString(m_path));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
entries = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot,
|
|
Shinya Kitaoka |
120a6e |
QDir::Name | QDir::LocaleAware);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int e, eCount = entries.size();
|
|
Shinya Kitaoka |
120a6e |
for (e = 0; e != eCount; ++e) names.push_back(entries[e].toStdWString());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int DvDirModelFileFolderNode::rowByName(const std::wstring &name) const {
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> names;</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
getChildrenNames(names);
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring>::iterator it =</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
std::find(names.begin(), names.end(), name);
|
|
Shinya Kitaoka |
120a6e |
if (it == names.end())
|
|
Shinya Kitaoka |
120a6e |
return -1;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return std::distance(names.begin(), it);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirModelFileFolderNode::getNodeByPath(const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
if (path == m_path) return this;
|
|
Shinya Kitaoka |
120a6e |
if (!m_path.isAncestorOf(path)) return 0;
|
|
Shinya Kitaoka |
120a6e |
int i, n = getChildCount();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < n; i++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getChild(i)->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelFileFolderNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openFolderPixmap(":Resources/browser_folder_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeFolderPixmap(":Resources/browser_folder_close.png");
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openFolderPixmap : closeFolderPixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelSceneFolderNode
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelSceneFolderNode::DvDirModelSceneFolderNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
std::wstring name,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &scenePath)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelFileFolderNode(parent, name, scenePath) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelSceneFolderNode::DvDirModelSceneFolderNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelFileFolderNode(parent, path.withoutParentDir().getWideString(),
|
|
Shinya Kitaoka |
120a6e |
path) {
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
ToonzScene scene;
|
|
Shinya Kitaoka |
120a6e |
scene.setScenePath(path);
|
|
Shinya Kitaoka |
120a6e |
TProjectP project = TProjectManager::instance()->loadSceneProject(path);
|
|
Shinya Kitaoka |
120a6e |
if (!project) return;
|
|
Shinya Kitaoka |
120a6e |
scene.setProject(project.getPointer());
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < project->getFolderCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
std::string folderName = project->getFolderName(i);
|
|
Shinya Kitaoka |
120a6e |
TFilePath folderPath = project->getFolder(i);
|
|
Shinya Kitaoka |
120a6e |
if (folderPath.isAbsolute() && !project->isConstantFolder(i)) {
|
|
Shinya Kitaoka |
120a6e |
std::wstring alias = L"+" + ::to_wstring(folderName);
|
|
Shinya Kitaoka |
120a6e |
TFilePath folderActualPath = scene.decodeFilePath(TFilePath(alias));
|
|
Shinya Kitaoka |
120a6e |
m_folders[alias] = folderActualPath;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelSceneFolderNode::~DvDirModelSceneFolderNode() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModelSceneFolderNode::setName(std::wstring newName) {
|
|
Shinya Kitaoka |
120a6e |
m_name = newName;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelSceneFolderNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openFolderPixmap(":Resources/browser_scene_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeFolderPixmap(":Resources/browser_scene_close.png");
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openFolderPixmap : closeFolderPixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirModelSceneFolderNode::makeChild(std::wstring name) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath actualFolderPath = m_folders[name];
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *node =
|
|
Shinya Kitaoka |
120a6e |
new DvDirModelFileFolderNode(this, name, actualFolderPath);
|
|
Shinya Kitaoka |
120a6e |
node->enableRename(false);
|
|
Shinya Kitaoka |
120a6e |
return node;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelSceneFolderNode::getChildrenNames(
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> &names) const {</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
std::map<std::wstring, tfilepath="">::const_iterator it;</std::wstring,>
|
|
Shinya Kitaoka |
120a6e |
for (it = m_folders.begin(); it != m_folders.end(); ++it)
|
|
Shinya Kitaoka |
120a6e |
names.push_back(it->first);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelSceneFolderNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
m_childrenValid = true;
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> names;</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
getChildrenNames(names);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<dvdirmodelnode *=""> oldChildren;</dvdirmodelnode>
|
|
Shinya Kitaoka |
120a6e |
oldChildren.swap(m_children);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<dvdirmodelnode *="">::iterator j;</dvdirmodelnode>
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)names.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
std::wstring name = names[i];
|
|
Shinya Kitaoka |
120a6e |
for (j = oldChildren.begin();
|
|
Shinya Kitaoka |
120a6e |
j != oldChildren.end() && (*j)->getName() != name; ++j) {
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *child = 0;
|
|
Shinya Kitaoka |
120a6e |
if (j != oldChildren.end()) {
|
|
Shinya Kitaoka |
120a6e |
child = *j;
|
|
Shinya Kitaoka |
120a6e |
oldChildren.erase(j);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
child = makeChild(name);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
for (j = oldChildren.begin(); j != oldChildren.end(); ++j) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *child = *j;
|
|
Shinya Kitaoka |
120a6e |
if (!!child && child->hasChildren())
|
|
Shinya Kitaoka |
120a6e |
child->removeChildren(0, child->getChildCount());
|
|
Shinya Kitaoka |
120a6e |
delete *j;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *DvDirModelSceneFolderNode::createNode(
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parent, const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *node = new DvDirModelFileFolderNode(parent, path);
|
|
Shinya Kitaoka |
120a6e |
if (path.getName().find("_files") == std::string::npos)
|
|
Shinya Kitaoka |
120a6e |
node->enableRename(true);
|
|
Shinya Kitaoka |
120a6e |
return node;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int DvDirModelSceneFolderNode::rowByName(const std::wstring &name) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> names;</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
getChildrenNames(names);
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring>::iterator it =</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
std::find(names.begin(), names.end(), name);
|
|
Shinya Kitaoka |
120a6e |
if (it == names.end())
|
|
Shinya Kitaoka |
120a6e |
return -1;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return std::distance(names.begin(), it);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelSpecialFileFolderNode [Special File Folder]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DvDirModelSpecialFileFolderNode::DvDirModelSpecialFileFolderNode(
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parent, std::wstring name, const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelFileFolderNode(parent, name, path) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelSpecialFileFolderNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
return m_pixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelSpecialFileFolderNode::setPixmap(const QPixmap &pixmap) {
|
|
Shinya Kitaoka |
120a6e |
m_pixmap = pixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirVersionControlNode [Special File Folder]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlNode::DvDirVersionControlNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
std::wstring name,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelFileFolderNode(parent, name, path)
|
|
Shinya Kitaoka |
120a6e |
, m_isSynched(false)
|
|
Shinya Kitaoka |
120a6e |
, m_isUnversioned(false)
|
|
Shinya Kitaoka |
120a6e |
, m_oldName() {
|
|
Shinya Kitaoka |
120a6e |
this->setExists(TFileStatus(path).doesExist());
|
|
Shinya Kitaoka |
120a6e |
setIsUnderVersionControl(
|
|
Shinya Kitaoka |
120a6e |
VersionControl::instance()->isFolderUnderVersionControl(toQString(path)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QList<tfilepath> DvDirVersionControlNode::getMissingFiles() const {</tfilepath>
|
|
Shinya Kitaoka |
120a6e |
QList<tfilepath> list;</tfilepath>
|
|
Shinya Kitaoka |
120a6e |
QMap<qstring, svnstatus="">::const_iterator i = m_statusMap.constBegin();</qstring,>
|
|
Shinya Kitaoka |
120a6e |
while (i != m_statusMap.constEnd()) {
|
|
Shinya Kitaoka |
120a6e |
SVNStatus s = i.value();
|
|
Shinya Kitaoka |
120a6e |
if (s.m_item == "missing" ||
|
|
Shinya Kitaoka |
120a6e |
s.m_item == "none" && s.m_repoStatus == "added") {
|
|
Shinya Kitaoka |
120a6e |
TFilePath path(getPath() + TFilePath(s.m_path.toStdWString()));
|
|
Shinya Kitaoka |
120a6e |
std::string dots = path.getDots();
|
|
Shinya Kitaoka |
120a6e |
if (dots != "") {
|
|
Shinya Kitaoka |
120a6e |
if (dots == "..") path = path.getParentDir() + path.getLevelNameW();
|
|
Shinya Kitaoka |
120a6e |
if (!list.contains(path)) list.append(path);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
i++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return list;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QStringList DvDirVersionControlNode::getMissingFiles(
|
|
Shinya Kitaoka |
120a6e |
const QRegExp &filter) const {
|
|
Shinya Kitaoka |
120a6e |
QStringList list;
|
|
Shinya Kitaoka |
120a6e |
QMap<qstring, svnstatus="">::const_iterator i = m_statusMap.constBegin();</qstring,>
|
|
Shinya Kitaoka |
120a6e |
for (; i != m_statusMap.constEnd(); i++) {
|
|
Shinya Kitaoka |
120a6e |
SVNStatus s = i.value();
|
|
Shinya Kitaoka |
120a6e |
if (s.m_item == "missing" ||
|
|
Shinya Kitaoka |
120a6e |
s.m_item == "none" && s.m_repoStatus == "added") {
|
|
Shinya Kitaoka |
120a6e |
TFilePath path(s.m_path.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
if (!filter.exactMatch(
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(path.withoutParentDir().getWideString())))
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
std::string dots = path.getDots();
|
|
Shinya Kitaoka |
120a6e |
if (dots != "") list.append(toQString(path));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return list;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QList<tfilepath> DvDirVersionControlNode::getMissingFolders() const {</tfilepath>
|
|
Shinya Kitaoka |
120a6e |
QList<tfilepath> list;</tfilepath>
|
|
Shinya Kitaoka |
120a6e |
QMap<qstring, svnstatus="">::const_iterator i = m_statusMap.constBegin();</qstring,>
|
|
Shinya Kitaoka |
120a6e |
while (i != m_statusMap.constEnd()) {
|
|
Shinya Kitaoka |
120a6e |
SVNStatus s = i.value();
|
|
Shinya Kitaoka |
120a6e |
if (s.m_item == "missing" ||
|
|
Shinya Kitaoka |
120a6e |
(s.m_item == "none" && s.m_repoStatus == "added")) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath path(getPath() + TFilePath(s.m_path.toStdWString()));
|
|
Shinya Kitaoka |
120a6e |
if (path.getDots() == "" || path.getType() == "tnz") {
|
|
Shinya Kitaoka |
120a6e |
QString currentFolderName =
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(getPath().getWideName());
|
|
Shinya Kitaoka |
120a6e |
if (currentFolderName != s.m_path) {
|
|
Shinya Kitaoka |
120a6e |
if (!s.m_path.contains("\\"))
|
|
Shinya Kitaoka |
120a6e |
list.append(path);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
QString newPath = s.m_path.replace(currentFolderName + "\\", "");
|
|
Shinya Kitaoka |
120a6e |
if (!newPath.contains("\\"))
|
|
Shinya Kitaoka |
120a6e |
list.append(getPath() + TFilePath(newPath.toStdWString()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
i++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return list;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirVersionControlNode::getChildrenNames(
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> &names) const {</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode::getChildrenNames(names);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QList<tfilepath> missingFolders = getMissingFolders();</tfilepath>
|
|
Shinya Kitaoka |
120a6e |
int count = missingFolders.size();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < count; i++) {
|
|
Shinya Kitaoka |
120a6e |
std::wstring name = missingFolders.at(i).getWideName();
|
|
Shinya Kitaoka |
120a6e |
if (find(names.begin(), names.end(), name) == names.end())
|
|
Shinya Kitaoka |
120a6e |
names.push_back(name);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirVersionControlNode::setIsUnderVersionControl(bool value) {
|
|
Shinya Kitaoka |
120a6e |
// Set the flags and enable/disable renaming accordling
|
|
Shinya Kitaoka |
120a6e |
m_isUnderVersionControl = value;
|
|
Shinya Kitaoka |
120a6e |
enableRename(!value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirVersionControlNode::makeChild(std::wstring name) {
|
|
Shinya Kitaoka |
120a6e |
if (TProjectManager::instance()->isProject(getPath() + name))
|
|
Shinya Kitaoka |
120a6e |
return new DvDirVersionControlProjectNode(this, name, getPath() + name);
|
|
Shinya Kitaoka |
120a6e |
return new DvDirVersionControlNode(this, name, getPath() + name);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirVersionControlNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openFolderPixmap(":Resources/browser_folder_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeFolderPixmap(":Resources/browser_folder_close.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openMissingPixmap(":Resources/vcfolder_mis_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeMissingPixmap(":Resources/vcfolder_mis_close.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openSceneFolderPixmap(":Resources/browser_scene_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeSceneFolderPixmap(":Resources/browser_scene_close.png");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(getPath()).doesExist()) {
|
|
Shinya Kitaoka |
120a6e |
if (getPath().getType() == "tnz")
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openSceneFolderPixmap : closeSceneFolderPixmap;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openFolderPixmap : closeFolderPixmap;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openMissingPixmap : closeMissingPixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void DvDirVersionControlNode::insertVersionControlStatus(
|
|
Shinya Kitaoka |
120a6e |
const QString &fileName, SVNStatus status) {
|
|
Shinya Kitaoka |
120a6e |
m_statusMap.insert(fileName, status);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SVNStatus DvDirVersionControlNode::getVersionControlStatus(
|
|
Shinya Kitaoka |
120a6e |
const QString &fileName) {
|
|
Shinya Kitaoka |
120a6e |
if (m_statusMap.contains(fileName)) return m_statusMap.value(fileName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SVNStatus s = SVNStatus();
|
|
Shinya Kitaoka |
120a6e |
s.m_isLocked = false;
|
|
Shinya Kitaoka |
120a6e |
s.m_isPartialEdited = false;
|
|
Shinya Kitaoka |
120a6e |
s.m_isPartialLocked = false;
|
|
Shinya Kitaoka |
120a6e |
return s;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QStringList DvDirVersionControlNode::refreshVersionControl(
|
|
Shinya Kitaoka |
120a6e |
const QList<svnstatus> &status) {</svnstatus>
|
|
Shinya Kitaoka |
120a6e |
TFilePath nodePath = getPath();
|
|
Shinya Kitaoka |
120a6e |
if (nodePath.isEmpty()) return QStringList();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int listSize = status.size();
|
|
Shinya Kitaoka |
120a6e |
bool isSynched = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QStringList checkPartialLockList;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < listSize; i++) {
|
|
Shinya Kitaoka |
120a6e |
SVNStatus s = status.at(i);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// It is not needed to check and cache SVNStatus for files that are
|
|
Shinya Kitaoka |
120a6e |
// "outside" the node "scope"
|
|
Shinya Kitaoka |
120a6e |
if (s.m_path == "." || s.m_path == ".." || s.m_path.split("\\").size() > 2)
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString fileName = s.m_path;
|
|
Shinya Kitaoka |
120a6e |
if (nodePath.getType() == "") insertVersionControlStatus(fileName, s);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Update also the status of the "scene" child folders
|
|
Shinya Kitaoka |
120a6e |
TFilePath path(fileName.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
if (path.getType() == "tnz") {
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlNode *childVcNode =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<dvdirversioncontrolnode *="">(</dvdirversioncontrolnode>
|
|
Shinya Kitaoka |
120a6e |
getNodeByPath(nodePath + path));
|
|
Shinya Kitaoka |
120a6e |
if (childVcNode) {
|
|
Shinya Kitaoka |
120a6e |
childVcNode->setIsUnderVersionControl(true);
|
|
Shinya Kitaoka |
120a6e |
if (s.m_repoStatus == "modified" || s.m_item == "modified" ||
|
|
Shinya Kitaoka |
120a6e |
s.m_item == "missing" || s.m_item == "none")
|
|
Shinya Kitaoka |
120a6e |
childVcNode->setIsSynched(false);
|
|
Shinya Kitaoka |
120a6e |
else if (s.m_item == "unversioned")
|
|
Shinya Kitaoka |
120a6e |
childVcNode->setIsUnversioned(true);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
childVcNode->setIsSynched(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// If a folder is unversioned, I set its status and even the unversioned
|
|
Shinya Kitaoka |
120a6e |
// status for its children
|
|
Shinya Kitaoka |
120a6e |
else if (path.getType() == "" && s.m_item == "unversioned") {
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlNode *childVcNode =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<dvdirversioncontrolnode *="">(</dvdirversioncontrolnode>
|
|
Shinya Kitaoka |
120a6e |
getNodeByPath(nodePath + path));
|
|
Shinya Kitaoka |
120a6e |
if (childVcNode) {
|
|
Shinya Kitaoka |
120a6e |
childVcNode->setIsUnversioned(true);
|
|
Shinya Kitaoka |
120a6e |
int childCount = childVcNode->getChildCount();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < childCount; i++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlNode *subChildNode =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<dvdirversioncontrolnode *="">(childVcNode->getChild(i));</dvdirversioncontrolnode>
|
|
Shinya Kitaoka |
120a6e |
if (subChildNode) subChildNode->setIsUnversioned(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Check also the 'partial-lock' property
|
|
Shinya Kitaoka |
120a6e |
std::string type = TFilePath(s.m_path.toStdWString()).getType();
|
|
Shinya Kitaoka |
120a6e |
if (type == "tlv" || type == "pli") {
|
|
Shinya Kitaoka |
120a6e |
if (s.m_item != "unversioned" && s.m_item != "missing" &&
|
|
Shinya Kitaoka |
120a6e |
s.m_repoStatus != "added")
|
|
Shinya Kitaoka |
120a6e |
checkPartialLockList.append(s.m_path);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (s.m_repoStatus == "modified" || s.m_item == "modified" ||
|
|
Shinya Kitaoka |
120a6e |
s.m_item == "unversioned" || s.m_item == "missing" ||
|
|
Shinya Kitaoka |
120a6e |
s.m_item == "none")
|
|
Shinya Kitaoka |
120a6e |
isSynched = false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setIsSynched(isSynched);
|
|
Shinya Kitaoka |
120a6e |
return checkPartialLockList;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlRootNode *
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlNode::getVersionControlRootNode() {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parent = getParent();
|
|
Shinya Kitaoka |
120a6e |
if (parent) return parent->getVersionControlRootNode();
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirVersionControlRootNode [Special File Folder]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DvDirVersionControlRootNode::DvDirVersionControlRootNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
std::wstring name,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirVersionControlNode(parent, name, path) {
|
|
Shinya Kitaoka |
120a6e |
setPixmap(QPixmap(":Resources/vcroot.png"));
|
|
Shinya Kitaoka |
120a6e |
setIsUnderVersionControl(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirVersionControlRootNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode::refreshChildren();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// DvDirVersionControlProjectNode
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DvDirVersionControlProjectNode::DvDirVersionControlProjectNode(
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parent, std::wstring name, const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirVersionControlNode(parent, name, path) {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "Project";
|
|
Shinya Kitaoka |
120a6e |
setIsUnderVersionControl(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath DvDirVersionControlProjectNode::getProjectPath() const {
|
|
Shinya Kitaoka |
120a6e |
return TProjectManager::instance()->projectFolderToProjectPath(getPath());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirVersionControlProjectNode::isCurrent() const {
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
return pm->getCurrentProjectPath().getParentDir() == getPath();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirVersionControlProjectNode::makeCurrent() {
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
TFilePath projectPath = getProjectPath();
|
|
Shinya Kitaoka |
120a6e |
if (!IoCmd::saveSceneIfNeeded(QObject::tr("Change project"))) return;
|
|
Shinya Kitaoka |
120a6e |
pm->setCurrentProjectPath(projectPath);
|
|
Shinya Kitaoka |
120a6e |
IoCmd::newScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirVersionControlProjectNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openPixmap(":Resources/browser_vcproject_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closePixmap(":Resources/browser_vcproject_close.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openMissingPixmap(":Resources/vcfolder_mis_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeMissingPixmap(":Resources/vcfolder_mis_close.png");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(getPath()).doesExist())
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openPixmap : closePixmap;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openMissingPixmap : closeMissingPixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirVersionControlProjectNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode::refreshChildren();
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
TProject *project = new TProject();
|
|
Shinya Kitaoka |
120a6e |
project->load(getProjectPath());
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < getChildCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<dvdirmodelfilefoldernode *="">(getChild(i));</dvdirmodelfilefoldernode>
|
|
Shinya Kitaoka |
120a6e |
if (node) {
|
|
Shinya Kitaoka |
120a6e |
int k = project->getFolderIndexFromPath(node->getPath());
|
|
Shinya Kitaoka |
120a6e |
node->setIsProjectFolder(k >= 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
delete project;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirVersionControlProjectNode::getChildrenNames(
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> &names) const {</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlNode::getChildrenNames(names);
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
TProject *project = new TProject();
|
|
Shinya Kitaoka |
120a6e |
project->load(getProjectPath());
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < project->getFolderCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
std::string folderName = project->getFolderName(i);
|
|
Shinya Kitaoka |
120a6e |
TFilePath folderPath = project->getFolder(i);
|
|
Shinya Kitaoka |
120a6e |
// if(folderPath.isAbsolute() || folderPath.getParentDir() != TFilePath())
|
|
Shinya Kitaoka |
120a6e |
if (folderPath.isAbsolute() && project->isConstantFolder(i)) {
|
|
Shinya Kitaoka |
120a6e |
names.push_back(L"+" + ::to_wstring(folderName));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
delete project;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelProjectNode [Project Folder]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelProjectNode::DvDirModelProjectNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &path)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelFileFolderNode(parent, path) {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "Project";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath DvDirModelProjectNode::getProjectPath() const {
|
|
Shinya Kitaoka |
120a6e |
return TProjectManager::instance()->projectFolderToProjectPath(getPath());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModelProjectNode::isCurrent() const {
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
return pm->getCurrentProjectPath().getParentDir() == getPath();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelProjectNode::makeCurrent() {
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
TFilePath projectPath = getProjectPath();
|
|
Shinya Kitaoka |
120a6e |
if (!IoCmd::saveSceneIfNeeded(QObject::tr("Change project"))) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef LINETEST
|
|
Shinya Kitaoka |
120a6e |
TnzCamera *camera = TnzCamera::instance();
|
|
Shinya Kitaoka |
120a6e |
if (camera->isCameraConnected()) camera->cameraDisconnect();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pm->setCurrentProjectPath(projectPath);
|
|
Shinya Kitaoka |
120a6e |
IoCmd::newScene();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelProjectNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openProjectPixmap(":Resources/browser_project_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeProjectPixmap(":Resources/browser_project_close.png");
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openProjectPixmap : closeProjectPixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelProjectNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode::refreshChildren();
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
TProject *project = new TProject();
|
|
Shinya Kitaoka |
120a6e |
project->load(getProjectPath());
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < getChildCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *node =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<dvdirmodelfilefoldernode *="">(getChild(i));</dvdirmodelfilefoldernode>
|
|
Shinya Kitaoka |
120a6e |
if (node) {
|
|
Shinya Kitaoka |
120a6e |
int k = project->getFolderIndexFromPath(node->getPath());
|
|
Shinya Kitaoka |
120a6e |
node->setIsProjectFolder(k >= 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
delete project;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelProjectNode::getChildrenNames(
|
|
Shinya Kitaoka |
120a6e |
std::vector<std::wstring> &names) const {</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode::getChildrenNames(names);
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
TProject *project = new TProject();
|
|
Shinya Kitaoka |
120a6e |
project->load(getProjectPath());
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < project->getFolderCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
std::string folderName = project->getFolderName(i);
|
|
Shinya Kitaoka |
120a6e |
TFilePath folderPath = project->getFolder(i);
|
|
Shinya Kitaoka |
120a6e |
// if(folderPath.isAbsolute() || folderPath.getParentDir() != TFilePath())
|
|
Shinya Kitaoka |
120a6e |
if (folderPath.isAbsolute() && project->isConstantFolder(i)) {
|
|
Shinya Kitaoka |
120a6e |
names.push_back(L"+" + ::to_wstring(folderName));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
delete project;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirModelProjectNode::makeChild(std::wstring name) {
|
|
Shinya Kitaoka |
120a6e |
if (name != L"" && name[0] == L'+') {
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
TProject *project = new TProject();
|
|
Shinya Kitaoka |
120a6e |
project->load(getProjectPath());
|
|
Shinya Kitaoka |
120a6e |
std::string folderName = ::to_string(name.substr(1));
|
|
Shinya Kitaoka |
120a6e |
TFilePath folderPath = project->getFolder(folderName);
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = new DvDirModelFileFolderNode(this, name, folderPath);
|
|
Shinya Kitaoka |
120a6e |
delete project;
|
|
Shinya Kitaoka |
120a6e |
return node;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return DvDirModelFileFolderNode::makeChild(name);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelDayNode [Day folder]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelDayNode::DvDirModelDayNode(DvDirModelNode *parent,
|
|
Shinya Kitaoka |
120a6e |
std::wstring dayDateString)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelNode(parent, dayDateString)
|
|
Shinya Kitaoka |
120a6e |
, m_dayDateString(::to_string(dayDateString)) {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "Day";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelDayNode::visualizeContent(FileBrowser *browser) {
|
|
Shinya Kitaoka |
120a6e |
browser->setHistoryDay(m_dayDateString);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelDayNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap openFolderPixmap(":Resources/browser_folder_open.png");
|
|
Shinya Kitaoka |
120a6e |
static QPixmap closeFolderPixmap(":Resources/browser_folder_close.png");
|
|
Shinya Kitaoka |
120a6e |
return isOpen ? openFolderPixmap : closeFolderPixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelHistoryNode [History]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DvDirModelHistoryNode::DvDirModelHistoryNode(DvDirModelNode *parent)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelNode(parent, L"History") {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "History";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelHistoryNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
m_children.clear();
|
|
Shinya Kitaoka |
120a6e |
m_childrenValid = true;
|
|
Shinya Kitaoka |
120a6e |
History *h = History::instance();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < h->getDayCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
const History::Day *day = h->getDay(i);
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *child =
|
|
Shinya Kitaoka |
120a6e |
new DvDirModelDayNode(this, ::to_wstring(day->getDate()));
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelHistoryNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap pixmap(":Resources/history.png");
|
|
Shinya Kitaoka |
120a6e |
return pixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelMyComputerNode [My Computer]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DvDirModelMyComputerNode::DvDirModelMyComputerNode(DvDirModelNode *parent)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelNode(parent, L"My Computer") {
|
|
Shinya Kitaoka |
120a6e |
// setIcon(QFileIconProvider().icon(QFileIconProvider::Computer));
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "MyComputer";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelMyComputerNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
m_childrenValid = true;
|
|
Shinya Kitaoka |
120a6e |
if (!m_children.empty()) clearPointerContainer(m_children);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet fps = TSystem::getDisks();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef MACOSX
|
|
Shinya Kitaoka |
120a6e |
fps.push_back(TFilePath("/Volumes/"));
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet::iterator it;
|
|
Shinya Kitaoka |
120a6e |
for (it = fps.begin(); it != fps.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *child =
|
|
Shinya Kitaoka |
120a6e |
new DvDirModelFileFolderNode(this, it->getWideString(), *it);
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelMyComputerNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap pixmap(":Resources/my_computer.png");
|
|
Shinya Kitaoka |
120a6e |
return pixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelNetworkNode [Network]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DvDirModelNetworkNode::DvDirModelNetworkNode(DvDirModelNode *parent)
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelNode(parent, L"Network") {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "Network";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelNetworkNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
m_childrenValid = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_children.empty()) clearPointerContainer(m_children);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Enumerate network nodes
|
|
Shinya Kitaoka |
120a6e |
HANDLE enumHandle;
|
|
Shinya Kitaoka |
120a6e |
DWORD err =
|
|
Shinya Kitaoka |
120a6e |
WNetOpenEnum(RESOURCE_CONTEXT, RESOURCETYPE_DISK, 0, NULL, &enumHandle);
|
|
Shinya Kitaoka |
120a6e |
assert(err == NO_ERROR);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DWORD count = -1,
|
|
Shinya Kitaoka |
120a6e |
bufferSize =
|
|
Shinya Kitaoka |
120a6e |
16 << 10; // Use 16 kB as recommended on Windows references
|
|
Shinya Kitaoka |
120a6e |
LPNETRESOURCE buffer = (LPNETRESOURCE)malloc(bufferSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
do {
|
|
Shinya Kitaoka |
120a6e |
// Get the next bunch of network devices
|
|
Shinya Kitaoka |
120a6e |
memset(buffer, 0, bufferSize);
|
|
Shinya Kitaoka |
120a6e |
err = WNetEnumResource(enumHandle, &count, buffer, &bufferSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (err == NO_ERROR) {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < count; ++i) {
|
|
Shinya Kitaoka |
120a6e |
// Only list disk-type devices - in any case, the remote (UNC) name
|
|
Shinya Kitaoka |
120a6e |
// should exist
|
|
Shinya Kitaoka |
120a6e |
if (buffer[i].dwType == RESOURCETYPE_DISK && buffer[i].lpRemoteName) {
|
|
Shinya Kitaoka |
120a6e |
std::wstring wstr(buffer[i].lpRemoteName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Build a NOT PEEKING folder node. This is important since network
|
|
Shinya Kitaoka |
120a6e |
// access is SLOW.
|
|
Shinya Kitaoka |
120a6e |
DvDirModelFileFolderNode *child =
|
|
Shinya Kitaoka |
120a6e |
new DvDirModelFileFolderNode(this, wstr, TFilePath(wstr));
|
|
Shinya Kitaoka |
120a6e |
child->setPeeking(false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else if (err != ERROR_NO_MORE_ITEMS)
|
|
Shinya Kitaoka |
120a6e |
break; // Excluding NO_ERROR and ERROR_NO_MORE_ITEMS, quit
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} while (err != ERROR_NO_MORE_ITEMS);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
err = WNetCloseEnum(enumHandle);
|
|
Shinya Kitaoka |
120a6e |
assert(err == NO_ERROR);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
free(buffer);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DvDirModelNetworkNode::getPixmap(bool isOpen) const {
|
|
Shinya Kitaoka |
120a6e |
static QPixmap pixmap(":Resources/network.png");
|
|
Shinya Kitaoka |
120a6e |
return pixmap;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModelRootNode [Root]
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DvDirModelRootNode::DvDirModelRootNode()
|
|
Shinya Kitaoka |
120a6e |
: DvDirModelNode(0, L"Root")
|
|
Shinya Kitaoka |
120a6e |
, m_myComputerNode(0)
|
|
Shinya Kitaoka |
120a6e |
, m_networkNode(0)
|
|
Shinya Kitaoka |
120a6e |
, m_sandboxProjectNode(0) {
|
|
Shinya Kitaoka |
120a6e |
m_nodeType = "Root";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelRootNode::add(std::wstring name, const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *child = new DvDirModelFileFolderNode(this, name, path);
|
|
Shinya Kitaoka |
120a6e |
child->setRow((int)m_children.size());
|
|
Shinya Kitaoka |
120a6e |
m_children.push_back(child);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModelRootNode::refreshChildren() {
|
|
Shinya Kitaoka |
120a6e |
m_childrenValid = true;
|
|
Shinya Kitaoka |
120a6e |
if (m_children.empty()) {
|
|
Shinya Kitaoka |
120a6e |
addChild(m_myComputerNode = new DvDirModelMyComputerNode(this));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Shinya Kitaoka |
120a6e |
addChild(m_networkNode = new DvDirModelNetworkNode(this));
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelSpecialFileFolderNode *child;
|
|
Shinya Kitaoka |
120a6e |
child = new DvDirModelSpecialFileFolderNode(this, L"My Documents",
|
|
Shinya Kitaoka |
120a6e |
getMyDocumentsPath());
|
|
Shinya Kitaoka |
120a6e |
child->setPixmap(QPixmap(":Resources/my_documents.png"));
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
child =
|
|
Shinya Kitaoka |
120a6e |
new DvDirModelSpecialFileFolderNode(this, L"Desktop", getDesktopPath());
|
|
Shinya Kitaoka |
120a6e |
child->setPixmap(QPixmap(":Resources/desktop.png"));
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
child = new DvDirModelSpecialFileFolderNode(
|
|
Shinya Kitaoka |
120a6e |
this, L"Library", ToonzFolder::getLibraryFolder());
|
|
Shinya Kitaoka |
120a6e |
child->setPixmap(QPixmap(":Resources/library.png"));
|
|
Shinya Kitaoka |
120a6e |
addChild(child);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
addChild(new DvDirModelHistoryNode(this));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TProjectManager *pm = TProjectManager::instance();
|
|
Shinya Kitaoka |
120a6e |
std::vector<tfilepath> projectRoots;</tfilepath>
|
|
Shinya Kitaoka |
120a6e |
pm->getProjectRoots(projectRoots);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)projectRoots.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath projectRoot = projectRoots[i];
|
|
Shinya Kitaoka |
120a6e |
std::wstring roothDir = projectRoot.getWideString();
|
|
Shinya Kitaoka |
120a6e |
DvDirModelSpecialFileFolderNode *projectRootNode =
|
|
Shinya Kitaoka |
120a6e |
new DvDirModelSpecialFileFolderNode(
|
|
Shinya Kitaoka |
120a6e |
this, L"Project root (" + roothDir + L")", projectRoot);
|
|
Shinya Kitaoka |
120a6e |
projectRootNode->setPixmap(QPixmap(":Resources/projects.png"));
|
|
Shinya Kitaoka |
120a6e |
m_projectRootNodes.push_back(projectRootNode);
|
|
Shinya Kitaoka |
120a6e |
addChild(projectRootNode);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFilePath sandboxProjectPath = pm->getSandboxProjectFolder();
|
|
Shinya Kitaoka |
120a6e |
m_sandboxProjectNode = new DvDirModelProjectNode(this, sandboxProjectPath);
|
|
Shinya Kitaoka |
120a6e |
addChild(m_sandboxProjectNode);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// SVN Repositories
|
|
Shinya Kitaoka |
120a6e |
QList<svnrepository> repositories =</svnrepository>
|
|
Shinya Kitaoka |
120a6e |
VersionControl::instance()->getRepositories();
|
|
Shinya Kitaoka |
120a6e |
int count = repositories.size();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < count; i++) {
|
|
Shinya Kitaoka |
120a6e |
SVNRepository repo = repositories.at(i);
|
|
Shinya Kitaoka |
120a6e |
DvDirVersionControlRootNode *node = new DvDirVersionControlRootNode(
|
|
Shinya Kitaoka |
120a6e |
this, repo.m_name.toStdWString(),
|
|
Shinya Kitaoka |
120a6e |
TFilePath(repo.m_localPath.toStdWString()));
|
|
Shinya Kitaoka |
120a6e |
node->setRepositoryPath(repo.m_repoPath.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
node->setLocalPath(repo.m_localPath.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
node->setUserName(repo.m_username.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
node->setPassword(repo.m_password.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
m_versionControlNodes.push_back(node);
|
|
Shinya Kitaoka |
120a6e |
addChild(node);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirModelRootNode::getNodeByPath(const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
// Check first for version control nodes
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = 0;
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// search in #1 the project folders, #2 sandbox, #3 other folders in file
|
|
Shinya Kitaoka |
120a6e |
// system
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// path could be a project, under some project root
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)m_projectRootNodes.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
node = m_projectRootNodes[i]->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
// search in the project folders
|
|
Shinya Kitaoka |
120a6e |
for (int j = 0; j < m_projectRootNodes[i]->getChildCount(); j++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelProjectNode *projectNode =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<dvdirmodelprojectnode *="">(</dvdirmodelprojectnode>
|
|
Shinya Kitaoka |
120a6e |
m_projectRootNodes[i]->getChild(j));
|
|
Shinya Kitaoka |
120a6e |
if (projectNode) {
|
|
Shinya Kitaoka |
120a6e |
// for the normal folder in the project folder
|
|
Shinya Kitaoka |
120a6e |
node = projectNode->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (projectNode->isCurrent()) {
|
|
Shinya Kitaoka |
120a6e |
// for the aliases in the project folder ("+drawings" etc.)
|
|
Shinya Kitaoka |
120a6e |
for (int k = 0; k < projectNode->getChildCount(); k++) {
|
|
Shinya Kitaoka |
120a6e |
node = projectNode->getChild(k)->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else // for the normal folder in the project root
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
node = m_projectRootNodes[i]->getChild(j)->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// it could be on a repository, under version control
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)m_versionControlNodes.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
node = m_versionControlNodes[i]->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// or it could be the sandbox project or in the sandbox project
|
|
Shinya Kitaoka |
120a6e |
if (m_sandboxProjectNode && m_sandboxProjectNode->getPath() == path)
|
|
Shinya Kitaoka |
120a6e |
return m_sandboxProjectNode;
|
|
Shinya Kitaoka |
120a6e |
if (m_sandboxProjectNode) {
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_sandboxProjectNode->getChildCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node =
|
|
Shinya Kitaoka |
120a6e |
m_sandboxProjectNode->getChild(i)->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// it could be a regular folder, somewhere in the file system
|
|
Shinya Kitaoka |
120a6e |
if (m_myComputerNode) {
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_myComputerNode->getChildCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = m_myComputerNode->getChild(i)->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// it could be a network folder
|
|
Shinya Kitaoka |
120a6e |
if (m_networkNode) {
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_networkNode->getChildCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = m_networkNode->getChild(i)->getNodeByPath(path);
|
|
Shinya Kitaoka |
120a6e |
if (node) return node;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DvDirModel
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModel::DvDirModel() {
|
|
Shinya Kitaoka |
120a6e |
m_root = new DvDirModelRootNode();
|
|
Shinya Kitaoka |
120a6e |
m_root->refreshChildren();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModel::~DvDirModel() { delete m_root; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModel::onFolderChanged(const TFilePath &path) { refreshFolder(path); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModel::refresh(const QModelIndex &index) {
|
|
Shinya Kitaoka |
120a6e |
if (!index.isValid()) return;
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(index);
|
|
Shinya Kitaoka |
120a6e |
if (!node) return;
|
|
Shinya Kitaoka |
120a6e |
emit layoutAboutToBeChanged();
|
|
Shinya Kitaoka |
120a6e |
emit beginRemoveRows(index, 0, node->getChildCount());
|
|
Shinya Kitaoka |
120a6e |
node->refreshChildren();
|
|
Shinya Kitaoka |
120a6e |
emit endRemoveRows();
|
|
Shinya Kitaoka |
120a6e |
emit layoutChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModel::refreshFolder(const TFilePath &folderPath,
|
|
Shinya Kitaoka |
120a6e |
const QModelIndex &i) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(i);
|
|
Shinya Kitaoka |
120a6e |
if (!node) return;
|
|
Shinya Kitaoka |
120a6e |
if (node->isFolder(folderPath))
|
|
Shinya Kitaoka |
120a6e |
refresh(i);
|
|
Shinya Kitaoka |
120a6e |
else if (node->areChildrenValid()) {
|
|
Shinya Kitaoka |
120a6e |
int count = rowCount(i);
|
|
Shinya Kitaoka |
120a6e |
int r;
|
|
Shinya Kitaoka |
120a6e |
for (r = 0; r < count; r++) refreshFolder(folderPath, index(r, 0, i));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DvDirModel::refreshFolderChild(const QModelIndex &i) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(i);
|
|
Shinya Kitaoka |
120a6e |
if (!node || !node->areChildrenValid()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (node->isFolder() || dynamic_cast<dvdirmodelmycomputernode *="">(node))</dvdirmodelmycomputernode>
|
|
Shinya Kitaoka |
120a6e |
refresh(i);
|
|
Shinya Kitaoka |
120a6e |
int count = rowCount(i);
|
|
Shinya Kitaoka |
120a6e |
int r;
|
|
Shinya Kitaoka |
120a6e |
for (r = 0; r < count; r++) refreshFolderChild(index(r, 0, i));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *DvDirModel::getNode(const QModelIndex &index) const {
|
|
Shinya Kitaoka |
120a6e |
if (index.isValid())
|
|
Shinya Kitaoka |
120a6e |
return static_cast<dvdirmodelnode *="">(index.internalPointer());</dvdirmodelnode>
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return m_root;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QModelIndex DvDirModel::index(int row, int column,
|
|
Shinya Kitaoka |
120a6e |
const QModelIndex &parent) const {
|
|
Shinya Kitaoka |
120a6e |
if (column != 0) return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parentNode = m_root;
|
|
Shinya Kitaoka |
120a6e |
if (parent.isValid()) parentNode = getNode(parent);
|
|
Shinya Kitaoka |
120a6e |
if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = parentNode->getChild(row);
|
|
Shinya Kitaoka |
120a6e |
return createIndex(row, column, node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QModelIndex DvDirModel::parent(const QModelIndex &index) const {
|
|
Shinya Kitaoka |
120a6e |
if (!index.isValid()) return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(index);
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parentNode = node->getParent();
|
|
Shinya Kitaoka |
120a6e |
if (!parentNode || parentNode == m_root)
|
|
Shinya Kitaoka |
120a6e |
return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return createIndex(parentNode->getRow(), 0, parentNode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QModelIndex DvDirModel::childByName(const QModelIndex &parent,
|
|
Shinya Kitaoka |
120a6e |
const std::wstring &name) const {
|
|
Shinya Kitaoka |
120a6e |
if (!parent.isValid()) return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *parentNode = getNode(parent);
|
|
Shinya Kitaoka |
120a6e |
if (!parentNode) return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
int row = parentNode->rowByName(name);
|
|
Shinya Kitaoka |
120a6e |
if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *childNode = parentNode->getChild(row);
|
|
Shinya Kitaoka |
120a6e |
return createIndex(row, 0, childNode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int DvDirModel::rowCount(const QModelIndex &parent) const {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(parent);
|
|
Shinya Kitaoka |
120a6e |
return node->getChildCount();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModel::hasChildren(const QModelIndex &parent) const {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(parent);
|
|
Shinya Kitaoka |
120a6e |
return node->hasChildren();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QVariant DvDirModel::data(const QModelIndex &index, int role) const {
|
|
Shinya Kitaoka |
120a6e |
if (!index.isValid()) return QVariant();
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(index);
|
|
Shinya Kitaoka |
120a6e |
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
|
Shinya Kitaoka |
120a6e |
return QString::fromStdWString(node->getName());
|
|
Shinya Kitaoka |
120a6e |
else if (role == Qt::DecorationRole) {
|
|
Shinya Kitaoka |
120a6e |
return QVariant();
|
|
Shinya Kitaoka |
120a6e |
} else if (role == Qt::ForegroundRole) {
|
|
Shinya Kitaoka |
120a6e |
if (!node || !node->isRenameEnabled())
|
|
Shinya Kitaoka |
120a6e |
return QBrush(Qt::blue);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return QVariant();
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return QVariant();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Qt::ItemFlags DvDirModel::flags(const QModelIndex &index) const {
|
|
Shinya Kitaoka |
120a6e |
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
|
|
Shinya Kitaoka |
120a6e |
if (index.isValid()) {
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(index);
|
|
Shinya Kitaoka |
120a6e |
if (node && node->isRenameEnabled()) flags |= Qt::ItemIsEditable;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return flags;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! used only for name / rename of items
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModel::setData(const QModelIndex &index, const QVariant &value,
|
|
Shinya Kitaoka |
120a6e |
int role) {
|
|
Shinya Kitaoka |
120a6e |
if (!index.isValid()) return false;
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(index);
|
|
Shinya Kitaoka |
120a6e |
if (!node || !node->isRenameEnabled()) return false;
|
|
Shinya Kitaoka |
120a6e |
QString newName = value.toString();
|
|
Shinya Kitaoka |
120a6e |
if (newName == "") return false;
|
|
Shinya Kitaoka |
120a6e |
if (!node->setName(newName.toStdWString())) return false;
|
|
Shinya Kitaoka |
120a6e |
emit dataChanged(index, index);
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool DvDirModel::removeRows(int row, int count,
|
|
Shinya Kitaoka |
120a6e |
const QModelIndex &parentIndex) {
|
|
Shinya Kitaoka |
120a6e |
if (!parentIndex.isValid()) return false;
|
|
Shinya Kitaoka |
120a6e |
DvDirModelNode *node = getNode(parentIndex);
|
|
Shinya Kitaoka |
120a6e |
if (!node) return false;
|
|
Shinya Kitaoka |
120a6e |
emit beginRemoveRows(parentIndex, row, row + count - 1);
|
|
Shinya Kitaoka |
120a6e |
node->removeChildren(row, count);
|
|
Shinya Kitaoka |
120a6e |
emit endRemoveRows();
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QModelIndex DvDirModel::getIndexByPath(const TFilePath &path) const {
|
|
Shinya Kitaoka |
120a6e |
return getIndexByNode(m_root->getNodeByPath(path));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QModelIndex DvDirModel::getIndexByNode(DvDirModelNode *node) const {
|
|
Shinya Kitaoka |
120a6e |
if (!node) return QModelIndex();
|
|
Shinya Kitaoka |
120a6e |
return createIndex(node->getRow(), 0, node);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QModelIndex DvDirModel::getCurrentProjectIndex() const {
|
|
Shinya Kitaoka |
120a6e |
return getIndexByPath(
|
|
Shinya Kitaoka |
120a6e |
TProjectManager::instance()->getCurrentProjectPath().getParentDir());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DvDirModel *DvDirModel::instance() {
|
|
Shinya Kitaoka |
120a6e |
static DvDirModel _instance;
|
|
Shinya Kitaoka |
120a6e |
return &_instance;
|
|
Toshihiro Shimizu |
890ddd |
}
|