This commit is contained in:
Max-Wilhelm Bruker 2009-10-03 02:47:17 +02:00
parent ebca375755
commit 9f35340188
11 changed files with 135 additions and 59 deletions

View file

@ -222,6 +222,14 @@ void CardInfo::clearPixmapCache()
}
}
void CardInfo::clearPixmapCacheMiss()
{
if (!pixmap)
return;
if (pixmap->isNull())
clearPixmapCache();
}
void CardInfo::updatePixmapCache()
{
qDebug(QString("Updating pixmap cache for %1").arg(name).toLatin1());
@ -456,6 +464,14 @@ void CardDatabase::updatePicDownload(int _picDownload)
picDownload = settings.value("personal/picturedownload", 0).toInt();
} else
picDownload = _picDownload;
if (picDownload) {
QHashIterator<QString, CardInfo *> cardIterator(cardHash);
while (cardIterator.hasNext()) {
CardInfo *c = cardIterator.next().value();
c->clearPixmapCacheMiss();
}
}
}
void CardDatabase::updatePicsPath(const QString &path)

View file

@ -83,6 +83,7 @@ public:
QPixmap *loadPixmap();
QPixmap *getPixmap(QSize size);
void clearPixmapCache();
void clearPixmapCacheMiss();
void updatePixmapCache();
private slots:
void picDownloadFinished(int id, bool error);

View file

@ -226,10 +226,20 @@ void Client::readLine()
ServerResponse resp;
if (values[0] == "ok")
resp = RespOk;
else if (values[0] == "name_not_found")
resp = RespNameNotFound;
else if (values[0] == "login_needed")
resp = RespLoginNeeded;
else if (values[0] == "syntax")
resp = RespSyntaxError;
else if (values[0] == "context")
resp = RespContextError;
else if (values[0] == "password")
resp = RespPassword;
resp = RespPasswordWrong;
else if (values[0] == "spectators_not_allowed")
resp = RespSpectatorsNotAllowed;
else
resp = RespErr;
resp = RespInvalid;
pc->responseReceived(resp);
} else if (prefix == "list_games") {
if (values.size() != 8) {

View file

@ -20,8 +20,13 @@ enum ProtocolStatus { StatusDisconnected,
enum ServerResponse {
RespOk,
RespPassword,
RespErr
RespNameNotFound,
RespLoginNeeded,
RespSyntaxError,
RespContextError,
RespPasswordWrong,
RespSpectatorsNotAllowed,
RespInvalid
};
enum ServerEventType {

View file

@ -72,7 +72,7 @@ void DlgCreateGame::checkResponse(ServerResponse response)
if (response == RespOk)
accept();
else {
QMessageBox::critical(this, tr("Error"), tr("XXX"));
QMessageBox::critical(this, tr("Error"), tr("Server error."));
return;
}
}

View file

@ -51,22 +51,19 @@ void GameSelector::actCreate()
disableGameList();
}
void GameSelector::actRefresh()
{
client->listGames();
}
void GameSelector::checkResponse(ServerResponse response)
{
createButton->setEnabled(true);
joinButton->setEnabled(true);
spectateButton->setEnabled(true);
if (response == RespOk)
disableGameList();
else {
QMessageBox::critical(this, tr("Error"), tr("XXX"));
return;
switch (response) {
case RespOk: disableGameList(); break;
case RespPasswordWrong: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break;
case RespSpectatorsNotAllowed: QMessageBox::critical(this, tr("Error"), tr("Spectators are not allowed in this game.")); break;
case RespContextError: QMessageBox::critical(this, tr("Error"), tr("The game is already full.")); break;
case RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break;
default: ;
}
}
@ -77,7 +74,7 @@ void GameSelector::actJoin()
QModelIndex ind = gameListView->currentIndex();
if (!ind.isValid())
return;
const ServerGame &game = gameListModel->getGame(ind.row());
const ServerGame &game = gameListModel->getGame(ind.data(Qt::UserRole).toInt());
QString password;
if (game.getHasPassword()) {
bool ok;

View file

@ -20,7 +20,6 @@ public:
private slots:
void showFullGamesChanged(int state);
void actCreate();
void actRefresh();
void actJoin();
void checkResponse(ServerResponse response);
private:

View file

@ -8,7 +8,11 @@ GamesModel::~GamesModel()
QVariant GamesModel::data(const QModelIndex &index, int role) const
{
if ((role != Qt::DisplayRole) || !index.isValid())
if (!index.isValid())
return QVariant();
if (role == Qt::UserRole)
return index.row();
if (role != Qt::DisplayRole)
return QVariant();
if ((index.row() >= gameList.size()) || (index.column() >= columnCount()))
return QVariant();

View file

@ -35,7 +35,7 @@ void MessageLogWidget::logSocketError(const QString &errorString)
void MessageLogWidget::logServerError(ServerResponse response)
{
switch (response) {
case RespPassword: append(tr("Invalid password.")); break;
case RespPasswordWrong: append(tr("Invalid password.")); break;
default: ;
}
}