Esempio n. 1
0
void KatalogView::openDocumentFile(const QUrl& )
{
  slotStatusMsg(i18n("Opening file..."));

  slotStatusMsg(i18n("Ready."));
}
Esempio n. 2
0
void KBattleshipWindow::slotEnemyFieldClick(int fieldx, int fieldy)
{
	if(m_connection != 0 || m_aiPlaying)
	{
		if(!m_aiPlaying && m_connection == 0)
			return;

		if(!m_serverHasClient && m_connection != 0)
			return;

		if(!m_shootable)
			return;

		if(m_view->enemyFieldState(fieldx, fieldy) == KBattleField::FREE)
		{
			if(!m_aiPlaying && !m_lost)
			{
				slotStatusMsg(i18n("Sending Message..."));
				KMessage *msg = new KMessage(KMessage::SHOOT);
				msg->addField("fieldx", QString::number(fieldx));
				msg->addField("fieldy", QString::number(fieldy));
				slotSendMessage(msg);
			}

			if(m_stat->hit() != 10 && m_aiPlaying)
			{
				m_stat->setShot();

				int showstate;

				if(m_enemyshiplist->shipTypeAt(fieldx, fieldy) == 99)
				{
					m_stat->setWater();
					showstate = KBattleField::WATER;
				}
				else
				{
					m_stat->setHit();
					showstate = KBattleField::HIT;
				}

				slotChangeEnemyFieldData(fieldx, fieldy, showstate);

				if(showstate == KBattleField::HIT)
				{
					KShip *ship = m_enemyshiplist->shipAt(fieldx, fieldy);
					typedef QValueList<int> DeathValueList;
					DeathValueList deathList;
					bool xokay = true, yokay = true;
					int tempy = 0, tempx = 0;

					if(ship->placedLeft())
					{
						for(tempx = ship->shipxstart(); tempx <= ship->shipxstop(); tempx++)
						{
							if(m_view->enemyFieldState(tempx, fieldy) == KBattleField::HIT)
							{
								deathList.append(tempx);
								xokay = true;
								yokay = false;
							}
							else
							{
								xokay = false;
								yokay = false;
								break;
							}
						}
					}
					else
					{
						for(tempy = ship->shipystart(); tempy <= ship->shipystop(); tempy++)
						{
							if(m_view->enemyFieldState(fieldx, tempy) == KBattleField::HIT)
							{
								deathList.append(tempy);
								xokay = false;
								yokay = true;
							}
							else
							{
								xokay = false;
								yokay = false;
								break;
							}
						}
					}

					if(xokay)
					{
						DeathValueList::Iterator it;
						for(it = deathList.begin(); it != deathList.end(); ++it)
						{
							if(fieldy+1 < m_enemyshiplist->m_fieldy) m_view->changeEnemyFieldData(*it, fieldy+1, KBattleField::BORDER);
							m_view->changeEnemyFieldData(*it, fieldy, KBattleField::DEATH);
							if(fieldy > 0) m_view->changeEnemyFieldData(*it, fieldy-1, KBattleField::BORDER);
						}
						if(ship->shipxstart() > 0)
						{
							if (fieldy > 0) m_view->changeEnemyFieldData(ship->shipxstart()-1, fieldy-1, KBattleField::BORDER);
							m_view->changeEnemyFieldData(ship->shipxstart()-1, fieldy, KBattleField::BORDER);
							if (fieldy < m_enemyshiplist->m_fieldy) m_view->changeEnemyFieldData(ship->shipxstart()-1, fieldy+1, KBattleField::BORDER);
						}
						if(ship->shipxstop() < m_enemyshiplist->m_fieldx)
						{
							if (fieldy>0) m_view->changeEnemyFieldData(ship->shipxstop()+1, fieldy-1, KBattleField::BORDER);
							m_view->changeEnemyFieldData(ship->shipxstop()+1, fieldy, KBattleField::BORDER);
							if (fieldy < m_enemyshiplist->m_fieldy)m_view->changeEnemyFieldData(ship->shipxstop()+1,fieldy+1, KBattleField::BORDER);
						}
					}
					else if(yokay)
					{
						DeathValueList::Iterator it;
						for(it = deathList.begin(); it != deathList.end(); ++it)
						{
							if (fieldx>0) m_view->changeEnemyFieldData(fieldx-1, *it, KBattleField::BORDER);
							m_view->changeEnemyFieldData(fieldx, *it, KBattleField::DEATH);
							if(fieldx<m_enemyshiplist->m_fieldx) m_view->changeEnemyFieldData(fieldx+1, *it, KBattleField::BORDER);
						}
						if(ship->shipystart()>0)
						{
							if (fieldx>0)m_view->changeEnemyFieldData(fieldx-1, ship->shipystart()-1, KBattleField::BORDER);
							m_view->changeEnemyFieldData(fieldx, ship->shipystart()-1, KBattleField::BORDER);
							if (fieldx<m_enemyshiplist->m_fieldx)m_view->changeEnemyFieldData(fieldx+1, ship->shipystart()-1, KBattleField::BORDER);
						}
						if(ship->shipystop()<m_enemyshiplist->m_fieldy)
						{
							if (fieldx>0)m_view->changeEnemyFieldData(fieldx-1, ship->shipystop()+1, KBattleField::BORDER);
							m_view->changeEnemyFieldData(fieldx, ship->shipystop()+1, KBattleField::BORDER);
							if (fieldx<m_enemyshiplist->m_fieldx)m_view->changeEnemyFieldData(fieldx+1, ship->shipystop()+1, KBattleField::BORDER);
						}
					}
				}
			}

			if(m_stat->hit() == 10 && m_aiPlaying)
			{
				m_aiPlaying = false;
				m_shootable = false;
				slotChangeOwnPlayer("-");
				slotChangeEnemyPlayer("-");
				m_gameSingle->setText(i18n("S&ingle Player"));
				m_gameNewServer->setEnabled(true);
				m_gameServerConnect->setEnabled(true);
				slotStatusMsg(i18n("You won the game :)"));
				m_stat->slotAddOwnWon();
				slotUpdateHighscore();
				switch(KMessageBox::questionYesNo(this, i18n("Do you want to restart the game?"),QString::null,i18n("Restart"),i18n("Do Not Restart")))
				{
					case KMessageBox::Yes:
						QTimer::singleShot(0, this, SLOT(slotRestartAI()));
						break;

					case KMessageBox::No:
						QTimer::singleShot(0, this, SLOT(slotDeleteAI()));
						break;
				}
				return;
			}
			else if(m_aiPlayer != 0 && m_aiPlaying)
				m_aiPlayer->slotRequestShot();
		}
	}
}
Esempio n. 3
0
void ndManager::openDocumentFile(const QString& url)
{
    slotStatusMsg(tr("Opening file..."));

    filePath = url;
    QFileInfo file(filePath);
    if(!file.exists()){
        QString title = tr("File not found: %1").arg(filePath);
        const int answer = QMessageBox::question(this,title, tr("The selected file no longer exists. Do you want to remove it from the list of recent opened files ?"), QMessageBox::Yes|QMessageBox::No);
        if(answer == QMessageBox::Yes){
            mFileOpenRecent->removeRecentFile(url);
        } else  {
            mFileOpenRecent->addRecentFile(url); //hack, unselect the item
        }
        filePath.clear();

        return;
    }
    //Check if the file exists
    if(!QFile::exists(url)){
        QMessageBox::critical (this, tr("Error!"),tr("The selected file does not exist."));
        mFileOpenRecent-> removeRecentFile(url);
        return;
    }

    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

    //If no document is open already, open the document asked.
    if(!mainDock){
        mFileOpenRecent->addRecentFile(url);

        //Open the file (that will also initialize the document)
        int returnStatus = doc->openDocument(url);
        if(returnStatus == ndManagerDoc::PARSE_ERROR){
            QApplication::restoreOverrideCursor();
            QMessageBox::critical (this, tr("Error!"),tr("The selected parameter file could not be initialize due to parsing error."));
            //close the document
            doc->closeDocument();
            resetState();
            return;
        }


        setWindowTitle(url);
        QApplication::restoreOverrideCursor();
    }
    // check, if this document is already open. If yes, do not do anything
    else{
        QString path = doc->url();

        if(path == url){
            mFileOpenRecent->addRecentFile(url); //hack, unselect the item
            QApplication::restoreOverrideCursor();
            return;
        }
        //If the document asked is not the already open. Open a new instance of the application with it.
        else{
            mFileOpenRecent->addRecentFile(url);
            filePath = path;

            QProcess::startDetached("ndmanager", QStringList()<<url);
            QApplication::restoreOverrideCursor();
        }
    }

    slotStatusMsg(tr("Ready."));
}
Esempio n. 4
0
void ndManager::slotViewMainToolBar()
{
    slotStatusMsg(tr("Toggle the main toolbar..."));
    mMainToolBar->setVisible(viewMainToolBar->isChecked());
    slotStatusMsg(tr("Ready."));
}
Esempio n. 5
0
void KVerbosApp::slotEditPaste()
{
  slotStatusMsg(i18n("Inserting clipboard contents..."));

  slotStatusMsg(i18n("Ready."));
}
Esempio n. 6
0
void KVerbosApp::slotEditCopy()
{
  slotStatusMsg(i18n("Copying selection to clipboard..."));

  slotStatusMsg(i18n("Ready."));
}
Esempio n. 7
0
void KVerbosApp::slotEditCut()
{
  slotStatusMsg(i18n("Cutting selection..."));

  slotStatusMsg(i18n("Ready."));
}