Commit a92ca5da authored by Inge Wallin's avatar Inge Wallin

KF5 port: KUrl --> QUrl

parent b3c58935
......@@ -144,13 +144,13 @@ void KmPlot::slotUpdateFullScreen( bool checked)
}
}
bool KmPlot::load(const KUrl& url)
bool KmPlot::load(const QUrl& url)
{
m_part->openUrl( url );
if (m_part->url().isEmpty())
return false;
setCaption(url.prettyUrl(KUrl::LeaveTrailingSlash));
return true;
m_part->openUrl( url );
if (m_part->url().isEmpty())
return false;
setCaption(url.toString()); // PrettyDecoded is the default
return true;
}
void KmPlot::setupActions()
......@@ -188,8 +188,9 @@ void KmPlot::fileOpen()
// this slot is called whenever the File->Open menu is selected,
// the Open shortcut is pressed (usually CTRL+O) or the Open toolbar
// button is clicked
KUrl const url = KFileDialog::getOpenUrl( QDir::currentPath(),
i18n( "*.fkt|KmPlot Files (*.fkt)\n*|All Files" ), this, i18n( "Open" ) );
QUrl const url = KFileDialog::getOpenUrl( QDir::currentPath(),
i18n( "*.fkt|KmPlot Files (*.fkt)\n*|All Files" ),
this, i18n( "Open" ) );
if ( !url.isEmpty())
{
......@@ -204,7 +205,7 @@ void KmPlot::fileOpen()
}
}
void KmPlot::fileOpen(const KUrl &url)
void KmPlot::fileOpen(const QUrl &url)
{
if ( !url.isEmpty())
{
......@@ -220,7 +221,7 @@ void KmPlot::fileOpen(const KUrl &url)
}
void KmPlot::openFileInNewWindow(const KUrl &url)
void KmPlot::openFileInNewWindow(const QUrl &url)
{
KToolInvocation::startServiceByDesktopName("kmplot",url.url());
}
......
......@@ -28,7 +28,6 @@
#include <kcmdlineargs.h>
#include <kparts/mainwindow.h>
#include <kparts/readwritepart.h>
#include <KUrl>
class KmPlotProgress;
class KToggleFullScreenAction;
......@@ -57,7 +56,7 @@ public:
/**
* Use this method to load whatever file/URL you have
*/
bool load(const KUrl& url);
bool load(const QUrl& url);
protected:
/// Quits KmPlot after checking if modifications shall be saved.
......@@ -75,7 +74,7 @@ public Q_SLOTS:
// DBus interface
Q_SCRIPTABLE void fileOpen();
Q_SCRIPTABLE void setStatusBarText(const QString &, int id);
Q_SCRIPTABLE void openFileInNewWindow(const KUrl &url);
Q_SCRIPTABLE void openFileInNewWindow(const QUrl &url);
/**
* Set the progress of drawing the plots, with \p progress ranging from 0
* to 1. After initially calling this function with \p progress less than
......@@ -88,7 +87,7 @@ public Q_SLOTS:
public slots:
/// Called when fullscren is enabled/disabled
void slotUpdateFullScreen(bool);
void fileOpen(const KUrl &url);
void fileOpen(const QUrl &url);
private:
void setupAccel();
......
......@@ -122,7 +122,7 @@ QDomDocument KmPlotIO::currentState()
}
bool KmPlotIO::save( const KUrl &url )
bool KmPlotIO::save( const QUrl &url )
{
QDomDocument doc = currentState();
......@@ -131,31 +131,31 @@ bool KmPlotIO::save( const KUrl &url )
KTemporaryFile tmpfile;
if ( !tmpfile.open() )
{
kWarning() << "Could not open " << KUrl( tmpfile.fileName() ).toLocalFile() << " for writing.\n";
return false;
kWarning() << "Could not open "
<< QUrl( tmpfile.fileName() ).toLocalFile() << " for writing.\n";
return false;
}
QTextStream ts( &tmpfile );
doc.save( ts, 4 );
ts.flush();
if ( !KIO::NetAccess::upload(tmpfile.fileName(), url,0))
{
kWarning() << "Could not open " << url.prettyUrl() << " for writing ("<<KIO::NetAccess::lastErrorString()<<").\n";
return false;
if ( !KIO::NetAccess::upload(tmpfile.fileName(), url,0)) {
kWarning() << "Could not open " << url.toString()
<< " for writing ("<<KIO::NetAccess::lastErrorString()<<").\n";
return false;
}
}
else
{
QFile xmlfile (url.toLocalFile());
if (!xmlfile.open( QIODevice::WriteOnly ) )
else {
QFile xmlfile (url.toLocalFile());
if (!xmlfile.open( QIODevice::WriteOnly ) )
{
kWarning() << "Could not open " << url.path() << " for writing.\n";
return false;
kWarning() << "Could not open " << url.path() << " for writing.\n";
return false;
}
QTextStream ts( &xmlfile );
doc.save( ts, 4 );
xmlfile.close();
return true;
QTextStream ts( &xmlfile );
doc.save( ts, 4 );
xmlfile.close();
return true;
}
return true;
}
......@@ -331,7 +331,7 @@ bool KmPlotIO::restore( const QDomDocument & doc )
}
bool KmPlotIO::load( const KUrl &url )
bool KmPlotIO::load( const QUrl &url )
{
QDomDocument doc( "kmpdoc" );
QFile f;
......
......@@ -53,7 +53,7 @@ class KmPlotIO
* @param exportConstants Whether to save the constants to the file as
* well.
*/
bool save( const KUrl &url );
bool save( const QUrl &url );
/**
* @return a QDomDocument describing the current KmPlot state (settings
......@@ -70,7 +70,7 @@ class KmPlotIO
* @param exportConstants Set to true or false depending on whether the
* opened file had constants saved in it.
*/
bool load( const KUrl &url );
bool load( const QUrl &url );
/**
* Restore KmPlot to the state described in the given QDomDocument.
......
......@@ -209,7 +209,7 @@ bool KParameterEditor::checkValueValid()
void KParameterEditor::cmdImport_clicked()
{
KUrl url = KFileDialog::getOpenUrl( QString(),i18n("*.txt|Plain Text File "));
QUrl url = KFileDialog::getOpenUrl( QString(),i18n("*.txt|Plain Text File "));
if ( url.isEmpty() )
return;
......@@ -279,7 +279,7 @@ void KParameterEditor::cmdExport_clicked()
{
if ( !m_mainWidget->list->count() )
return;
KUrl url = KFileDialog::getSaveUrl( QString(),i18n("*.txt|Plain Text File "));
QUrl url = KFileDialog::getSaveUrl( QString(),i18n("*.txt|Plain Text File "));
if ( url.isEmpty() )
return;
......
......@@ -234,7 +234,7 @@ MainDlg::~MainDlg()
void MainDlg::setupActions()
{
// standard actions
m_recentFiles = KStandardAction::openRecent( this, SLOT( slotOpenRecent( const KUrl& ) ), this );
m_recentFiles = KStandardAction::openRecent( this, SLOT( slotOpenRecent( const QUrl& ) ), this );
actionCollection()->addAction( "file_openrecent", m_recentFiles );
actionCollection()->addAction( KStandardAction::Print, "file_print", this, SLOT( slotPrint() ) );
KStandardAction::save( this, SLOT( slotSave() ), actionCollection() );
......@@ -519,7 +519,9 @@ void MainDlg::slotSaveas()
{
if (m_readonly)
return;
const KUrl url = KFileDialog::getSaveUrl( QDir::currentPath(), i18n( "*.fkt|KmPlot Files (*.fkt)\n*|All Files" ), m_parent, i18n( "Save As" ) );
const QUrl url = KFileDialog::getSaveUrl( QDir::currentPath(),
i18n( "*.fkt|KmPlot Files (*.fkt)\n*|All Files" ),
m_parent, i18n( "Save As" ) );
if ( url.isEmpty() )
return;
......@@ -541,7 +543,7 @@ void MainDlg::slotSaveas()
{
setUrl(url);
m_recentFiles->addUrl( url );
setWindowCaption( KUrl(this->url()).prettyUrl(KUrl::LeaveTrailingSlash) );
setWindowCaption( QUrl(this->url()).toString() );
m_modified = false;
}
}
......@@ -551,7 +553,7 @@ void MainDlg::slotExport()
QString filter = KImageIO::pattern( KImageIO::Writing );
filter += i18n("\n*.svg|Scalable Vector Graphics");
KUrl url = KFileDialog::getSaveUrl( QDir::currentPath(), filter, m_parent, i18n( "Export as Image" ) );
QUrl url = KFileDialog::getSaveUrl( QDir::currentPath(), filter, m_parent, i18n( "Export as Image" ) );
if ( !url.isValid() )
return;
......@@ -624,7 +626,9 @@ void MainDlg::slotExport()
}
if ( !saveOk )
KMessageBox::error( m_parent, i18n( "Sorry, something went wrong while saving to image \"%1\"", url.prettyUrl() ) );
KMessageBox::error(m_parent,
i18n("Sorry, something went wrong while saving to image \"%1\"",
url.toString()));
}
......@@ -633,13 +637,13 @@ bool MainDlg::openFile()
if (url()==m_currentfile || !kmplotio->load( url() ) )
{
m_recentFiles->removeUrl( url() ); //remove the file from the recent-opened-file-list
setUrl(KUrl());
setUrl(QUrl());
return false;
}
m_currentfile = url();
m_recentFiles->addUrl( KUrl(url()).prettyUrl(KUrl::LeaveTrailingSlash) );
setWindowCaption( KUrl(url()).prettyUrl(KUrl::LeaveTrailingSlash) );
m_recentFiles->addUrl( QUrl(url()).toString() );
setWindowCaption( QUrl(url()).toString() );
resetUndoRedo();
View::self()->updateSliders();
View::self()->drawPlot();
......@@ -652,7 +656,7 @@ bool MainDlg::saveFile()
return !isModified();
}
void MainDlg::slotOpenRecent( const KUrl &url )
void MainDlg::slotOpenRecent( const QUrl &url )
{
if( isModified() || !this->url().isEmpty() ) // open the file in a new window
{
......@@ -668,7 +672,7 @@ void MainDlg::slotOpenRecent( const KUrl &url )
m_currentfile = url;
setUrl(url);
m_recentFiles->setCurrentItem(-1); //don't select the item in the open-recent menu
setWindowCaption( KUrl(this->url()).prettyUrl(KUrl::LeaveTrailingSlash) );
setWindowCaption( QUrl(this->url()).toString() );
resetUndoRedo();
View::self()->updateSliders();
View::self()->drawPlot();
......
......@@ -189,7 +189,7 @@ private:
/// MainDlg's parent widget
QWidget *m_parent;
/// Current file
KUrl m_currentfile;
QUrl m_currentfile;
/// The axes config dialogs
CoordsConfigDialog* m_coordsDialog;
/// The constants editor
......@@ -220,7 +220,7 @@ protected slots:
* When you click on a File->Open Recent file, it'll open
* @param url name of the url to open
*/
void slotOpenRecent( const KUrl &url );
void slotOpenRecent( const QUrl &url );
/// @see requestSaveCurrentState
void saveCurrentState();
/// Used when opening a new file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment