mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
generic: drop redundant tempfile option
see the following commit in kdelibs repo: 8c8855d9a62bd422fa15176d9a1271ff2f54c7e2 Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
75c518ed98
commit
43e538f21d
12 changed files with 17 additions and 65 deletions
|
@ -208,8 +208,6 @@ bool KateApp::startupKate ()
|
||||||
#endif
|
#endif
|
||||||
QTextCodec *codec = m_args->isSet("encoding") ? QTextCodec::codecForName(m_args->getOption("encoding").toUtf8()) : 0;
|
QTextCodec *codec = m_args->isSet("encoding") ? QTextCodec::codecForName(m_args->getOption("encoding").toUtf8()) : 0;
|
||||||
|
|
||||||
bool tempfileSet = KCmdLineArgs::isTempFileSet();
|
|
||||||
|
|
||||||
KTextEditor::Document *doc = 0;
|
KTextEditor::Document *doc = 0;
|
||||||
const QString codec_name = codec ? codec->name() : QString();
|
const QString codec_name = codec ? codec->name() : QString();
|
||||||
KateDocManager::self()->setSuppressOpeningErrorDialogs(true);
|
KateDocManager::self()->setSuppressOpeningErrorDialogs(true);
|
||||||
|
@ -226,7 +224,7 @@ bool KateApp::startupKate ()
|
||||||
i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", m_args->url(z).url()) );
|
i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", m_args->url(z).url()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc = activeMainWindow()->viewManager()->openUrls(urls, codec_name, tempfileSet);
|
doc = activeMainWindow()->viewManager()->openUrls(urls, codec_name);
|
||||||
KateDocManager::self()->setSuppressOpeningErrorDialogs(false);
|
KateDocManager::self()->setSuppressOpeningErrorDialogs(false);
|
||||||
|
|
||||||
// handle stdin input
|
// handle stdin input
|
||||||
|
@ -316,12 +314,12 @@ KateSessionManager *KateApp::sessionManager ()
|
||||||
return m_sessionManager;
|
return m_sessionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KateApp::openUrl (const KUrl &url, const QString &encoding, bool isTempFile)
|
bool KateApp::openUrl (const KUrl &url, const QString &encoding)
|
||||||
{
|
{
|
||||||
return openDocUrl(url,encoding,isTempFile);
|
return openDocUrl(url,encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
KTextEditor::Document* KateApp::openDocUrl (const KUrl &url, const QString &encoding, bool isTempFile)
|
KTextEditor::Document* KateApp::openDocUrl (const KUrl &url, const QString &encoding)
|
||||||
{
|
{
|
||||||
KateMainWindow *mainWindow = activeMainWindow ();
|
KateMainWindow *mainWindow = activeMainWindow ();
|
||||||
|
|
||||||
|
@ -342,9 +340,9 @@ KTextEditor::Document* KateApp::openDocUrl (const KUrl &url, const QString &enco
|
||||||
|
|
||||||
// open a normal file
|
// open a normal file
|
||||||
if (codec)
|
if (codec)
|
||||||
doc=mainWindow->viewManager()->openUrl( url, codec->name(), true, isTempFile);
|
doc=mainWindow->viewManager()->openUrl( url, codec->name(), true);
|
||||||
else
|
else
|
||||||
doc=mainWindow->viewManager()->openUrl( url, QString(), true, isTempFile );
|
doc=mainWindow->viewManager()->openUrl( url, QString(), true );
|
||||||
|
|
||||||
// back to normal....
|
// back to normal....
|
||||||
documentManager()->setSuppressOpeningErrorDialogs (false);
|
documentManager()->setSuppressOpeningErrorDialogs (false);
|
||||||
|
|
|
@ -201,9 +201,9 @@ class KATE_EXPORT KateApp : public KApplication
|
||||||
* @param encoding encoding name
|
* @param encoding encoding name
|
||||||
* @return success
|
* @return success
|
||||||
*/
|
*/
|
||||||
bool openUrl (const KUrl &url, const QString &encoding, bool isTempFile);
|
bool openUrl (const KUrl &url, const QString &encoding);
|
||||||
|
|
||||||
KTextEditor::Document* openDocUrl (const KUrl &url, const QString &encoding, bool isTempFile);
|
KTextEditor::Document* openDocUrl (const KUrl &url, const QString &encoding);
|
||||||
|
|
||||||
void emitDocumentClosed(const QString& token);
|
void emitDocumentClosed(const QString& token);
|
||||||
|
|
||||||
|
|
|
@ -50,29 +50,16 @@ void KateAppAdaptor::activate ()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KateAppAdaptor::openUrl (QString url, QString encoding)
|
bool KateAppAdaptor::openUrl (QString url, QString encoding)
|
||||||
{
|
|
||||||
return m_app->openUrl (url, encoding, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KateAppAdaptor::openUrl (QString url, QString encoding, bool isTempFile)
|
|
||||||
{
|
{
|
||||||
kDebug () << "openURL";
|
kDebug () << "openURL";
|
||||||
|
return m_app->openUrl (url, encoding);
|
||||||
return m_app->openUrl (url, encoding, isTempFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------
|
//-----------
|
||||||
QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding)
|
QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding)
|
||||||
{
|
|
||||||
KTextEditor::Document *doc=m_app->openDocUrl (url, encoding, false);
|
|
||||||
if (!doc) return QString("ERROR");
|
|
||||||
return QString::number((qptrdiff)doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding, bool isTempFile)
|
|
||||||
{
|
{
|
||||||
kDebug () << "openURL";
|
kDebug () << "openURL";
|
||||||
KTextEditor::Document *doc=m_app->openDocUrl (url, encoding, isTempFile);
|
KTextEditor::Document *doc=m_app->openDocUrl (url, encoding);
|
||||||
if (!doc) return QString("ERROR");
|
if (!doc) return QString("ERROR");
|
||||||
return QString::number((qptrdiff)doc);
|
return QString::number((qptrdiff)doc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,16 +56,6 @@ class KateAppAdaptor : public QDBusAbstractAdaptor
|
||||||
*/
|
*/
|
||||||
QString tokenOpenUrl (QString url, QString encoding);
|
QString tokenOpenUrl (QString url, QString encoding);
|
||||||
|
|
||||||
/**
|
|
||||||
* Like the above, but adds an option to let the documentManager know
|
|
||||||
* if the file should be deleted when closed.
|
|
||||||
* @p isTempFile should be set to true with the --tempfile option set ONLY,
|
|
||||||
* files opened with this set to true will be deleted when closed.
|
|
||||||
*/
|
|
||||||
bool openUrl(QString url, QString encoding, bool isTempFile);
|
|
||||||
|
|
||||||
QString tokenOpenUrl(QString url, QString encoding, bool isTempFile);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set cursor of active view in active main window
|
* set cursor of active view in active main window
|
||||||
* @param line line for cursor
|
* @param line line for cursor
|
||||||
|
|
|
@ -217,14 +217,14 @@ bool KateDocManager::isOpen(KUrl url)
|
||||||
return findDocument (url) != 0;
|
return findDocument (url) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<KTextEditor::Document *> KateDocManager::openUrls(const QList<KUrl> &urls, const QString &encoding, bool isTempFile, const KateDocumentInfo& docInfo)
|
QList<KTextEditor::Document *> KateDocManager::openUrls(const QList<KUrl> &urls, const QString &encoding, const KateDocumentInfo& docInfo)
|
||||||
{
|
{
|
||||||
QList<KTextEditor::Document *> docs;
|
QList<KTextEditor::Document *> docs;
|
||||||
|
|
||||||
emit m_documentManager->aboutToLoadDocuments();
|
emit m_documentManager->aboutToLoadDocuments();
|
||||||
|
|
||||||
foreach (const KUrl &url, urls) {
|
foreach (const KUrl &url, urls) {
|
||||||
docs << openUrl(url, encoding, isTempFile, docInfo);
|
docs << openUrl(url, encoding, docInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit m_documentManager->documentsLoaded(docs);
|
emit m_documentManager->documentsLoaded(docs);
|
||||||
|
@ -232,7 +232,7 @@ QList<KTextEditor::Document *> KateDocManager::openUrls(const QList<KUrl> &urls,
|
||||||
return docs;
|
return docs;
|
||||||
}
|
}
|
||||||
|
|
||||||
KTextEditor::Document *KateDocManager::openUrl (const KUrl& url, const QString &encoding, bool isTempFile, const KateDocumentInfo& docInfo)
|
KTextEditor::Document *KateDocManager::openUrl (const KUrl& url, const QString &encoding, const KateDocumentInfo& docInfo)
|
||||||
{
|
{
|
||||||
KUrl u(url);
|
KUrl u(url);
|
||||||
u.cleanPath();
|
u.cleanPath();
|
||||||
|
@ -254,16 +254,6 @@ KTextEditor::Document *KateDocManager::openUrl (const KUrl& url, const QString &
|
||||||
doc->setEncoding(encoding);
|
doc->setEncoding(encoding);
|
||||||
|
|
||||||
doc->setSuppressOpeningErrorDialogs (false);
|
doc->setSuppressOpeningErrorDialogs (false);
|
||||||
|
|
||||||
if ( isTempFile && u.isLocalFile() )
|
|
||||||
{
|
|
||||||
QFileInfo fi( u.toLocalFile() );
|
|
||||||
if ( fi.exists() )
|
|
||||||
{
|
|
||||||
m_tempFiles[ doc] = qMakePair(u, fi.lastModified());
|
|
||||||
kDebug(13001) << "temporary file will be deleted after use unless modified: " << u.pathOrUrl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(doc, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(slotModChanged(KTextEditor::Document*)));
|
connect(doc, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(slotModChanged(KTextEditor::Document*)));
|
||||||
|
|
|
@ -111,12 +111,10 @@ class KateDocManager : public QObject
|
||||||
|
|
||||||
KTextEditor::Document *openUrl(const KUrl&,
|
KTextEditor::Document *openUrl(const KUrl&,
|
||||||
const QString &encoding = QString(),
|
const QString &encoding = QString(),
|
||||||
bool isTempFile = false,
|
|
||||||
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
||||||
|
|
||||||
QList<KTextEditor::Document *> openUrls(const QList<KUrl>&,
|
QList<KTextEditor::Document *> openUrls(const QList<KUrl>&,
|
||||||
const QString &encoding = QString(),
|
const QString &encoding = QString(),
|
||||||
bool isTempFile = false,
|
|
||||||
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
||||||
|
|
||||||
bool closeDocument(KTextEditor::Document *, bool closeUrl = true);
|
bool closeDocument(KTextEditor::Document *, bool closeUrl = true);
|
||||||
|
|
|
@ -142,7 +142,6 @@ int main( int argc, char **argv )
|
||||||
options.add("use", ki18n("Reuse existing Kate instance; default, only for compatibility"));
|
options.add("use", ki18n("Reuse existing Kate instance; default, only for compatibility"));
|
||||||
options.add("+[URL]", ki18n("Document to open"));
|
options.add("+[URL]", ki18n("Document to open"));
|
||||||
KCmdLineArgs::addCmdLineOptions (options);
|
KCmdLineArgs::addCmdLineOptions (options);
|
||||||
KCmdLineArgs::addTempFileOption();
|
|
||||||
|
|
||||||
// get our command line args ;)
|
// get our command line args ;)
|
||||||
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
|
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
|
||||||
|
@ -244,8 +243,6 @@ int main( int argc, char **argv )
|
||||||
|
|
||||||
QString enc = args->isSet("encoding") ? args->getOption("encoding") : QByteArray("");
|
QString enc = args->isSet("encoding") ? args->getOption("encoding") : QByteArray("");
|
||||||
|
|
||||||
bool tempfileSet = KCmdLineArgs::isTempFileSet();
|
|
||||||
|
|
||||||
// only block, if files to open there....
|
// only block, if files to open there....
|
||||||
bool needToBlock = args->isSet( "block" ) && (args->count() > 0);
|
bool needToBlock = args->isSet( "block" ) && (args->count() > 0);
|
||||||
|
|
||||||
|
@ -260,7 +257,6 @@ int main( int argc, char **argv )
|
||||||
QList<QVariant> dbusargs;
|
QList<QVariant> dbusargs;
|
||||||
dbusargs.append(args->url(z).url());
|
dbusargs.append(args->url(z).url());
|
||||||
dbusargs.append(enc);
|
dbusargs.append(enc);
|
||||||
dbusargs.append(tempfileSet);
|
|
||||||
m.setArguments(dbusargs);
|
m.setArguments(dbusargs);
|
||||||
|
|
||||||
QDBusMessage res=QDBusConnection::sessionBus().call (m);
|
QDBusMessage res=QDBusConnection::sessionBus().call (m);
|
||||||
|
|
|
@ -523,8 +523,7 @@ void KateMainWindow::slotOpenDocument(KUrl url)
|
||||||
{
|
{
|
||||||
m_viewManager->openUrl(url,
|
m_viewManager->openUrl(url,
|
||||||
QString(),
|
QString(),
|
||||||
true,
|
true);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KateMainWindow::readOptions ()
|
void KateMainWindow::readOptions ()
|
||||||
|
|
|
@ -275,7 +275,7 @@ void KateViewManager::slotDocumentOpen ()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KTextEditor::Document *lastID = openUrls(r.URLs, r.encoding, false, docInfo);
|
KTextEditor::Document *lastID = openUrls(r.URLs, r.encoding, docInfo);
|
||||||
|
|
||||||
if (lastID)
|
if (lastID)
|
||||||
activateView (lastID);
|
activateView (lastID);
|
||||||
|
@ -312,10 +312,9 @@ void KateViewManager::slotDocumentClose ()
|
||||||
KTextEditor::Document *KateViewManager::openUrl (const KUrl &url,
|
KTextEditor::Document *KateViewManager::openUrl (const KUrl &url,
|
||||||
const QString& encoding,
|
const QString& encoding,
|
||||||
bool activate,
|
bool activate,
|
||||||
bool isTempFile,
|
|
||||||
const KateDocumentInfo& docInfo)
|
const KateDocumentInfo& docInfo)
|
||||||
{
|
{
|
||||||
KTextEditor::Document *doc = KateDocManager::self()->openUrl (url, encoding, isTempFile, docInfo);
|
KTextEditor::Document *doc = KateDocManager::self()->openUrl (url, encoding, docInfo);
|
||||||
|
|
||||||
if (!doc->url().isEmpty())
|
if (!doc->url().isEmpty())
|
||||||
m_mainWindow->fileOpenRecent->addUrl( doc->url() );
|
m_mainWindow->fileOpenRecent->addUrl( doc->url() );
|
||||||
|
@ -328,10 +327,9 @@ KTextEditor::Document *KateViewManager::openUrl (const KUrl &url,
|
||||||
|
|
||||||
KTextEditor::Document *KateViewManager::openUrls (const QList<KUrl> &urls,
|
KTextEditor::Document *KateViewManager::openUrls (const QList<KUrl> &urls,
|
||||||
const QString& encoding,
|
const QString& encoding,
|
||||||
bool isTempFile,
|
|
||||||
const KateDocumentInfo& docInfo)
|
const KateDocumentInfo& docInfo)
|
||||||
{
|
{
|
||||||
QList<KTextEditor::Document *> docs = KateDocManager::self()->openUrls(urls, encoding, isTempFile, docInfo);
|
QList<KTextEditor::Document *> docs = KateDocManager::self()->openUrls(urls, encoding, docInfo);
|
||||||
|
|
||||||
foreach (const KTextEditor::Document *doc, docs) {
|
foreach (const KTextEditor::Document *doc, docs) {
|
||||||
if (!doc->url().isEmpty()) {
|
if (!doc->url().isEmpty()) {
|
||||||
|
|
|
@ -75,12 +75,10 @@ class KateViewManager : public QSplitter
|
||||||
KTextEditor::Document *openUrl (const KUrl &url,
|
KTextEditor::Document *openUrl (const KUrl &url,
|
||||||
const QString& encoding,
|
const QString& encoding,
|
||||||
bool activate = true,
|
bool activate = true,
|
||||||
bool isTempFile = false,
|
|
||||||
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
||||||
|
|
||||||
KTextEditor::Document *openUrls (const QList<KUrl> &url,
|
KTextEditor::Document *openUrls (const QList<KUrl> &url,
|
||||||
const QString& encoding,
|
const QString& encoding,
|
||||||
bool isTempFile = false,
|
|
||||||
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
const KateDocumentInfo& docInfo = KateDocumentInfo());
|
||||||
|
|
||||||
KTextEditor::View *openUrlWithView (const KUrl &url, const QString& encoding);
|
KTextEditor::View *openUrlWithView (const KUrl &url, const QString& encoding);
|
||||||
|
|
|
@ -120,7 +120,6 @@ Name[zh_TW]=Kate
|
||||||
MimeType=text/plain;
|
MimeType=text/plain;
|
||||||
Exec=kate --icon '%i' --caption '%c' -b %U
|
Exec=kate --icon '%i' --caption '%c' -b %U
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
X-KDE-HasTempFileOption=true
|
|
||||||
Icon=kate
|
Icon=kate
|
||||||
X-DocPath=kate/index.html
|
X-DocPath=kate/index.html
|
||||||
Type=Application
|
Type=Application
|
||||||
|
|
|
@ -131,7 +131,6 @@ int main( int argc, char **argv )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KCmdLineArgs::addCmdLineOptions( options );
|
KCmdLineArgs::addCmdLineOptions( options );
|
||||||
KCmdLineArgs::addTempFileOption();
|
|
||||||
|
|
||||||
#ifdef KIOCLIENT_AS_KIOCLIENT
|
#ifdef KIOCLIENT_AS_KIOCLIENT
|
||||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||||
|
|
Loading…
Add table
Reference in a new issue