part_rw.cpp
来自「konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版」· C++ 代码 · 共 109 行
CPP
109 行
/* This file is part of the KDE project Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> Copyright (C) 2000 David Faure <faure@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/#include "part.h"#if defined(ENABLE_READWRITE)#include <klocale.h>#include <kmessagebox.h>#include <kfiledialog.h>using namespace KParts;bool ReadWritePart::closeURL(){ if ( m_bReadWrite && m_bModified ) { int res = KMessageBox::warningYesNoCancel( widget(), i18n( "The document has been modified.\nDo you want to save it ?" ) ); switch( res ) { case KMessageBox::Yes: return save() && ReadOnlyPart::closeURL(); case KMessageBox::No: break; default: return false; } } return ReadOnlyPart::closeURL();}bool ReadWritePart::saveAs( const KURL & kurl ){ if ( kurl.isMalformed() || !kurl.isLocalFile() || !kurl.query().isEmpty() ) { KMessageBox::sorry( widget(), i18n( "Can save only to local files." ) ); return false; } if ( QFile::exists( kurl.path() ) && KMessageBox::warningYesNo( widget(), i18n( "Overwrite existing file ?" ) ) != KMessageBox::Yes ) return false; ReadOnlyPart::closeURL(); m_url = kurl; m_file = m_url.path(); emit setWindowCaption( m_url.prettyURL() ); return save();}bool ReadWritePart::saveToURL(){ if ( m_url.isLocalFile() && m_url.query().isEmpty() ) { setModified( false ); emit completed(); return true; } return false;}bool ReadWritePart::save(){ if ( m_file.isEmpty() || !m_url.isLocalFile() || !m_url.query().isEmpty() ) { QString fname = m_url.fileName(); if ( m_url.isLocalFile() && m_url.query().startsWith( "??" ) ) { fname = m_url.query().mid( 2 ); int sl = fname.findRev( '/' ); if ( sl >= 0 ) fname.remove( 0, sl + 1 ); } KURL url = KFileDialog::getSaveURL( QString::fromLatin1( "%1/%2" ) .arg( QDir::currentDirPath() ) .arg( fname ) ); if ( url.isEmpty() ) return false; return saveAs( url ); } return saveFile() && saveToURL();}#include "part_rw.moc"#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?