[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] KTip
From: Tobias Koenig <tokoe82 () yahoo ! de>
Date: 2002-02-19 21:15:12
[Download RAW message or body]
Hello,
the two patches in attachment fix bug #28890 in ktip, so can I commit
them to CVS?
ATM we have the application ktip and the KTipDialog/KTipDatabase class
and both show tips to the user with nearly the same GUI. Are there
any objections against improving KTipDialog a bit (adding 'Previous' button,
adapt the backgroundcolor to ktip) and making ktip a wrapper for KTipDialog?
Ciao,
Tobias
--
In a world without walls and fences who
needs Windows and Gates???
["ktip.patch" (text/plain)]
--- ktip.cpp.old Tue Feb 19 21:07:19 2002
+++ ktip.cpp Tue Feb 19 21:10:20 2002
@@ -64,51 +64,34 @@ KTipDatabase::KTipDatabase(const QString
// text as done here.
void KTipDatabase::loadTips(const QString &tipFile)
{
- QString fname;
+ QString fileName = locate("data", tipFile);
- fname = locate("data", tipFile);
-
- if (fname.isEmpty())
- return ;
-
- tips.clear();
-
- QFile f(fname);
- if (f.open(IO_ReadOnly))
+ if (fileName.isEmpty())
{
- QTextStream ts(&f);
-
- QString line, tag, tip;
- bool inTip = false;
- while (!ts.eof())
- {
- line = ts.readLine();
- tag = line.stripWhiteSpace().lower();
+ qWarning("can't find '%s' in standard dirs", tipFile.latin1());
+ return;
+ }
- if (tag == "<html>")
+ QFile file(fileName);
+ if (!file.open(IO_ReadOnly))
{
- inTip = true;
- tip = QString::null;
- continue;
+ qWarning("can't open '%s' for reading", fileName.latin1());
+ return;
}
- if (inTip)
- {
- if (tag == "</html>")
+ tips.clear();
+
+ QString content = file.readAll();
+
+ int pos = -1;
+ while ((pos = content.find("<html>", pos + 1, false)) != -1)
{
+ QString tip = content.mid(pos + 6, content.find("</html>", pos, false) - pos - 6);
tips.append(tip);
- inTip = false;
- }
- else
- tip.append(line).append("\n");
}
- }
-
- f.close();
- }
+ file.close();
}
-
void KTipDatabase::nextTip()
{
["ktipwindow.patch" (text/plain)]
--- ktipwindow.cpp.old Tue Feb 19 21:00:07 2002
+++ ktipwindow.cpp Tue Feb 19 21:00:51 2002
@@ -164,51 +164,34 @@ void TipWindow::startupClicked()
// text as done here.
void TipWindow::loadTips()
{
- QString fname;
+ QString fileName = locate("data", QString("kdewizard/tips"));
- fname = locate("data", QString("kdewizard/tips"));
+ if (fileName.isEmpty())
+ {
+ qWarning("can't find kdewizard/tips in standard dirs");
+ return;
+ }
- if (fname.isEmpty())
+ QFile file(fileName);
+ if (!file.open(IO_ReadOnly))
+ {
+ qWarning("can't open '%s' for reading", fileName.latin1());
return;
+ }
tips.clear();
- QFile f(fname);
- if (f.open(IO_ReadOnly))
- {
- QTextStream ts(&f);
-
- QString line, tag, tip;
- bool inTip = false;
- while (!ts.eof())
- {
- line = ts.readLine();
- tag = line.stripWhiteSpace().lower();
+ QString content = file.readAll();
- if (tag == "<html>")
- {
- inTip = true;
- tip = QString::null;
- continue;
- }
-
- if (inTip)
- {
- if (tag == "</html>")
+ int pos = -1;
+ while ((pos = content.find("<html>", pos + 1, false)) != -1)
{
+ QString tip = content.mid(pos + 6, content.find("</html>", pos, false) - pos - 6);
tips.append(tip);
- inTip = false;
- }
- else
- tip.append(line).append("\n");
}
- }
-
- f.close();
- }
+ file.close();
}
-
void TipWindow::nextTip()
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic