Ejemplo n.º 1
0
bool UserMenuDialog::saveClicked()
{
	if ( m_currentXmlFile.isEmpty() ) {
		return false;
	}
	KILE_DEBUG() << "save menutree: " << m_currentXmlFile;

	// read current entry
	QTreeWidgetItem *current = m_menutree->currentItem();
	if ( current ) {
		kdDebug() << "read current item ...";
		readMenuentryData( dynamic_cast<UserMenuItem *>(current) );
	}

	if ( saveCheck() == false ) {
		return false;
	}

	// force to save file in local directory
	QStringList dirs = KGlobal::dirs()->findDirs("appdata", "usermenu/");
	if ( dirs.size() > 1 ) {
		if ( m_currentXmlFile.startsWith(dirs[1]) ) {
			m_currentXmlFile.replace(dirs[1],dirs[0]);
			KILE_DEBUG() << "change filename to local directory: " << m_currentXmlFile;
		}
	}

	// save file
	m_menutree->writeXml(m_currentXmlFile);
	return true;
}
Ejemplo n.º 2
0
QString UserMenuDialog::saveAsClicked()
{
	KILE_DEBUG() << "menutree should be saved as ...";

	// read current entry
	QTreeWidgetItem *current = m_menutree->currentItem();
	if ( current ) {
		KILE_DEBUG() << "read current item ...";
		readMenuentryData( dynamic_cast<UserMenuItem *>(current) );
	}

	if ( saveCheck() == false ) {
		return QString();
	}

	QString directory = KStandardDirs::locateLocal("appdata", "usermenu/");
	QString filter = i18n("*.xml|Latex Menu Files");

	QString filename = KFileDialog::getSaveFileName(directory, filter, this, i18n("Save Menu File"));
	if(filename.isEmpty()) {
		return QString();
	}

	if( QFile::exists(filename) ) {
		if ( KMessageBox::questionYesNo(this, i18n("File '%1' does already exist.\nOverwrite this file?", filename)) == KMessageBox::No ) {
			return QString();
		}
	}

	// save file
	m_menutree->writeXml(filename);
	return filename;
}
Ejemplo n.º 3
0
QString UserMenuDialog::saveAsClicked()
{
	KILE_DEBUG_MAIN << "menutree should be saved as ...";

	// read current entry
	QTreeWidgetItem *current = m_menutree->currentItem();
	if (current) {
		KILE_DEBUG_MAIN << "read current item ...";
		readMenuentryData(dynamic_cast<UserMenuItem *>(current));
	}

	if (saveCheck() == false) {
		return QString();
	}

	const QString directory = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "usermenu/";
	const QString filter = i18n("User Menu Files (*.xml)");

	QString filename = QFileDialog::getSaveFileName(this, i18n("Save Menu File"), directory, filter);
	if (filename.isEmpty()) {
		return QString();
	}

	if (QFile::exists(filename)) {
		if (KMessageBox::questionYesNo(this, i18n("File '%1' does already exist.\nOverwrite this file?", filename)) == KMessageBox::No) {
			return QString();
		}
	}

	// save file
	m_menutree->writeXml(filename);
	return filename;
}
Ejemplo n.º 4
0
bool UserMenuDialog::saveClicked()
{
	if (m_currentXmlFile.isEmpty()) {
		return false;
	}
	KILE_DEBUG_MAIN << "save menutree: " << m_currentXmlFile;

	// read current entry
	QTreeWidgetItem *current = m_menutree->currentItem();
	if (current) {
		KILE_DEBUG_MAIN << "read current item ...";
		readMenuentryData( dynamic_cast<UserMenuItem *>(current) );
	}

	if (saveCheck() == false) {
		return false;
	}

	// force to save file in local directory
	QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, "usermenu", QStandardPaths::LocateDirectory);
	if (dirs.size() > 1) {
		if (m_currentXmlFile.startsWith(dirs[1])) {
			m_currentXmlFile.replace(dirs[1],dirs[0]);
			KILE_DEBUG_MAIN << "change filename to local directory:" << m_currentXmlFile;
		}
	}

	// save file
	m_menutree->writeXml(m_currentXmlFile);
	return true;
}
Ejemplo n.º 5
0
void ParamDialog::on_confirmButton_clicked()
{
    saveCheck();
    QFile file(SystemBase::path + QString("/") + SystemBase::postfix);
    if(file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
        QTextStream out(&file);
        out << name << endl;
        file.close();
    }
    accept();
}
Ejemplo n.º 6
0
void MapEditor::closeEvent (QCloseEvent *ev)
{
    if(saveCheck())
    {
        ev->ignore();
        return;
    }

    delete m_mapWidget;
    m_mapWidget=NULL;
    emit closed();
}
Ejemplo n.º 7
0
void ParamDialog::on_newButton_clicked()
{
    saveCheck();
    KeyboardDialog kd(this);
    if(kd.exec() == QDialog::Accepted) {
        if(param != NULL)
            delete param;

        name = kd.getText();
        param = new ParamData(SystemBase::reagentNum);
        treeModel->setHorizontalHeaderLabels(QStringList(name));
        displayUpdate();
        isChanged = true;

        ui->paramView->setEnabled(true);
        ui->saveButton->setEnabled(true);
        ui->saveAsButton->setEnabled(true);
    }
}
Ejemplo n.º 8
0
void ParamDialog::on_openButton_clicked()
{
    saveCheck();
    FileListDialog fd(this, SystemBase::path, QString(".") + SystemBase::postfix);
    if(fd.exec() == QDialog::Accepted) {
        name = fd.selectedFile();
        QFile file(SystemBase::path + name + QString(".") + SystemBase::postfix);
        if(param) {
            param->readParam(SystemBase::reagentNum, file);
        } else {
            param = new ParamData(SystemBase::reagentNum, file);
        }
        treeModel->setHorizontalHeaderLabels(QStringList(name));
        displayUpdate();

        ui->paramView->setEnabled(true);
        ui->saveButton->setEnabled(true);
        ui->saveAsButton->setEnabled(true);
    }
}